diff options
Diffstat (limited to 'gui/worker.h')
-rw-r--r-- | gui/worker.h | 117 |
1 files changed, 69 insertions, 48 deletions
diff --git a/gui/worker.h b/gui/worker.h index fe539fe..62c8d84 100644 --- a/gui/worker.h +++ b/gui/worker.h @@ -1,64 +1,85 @@ +// Simulator for the RISC-V[ECTOR] mini-ISA +// Copyright (C) 2025 Siddarth Suresh +// Copyright (C) 2025 bdunahu + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <https://www.gnu.org/licenses/>. + #ifndef WORKER_H #define WORKER_H -#include <QObject> -#include <QThread> -#include <QDebug> - +#include "cache.h" #include "controller.h" #include "dram.h" -#include "cache.h" +#include "ex.h" #include "id.h" #include "if.h" -#include "ex.h" #include "mm.h" #include "wb.h" +#include <QDebug> +#include <QMutex> +#include <QObject> +#include <QThread> +#include <deque> + +class Worker : public QObject +{ + Q_OBJECT + + private: + /** + * The storage objects, stored smallest to largest. + */ + std::deque<Storage *> s; + IF *if_stage; + ID *id_stage; + EX *ex_stage; + MM *mm_stage; + WB *wb_stage; -class Worker : public QObject { - Q_OBJECT + Controller *ct = nullptr; + QMutex ct_mutex; -private: - std::vector<Cache*> c; - std::vector<int> cache_ways; - std::vector<int> cache_size; - bool cache_enabled = false; - Dram *d; - Controller *ct; - ID *id_stage; - IF *if_stage; - EX *ex_stage; - MM *mm_stage; - WB *wb_stage; + /** + * The size each progressive cache level increases by. + */ + unsigned int size_inc; -public: - explicit Worker(QObject *parent = nullptr); - ~Worker(); - std::vector<int> getWays(); - std::vector<int> getSize(); - void setWays(std::vector<int> ways); - void setSize(std::vector<int> size); + public: + explicit Worker(QObject *parent = nullptr); + ~Worker(); + QMutex &get_ct_mutex() { return ct_mutex; } -public slots: - void doWork(); - void refreshDram(); - void loadProgram(std::vector<signed int> p); - void configure(std::vector<int> ways, std::vector<int> size, bool is_pipelined, bool is_cache_enabled); - void refreshCache(); - void refreshRegisters(); - void runSteps(int steps); - void runStep(); + public slots: + void runSteps(int steps); + void configure( + std::vector<unsigned int> ways, + std::vector<signed int> program, + bool is_pipelined); -signals: - void clock_cycles(int value, int pc); - void dram_storage(const std::vector<std::array<signed int, LINE_SIZE>> data); - void cache_storage(const std::vector<std::array<signed int, LINE_SIZE>> data); - void register_storage(const std::array<int, GPR_NUM> data); - void if_info(const std::vector<int> info); - void id_info(const std::vector<int> info); - void ex_info(const std::vector<int> info); - void mm_info(const std::vector<int> info); - void wb_info(const std::vector<int> info); - void finished(); + signals: + void clock_cycles(int value, int pc); + void + dram_storage(const std::vector<std::array<signed int, LINE_SIZE>> data); + void + cache_storage(const std::vector<std::array<signed int, LINE_SIZE>> data); + void register_storage(const std::array<int, GPR_NUM> data); + void if_info(const std::vector<int> info); + void id_info(const std::vector<int> info); + void ex_info(const std::vector<int> info); + void mm_info(const std::vector<int> info); + void wb_info(const std::vector<int> info); + void finished(); }; -#endif // WORKER_H
\ No newline at end of file +#endif // WORKER_H |