summaryrefslogtreecommitdiff
path: root/gui/worker.h
diff options
context:
space:
mode:
authorbd <bdunaisky@umass.edu>2025-04-21 20:00:58 +0000
committerGitHub <noreply@github.com>2025-04-21 20:00:58 +0000
commitd933a0405b7a7dff3cf05839ac99d120cafa4d75 (patch)
tree43238110a03ce678f1a68b0b4175ae023527b070 /gui/worker.h
parentcdc9d9c6195cf51e2d1ff10ff4f29797d3e51691 (diff)
parent7cad6f05ebed25557fe6a31bfdf6290c72506868 (diff)
Merge pull request #57 from bdunahu/bdunahu
Initialize all pipe objects at once, thread safety,
Diffstat (limited to 'gui/worker.h')
-rw-r--r--gui/worker.h117
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