From 9e30d0054e7b3eb10e4e464b12ae3cc1eecc9585 Mon Sep 17 00:00:00 2001 From: bd Date: Tue, 1 Apr 2025 23:22:12 -0400 Subject: Fix bug with decode pushing checked_out when delayed with RAW --- gui/worker.cc | 132 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 47 deletions(-) (limited to 'gui/worker.cc') diff --git a/gui/worker.cc b/gui/worker.cc index ca3ec4b..2df4e17 100644 --- a/gui/worker.cc +++ b/gui/worker.cc @@ -2,66 +2,104 @@ Worker::Worker(QObject *parent) : QObject(parent) {} -void Worker::doWork() { - qDebug() << "Initializing..."; - this->d = new Dram(0); +void Worker::doWork() +{ + qDebug() << "Initializing..."; + this->d = new Dram(0); this->c = new Cache(this->d, 0); - this->if_stage = new IF(nullptr); + 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); + 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 b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, + b15; + std::vector p; + + // I-TYPE / / / / + b0 = 0b00000010000000000001000000001101; // ADDI $2 $0 0x200; + b1 = 0b00000000000000010010100000001101; // ADDI $5 $0 0x1; + b2 = 0b00000000000000000010100010101101; // STORE $5 0($2); (RAW HAZARD)! + // I-TYPE / / / / + b3 = 0b00000000000000100010100000001101; // ADDI $5 $0 0x2; (RAW HAZARD)! + b4 = 0b00000000000000010010100010101101; // STORE $5 1($2); (RAW HAZARD)! + // // I-TYPE / / / / + b5 = 0b00000000000000000010100000001101; // ADDI $5 $0 0x0; + // // I-TYPE / / / / + b6 = 0b00000000000000010011000000001101; // ADDI $6 $0 0x1; + // // J-TYPE / / / + b7 = 0b00000000000000000011100000001010; // JRL CHECK + // // R-TYPE / / / / / + b8 = 0b00000000000100100101000100000100; // ADD $9 $2 $5; + // // I-TYPE / / / / + b9 = 0b00000000000000000011101001000101; // LOAD $7 0($9); (RAW HAZARD)! + // // I-TYPE / / / / + b10 = 0b00000000000000010100001001000101; // LOAD $8 1($9); + // // R-TYPE / / / / / + b11 = 0b00000000000011101000001110000100; // ADD $7 $7 $8; + // I-TYPE / / / / + b12 = 0b00000000000000000011101001101101; // STORE $7 0($9); + b13 = 0b00000010000000010010100101001101; // ADDI $5 $5 0x1; + // // R-TYPE / / / / / + b14 = 0b00000000000111100101001101000000; // CMP $6 $5 + // // J-TYPE / / / + b15 = 0b11111111111111111100100000010110; // bgt LOOP + + p = {b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15}; + this->d->load(p); } -Worker::~Worker() { - emit finished(); - qDebug() << "Worker destructor called in thread:" << QThread::currentThread(); - delete this->ct; +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::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::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::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::runSteps(int steps) +{ + qDebug() << "Running for steps: " << steps; + this->ct->run_for(steps); + emit dram_storage(this->d->view(0, 256)); + 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 +void Worker::runStep() +{ + qDebug() << "Running for 1 step "; + this->ct->advance(WAIT); + emit dram_storage(this->d->view(0, 256)); + emit cache_storage(this->c->view(0, 8)); + emit register_storage(this->ct->get_gprs()); + qDebug() << "PC " << this->ct->get_pc(); + emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc()); +} -- cgit v1.2.3 From 3eeb345d673bee6d62b04fc8a8a95ab822dc1e45 Mon Sep 17 00:00:00 2001 From: bd Date: Wed, 2 Apr 2025 00:04:37 -0400 Subject: Last fix to demo program --- gui/worker.cc | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'gui/worker.cc') diff --git a/gui/worker.cc b/gui/worker.cc index 2df4e17..685b46c 100644 --- a/gui/worker.cc +++ b/gui/worker.cc @@ -20,39 +20,46 @@ void Worker::doWork() emit register_storage(this->ct->get_gprs()); signed int b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, - b15; + b15, b16, b17, b18, b19; std::vector p; // I-TYPE / / / / b0 = 0b00000010000000000001000000001101; // ADDI $2 $0 0x200; b1 = 0b00000000000000010010100000001101; // ADDI $5 $0 0x1; - b2 = 0b00000000000000000010100010101101; // STORE $5 0($2); (RAW HAZARD)! + b2 = 0b00000000000000000010100010101101; // STORE $5 0($2); // I-TYPE / / / / - b3 = 0b00000000000000100010100000001101; // ADDI $5 $0 0x2; (RAW HAZARD)! - b4 = 0b00000000000000010010100010101101; // STORE $5 1($2); (RAW HAZARD)! - // // I-TYPE / / / / - b5 = 0b00000000000000000010100000001101; // ADDI $5 $0 0x0; - // // I-TYPE / / / / - b6 = 0b00000000000000010011000000001101; // ADDI $6 $0 0x1; - // // J-TYPE / / / - b7 = 0b00000000000000000011100000001010; // JRL CHECK - // // R-TYPE / / / / / - b8 = 0b00000000000100100101000100000100; // ADD $9 $2 $5; + b3 = 0b00000000000000100010100000001101; // ADDI $5 $0 0x2; + b4 = 0b00000000000000010010100010101101; // STORE $5 1($2); + // I-TYPE / / / / + b5 = 0b00000000000000110010100000001101; // ADDI $5 $0 0x3; + b6 = 0b00000000000000100010100010101101; // STORE $5 2($2); + // I-TYPE / / / / + b7 = 0b00000000000001000010100000001101; // ADDI $5 $0 0x4; + b8 = 0b00000000000000110010100010101101; // STORE $5 3($2); // // I-TYPE / / / / - b9 = 0b00000000000000000011101001000101; // LOAD $7 0($9); (RAW HAZARD)! + b9 = 0b00000000000000000010100000001101; // ADDI $5 $0 0x0; + // // I-TYPE / / / / + b10 = 0b00000000000000110011000000001101; // ADDI $6 $0 0x3; + // // J-TYPE / / / + b11 = 0b00000000000000000011100000001010; // JRL CHECK + // // R-TYPE / / / / / + b12 = 0b00000000000100100101000100000100; // ADD $9 $2 $5; + // // I-TYPE / / / / + b13 = 0b00000000000000000011101001000101; // LOAD $7 0($9); (RAW HAZARD)! // // I-TYPE / / / / - b10 = 0b00000000000000010100001001000101; // LOAD $8 1($9); + b14 = 0b00000000000000010100001001000101; // LOAD $8 1($9); // // R-TYPE / / / / / - b11 = 0b00000000000011101000001110000100; // ADD $7 $7 $8; + b15 = 0b00000000000011101000001110000100; // ADD $7 $7 $8; // I-TYPE / / / / - b12 = 0b00000000000000000011101001101101; // STORE $7 0($9); - b13 = 0b00000010000000010010100101001101; // ADDI $5 $5 0x1; + b16 = 0b00000000000000000011101001101101; // STORE $7 0($9); + b17 = 0b00000000000000010010100101001101; // ADDI $5 $5 0x1; // // R-TYPE / / / / / - b14 = 0b00000000000111100101001101000000; // CMP $6 $5 + b18 = 0b00000000000111100101001101000000; // CMP $6 $5 // // J-TYPE / / / - b15 = 0b11111111111111111100100000010110; // bgt LOOP + b19 = 0b11111111111111111100000000010110; // bgt LOOP - p = {b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15}; + p = {b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, + b10, b11, b12, b13, b14, b15, b16, b17, b18, b19}; this->d->load(p); } -- cgit v1.2.3