summaryrefslogtreecommitdiff
path: root/gui/worker.cc
diff options
context:
space:
mode:
authorSiddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com>2025-04-27 09:12:50 -0400
committerGitHub <noreply@github.com>2025-04-27 09:12:50 -0400
commit5653b2a033e7a4173d2f178b5ce52384666d3d7b (patch)
tree5c8fc7282ad1ce0c215786a70b35296645df2a1b /gui/worker.cc
parent3d0133c2f793e82d7519d8e2c5023114cd0f0eab (diff)
parenta4dd1f00a5d0108058fb3bfbd5f399a507792859 (diff)
Merge pull request #68 from bdunahu/bdunahu
[WIP] Pipeline cleanup and revisited GUI storage display
Diffstat (limited to 'gui/worker.cc')
-rw-r--r--gui/worker.cc53
1 files changed, 32 insertions, 21 deletions
diff --git a/gui/worker.cc b/gui/worker.cc
index 2652fce..0ba364b 100644
--- a/gui/worker.cc
+++ b/gui/worker.cc
@@ -17,14 +17,13 @@
#include "worker.h"
#include "storage.h"
+#include "util.h"
Worker::Worker(QObject *parent) : QObject(parent) {}
Worker::~Worker()
{
emit finished();
- qDebug() << "Worker destructor called in thread:"
- << QThread::currentThread();
delete this->ct;
}
@@ -41,10 +40,6 @@ void Worker::configure(
this->s.clear();
this->ct_mutex.lock();
- if (ways.size() != 0) {
- // TODO optimal proper sizes
- this->size_inc = ((MEM_LINE_SPEC * 0.75) / ways.size());
- }
d = new Dram(DRAM_DELAY);
s = static_cast<Storage *>(d);
@@ -53,7 +48,8 @@ void Worker::configure(
for (i = ways.size(); i > 0; --i) {
s = static_cast<Storage *>(new Cache(
- s, this->size_inc * (i), ways.at(i - 1), CACHE_DELAY + i));
+ s, cache_size_mapper(ways.size() - 1, i - 1), ways.at(i - 1),
+ CACHE_DELAY + i));
this->s.push_front(s);
}
@@ -69,30 +65,45 @@ void Worker::configure(
delete old;
this->ct_mutex.unlock();
- emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc());
+ this->update();
}
void Worker::runSteps(int steps)
{
+ this->ct->run_for(steps);
+ this->update();
+}
+
+void Worker::update()
+{
unsigned long i;
this->ct_mutex.lock();
- qDebug() << "Running for " << steps << "steps";
- this->ct->run_for(steps);
-
- // TODO move these to separate functions
emit register_storage(this->ct->get_gprs());
- emit storage(this->s.at(0)->view(0, 255), 1);
-
- for (i = 1; i < s.size(); ++i)
- emit storage(this->s.at(i - 1)->view(0, 1 << this->size_inc * i), i + 1);
+ for (i = 0; i < s.size(); ++i)
+ emit storage(this->data_to_QT(this->s.at(i)->get_data()), i + 1);
emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc());
- emit if_info(this->if_stage->stage_info());
- emit id_info(this->id_stage->stage_info());
- emit ex_info(this->ex_stage->stage_info());
- emit mm_info(this->mm_stage->stage_info());
- emit wb_info(this->wb_stage->stage_info());
+ emit if_info(this->if_stage->get_instr());
+ emit id_info(this->id_stage->get_instr());
+ emit ex_info(this->ex_stage->get_instr());
+ emit mm_info(this->mm_stage->get_instr());
+ emit wb_info(this->wb_stage->get_instr());
this->ct_mutex.unlock();
}
+
+QVector<QVector<int>>
+Worker::data_to_QT(std::vector<std::array<signed int, LINE_SIZE>> data)
+{
+ QVector<QVector<int>> r;
+ QVector<int> tmp;
+
+ r.reserve(static_cast<int>(data.size()));
+
+ for (const auto &line : data) {
+ tmp = QVector<int>(line.begin(), line.end());
+ r.append(tmp);
+ }
+ return r;
+}