diff options
author | Siddarth-Suresh <65844402+Siddarth-Suresh@users.noreply.github.com> | 2025-04-01 21:54:38 -0400 |
---|---|---|
committer | Siddarth-Suresh <65844402+Siddarth-Suresh@users.noreply.github.com> | 2025-04-01 21:54:38 -0400 |
commit | cc2781682a47dc331f7bbcb5d7842db5197d29fc (patch) | |
tree | 248c770c6e1a51756c5a8fa904ec4873fb66644e /gui/worker.cc | |
parent | 6f536bd1bd1abab307c79d688c993e930cf7c250 (diff) |
GUI and controller on separate threads
Diffstat (limited to 'gui/worker.cc')
-rw-r--r-- | gui/worker.cc | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/gui/worker.cc b/gui/worker.cc new file mode 100644 index 0000000..ca3ec4b --- /dev/null +++ b/gui/worker.cc @@ -0,0 +1,67 @@ +#include "worker.h" + +Worker::Worker(QObject *parent) : QObject(parent) {} + +void Worker::doWork() { + qDebug() << "Initializing..."; + this->d = new Dram(0); + this->c = new Cache(this->d, 0); + 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, this->c, true); + + emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc()); + emit dram_storage(this->d->view(0,32)); + emit cache_storage(this->c->view(0,8)); + emit register_storage(this->ct->get_gprs()); + + signed int w; + w = 0x11223344; + this->d->write_word(MEM, w, 0x0); + this->c->write_word(MEM, w, 0x0); + this->ct->set_gprs(0, w); +} + +Worker::~Worker() { + emit finished(); + qDebug() << "Worker destructor called in thread:" << QThread::currentThread(); + delete this->ct; + delete this->c; +} + + +void Worker::refreshDram() { + qDebug() << "Refreshing Dram"; + emit dram_storage(this->d->view(0,32)); +} + +void Worker::refreshCache() { + qDebug() << "Refreshing Dram"; + emit cache_storage(this->c->view(0,8)); +} + +void Worker::refreshRegisters() { + qDebug() << "Refreshing Registers"; + emit register_storage(this->ct->get_gprs()); +} + +void Worker::runSteps(int steps) { + qDebug() << "Running for steps: " << steps; + this->ct->run_for(steps); + emit dram_storage(this->d->view(0,32)); + emit cache_storage(this->c->view(0,8)); + emit register_storage(this->ct->get_gprs()); + emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc()); +} + +void Worker::runStep() { + qDebug() << "Running for 1 step " ; + this->ct->advance(OK); + emit dram_storage(this->d->view(0,32)); + emit cache_storage(this->c->view(0,8)); + emit register_storage(this->ct->get_gprs()); + emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc()); +}
\ No newline at end of file |