summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/gui.cc2
-rw-r--r--gui/gui.h5
-rw-r--r--gui/worker.cc55
-rw-r--r--gui/worker.h80
4 files changed, 85 insertions, 57 deletions
diff --git a/gui/gui.cc b/gui/gui.cc
index 3a1027a..dc77fc9 100644
--- a/gui/gui.cc
+++ b/gui/gui.cc
@@ -351,7 +351,7 @@ void GUI::on_config_clicked()
else
this->set_status(get_initialize);
- emit sendConfigure(ways, is_pipelined);
+ emit sendConfigure(ways, this->p, is_pipelined);
}
void GUI::set_status(const std::function<std::string()> &func)
diff --git a/gui/gui.h b/gui/gui.h
index 97f131a..cbd482b 100644
--- a/gui/gui.h
+++ b/gui/gui.h
@@ -42,7 +42,10 @@ class GUI : public QMainWindow
void sendRefreshCache();
void sendRefreshRegisters();
void sendRunSteps(int steps);
- void sendConfigure(std::vector<unsigned int> ways, bool is_pipelined);
+ void sendConfigure(
+ std::vector<unsigned int> ways,
+ vector<int> program,
+ bool is_pipelined);
private slots:
void onWorkerClockCycles(int value, int pc);
diff --git a/gui/worker.cc b/gui/worker.cc
index 558552f..6ec564e 100644
--- a/gui/worker.cc
+++ b/gui/worker.cc
@@ -1,4 +1,5 @@
#include "worker.h"
+#include "storage.h"
Worker::Worker(QObject *parent) : QObject(parent) {}
@@ -10,30 +11,38 @@ Worker::~Worker()
delete this->ct;
}
-void Worker::configure(std::vector<unsigned int> ways, bool is_pipelined)
+void Worker::configure(
+ std::vector<unsigned int> ways,
+ std::vector<signed int> program,
+ bool is_pipelined)
{
- // this->d = new Dram(DRAM_DELAY);
- // setWays(ways);
- // setSize(size);
- // this->cache_enabled = is_cache_enabled;
- // if (!is_cache_enabled || ways.size() == 0) {
- // this->ct = new Controller(wb_stage, this->d, is_pipelined);
- // } else {
- // // 0th index cache has largest delay
- // for (int i = 0; i < ways.size(); i++) {
- // if (i == 0) {
- // Cache *cache =
- // new Cache(this->d, size[i], ways[i], ways.size());
- // this->c.push_back(cache);
- // } else {
- // Cache *cache = new Cache(
- // this->c[i - 1], size[i], ways[i], ways.size() - i);
- // this->c.push_back(cache);
- // }
- // }
- // this->ct =
- // new Controller(wb_stage, this->c.at(ways.size() - 1), is_pipelined);
- // }
+ unsigned int size_inc;
+ Dram *d;
+ Storage *s;
+ int i;
+
+ if (ways.size() != 0)
+ size_inc = MEM_LINE_SPEC / ways.size();
+ d = new Dram(DRAM_DELAY);
+ s = (Storage *)d;
+
+ this->s.push_front(s);
+ d->load(program);
+
+ for (i = ways.size(); i > 0; --i) {
+ s = (Storage *)new Cache(
+ s, size_inc * (i), ways.at(i - 1), CACHE_DELAY + i);
+ this->s.push_front(s);
+ }
+
+ this->if_stage = new IF(nullptr);
+ this->id_stage = new ID(if_stage);
+ this->ex_stage = new EX(id_stage);
+ this->mm_stage = new MM(ex_stage);
+ this->wb_stage = new WB(mm_stage);
+ this->ct =
+ new Controller(wb_stage, s, is_pipelined);
+
emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc());
}
diff --git a/gui/worker.h b/gui/worker.h
index df7d9cc..b6332b0 100644
--- a/gui/worker.h
+++ b/gui/worker.h
@@ -1,49 +1,65 @@
#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 <QObject>
+#include <QThread>
+#include <deque>
-class Worker : public QObject {
- Q_OBJECT
+class Worker : public QObject
+{
+ Q_OBJECT
-private:
- std::vector<Storage*> s;
- std::vector<Stage*> p;
- Controller *ct;
+ private:
+ /**
+ * The storage objects, stored smallest to largest.
+ */
+ std::deque<Storage *> s;
+ /**
+ * The stage objects, starting with fetch.
+ */
+ IF *if_stage;
+ ID *id_stage;
+ EX *ex_stage;
+ MM *mm_stage;
+ WB *wb_stage;
+ Controller *ct;
-public:
- explicit Worker(QObject *parent = nullptr);
- ~Worker();
+ public:
+ explicit Worker(QObject *parent = nullptr);
+ ~Worker();
-public slots:
- void refreshDram();
- void refreshCache();
- void refreshRegisters();
- void runSteps(int steps);
- void configure(std::vector<unsigned int> ways, bool is_pipelined);
+ public slots:
+ void refreshDram();
+ void refreshCache();
+ void refreshRegisters();
+ 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