From 6579f7272905d1e25b43ef051da6c2180e60ca2b Mon Sep 17 00:00:00 2001 From: bd Date: Tue, 1 Apr 2025 00:49:52 -0400 Subject: Ensure all stages only do work if they are not 'OK' --- src/sim/stage.cc | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/sim/stage.cc') 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 #include +#include 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(); } } -- cgit v1.2.3