summaryrefslogtreecommitdiff
path: root/src/sim/stage.cc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-01 00:49:52 -0400
committerbd <bdunahu@operationnull.com>2025-04-01 00:49:52 -0400
commit6579f7272905d1e25b43ef051da6c2180e60ca2b (patch)
treea4b217aa56126f7d05304ab93f6c36b66fd6b694 /src/sim/stage.cc
parenta4e0e5ff6208205f6ebd980f9ed1eca91dcc4311 (diff)
Ensure all stages only do work if they are not 'OK'
Diffstat (limited to 'src/sim/stage.cc')
-rw-r--r--src/sim/stage.cc23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/sim/stage.cc b/src/sim/stage.cc
index 0f13d65..31d7d0d 100644
--- a/src/sim/stage.cc
+++ b/src/sim/stage.cc
@@ -2,13 +2,13 @@
#include "utils.h"
#include <array>
#include <deque>
+#include <iostream>
Stage::Stage(Stage *next)
{
this->next = next;
this->curr_instr = nullptr;
- this->status = OK;
- this->checked_out = {};
+ this->status = WAIT;
}
Stage::~Stage() { delete this->next; };
@@ -21,13 +21,9 @@ Storage *Stage::storage;
bool Stage::is_pipelined;
int Stage::clock_cycle;
-bool Stage::get_condition(CC c) {
- return (this->gprs[3] >> c) & 1;
-}
+bool Stage::get_condition(CC c) { return (this->gprs[3] >> c) & 1; }
-void Stage::set_pc(unsigned int pc) {
- this->pc = pc;
-}
+void Stage::set_pc(unsigned int pc) { this->pc = pc; }
InstrDTO *Stage::advance(Response p)
{
@@ -36,16 +32,16 @@ InstrDTO *Stage::advance(Response p)
if (this->curr_instr && this->status != OK)
this->advance_helper();
- if (this->status == OK && p == OK && this->curr_instr) {
+ if (this->status == OK && p == WAIT && this->curr_instr) {
// mutual consent
this->curr_instr->set_time_of(this->id, this->clock_cycle);
r = new InstrDTO(*this->curr_instr);
delete curr_instr;
curr_instr = nullptr;
- this->status = STALLED;
+ this->status = WAIT;
}
- n = (p != OK || this->status != OK) ? STALLED : OK;
+ n = (p != WAIT || this->status != WAIT) ? STALLED : WAIT;
// the power of consent
this->curr_instr = this->next->advance(n);
return r;
@@ -80,10 +76,11 @@ bool Stage::is_checked_out(signed int r)
this->checked_out.end();
}
-void Stage::squash(){
+void Stage::squash()
+{
this->curr_instr->set_mnemonic(NOP);
this->status = OK;
- if(this->next){
+ if (this->next) {
this->next->squash();
}
}