diff options
author | bd <bdunahu@operationnull.com> | 2025-04-01 00:49:52 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-01 00:49:52 -0400 |
commit | 6579f7272905d1e25b43ef051da6c2180e60ca2b (patch) | |
tree | a4b217aa56126f7d05304ab93f6c36b66fd6b694 /src/sim/wb.cc | |
parent | a4e0e5ff6208205f6ebd980f9ed1eca91dcc4311 (diff) |
Ensure all stages only do work if they are not 'OK'
Diffstat (limited to 'src/sim/wb.cc')
-rw-r--r-- | src/sim/wb.cc | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/src/sim/wb.cc b/src/sim/wb.cc index ac47f25..276d1d0 100644 --- a/src/sim/wb.cc +++ b/src/sim/wb.cc @@ -6,34 +6,35 @@ WB::WB(Stage *stage) : Stage(stage) { this->id = WRITE; } -void WB::advance_helper() { - if(this -> curr_instr) { - if(this->curr_instr->get_type() == R || this->curr_instr->get_type() == I){ - if(this->checked_out.size() > 0) { - signed int reg = this->checked_out.front(); - this->checked_out.pop_front(); - if(reg >= GPR_NUM){ - // TODO: handle vector instructions - } else { - if(this->curr_instr->get_mnemonic() != STORE && this->curr_instr->get_mnemonic() != STOREV){ - this->gprs[reg] = this->curr_instr->get_s1(); - } - } - } - } else if (this->curr_instr->get_type() == J) { - // TODO:handle push pop - // branch taken - if(this->pc != this->curr_instr->get_s1()) { - if(this->curr_instr->get_mnemonic() == JAL){ - // set link register to next instruction - this->gprs[1] = this->pc + 1; - } - this->pc = this->curr_instr->get_s1(); - //clear pending registers and squash pipeline - this->checked_out = {}; - this->next->squash(); - } - } - } - this->status = OK; +void WB::advance_helper() +{ + if (this->curr_instr->get_type() == R || + this->curr_instr->get_type() == I) { + if (this->checked_out.size() > 0) { + signed int reg = this->checked_out.front(); + this->checked_out.pop_front(); + if (reg >= GPR_NUM) { + // TODO: handle vector instructions + } else { + if (this->curr_instr->get_mnemonic() != STORE && + this->curr_instr->get_mnemonic() != STOREV) { + this->gprs[reg] = this->curr_instr->get_s1(); + } + } + } + } else if (this->curr_instr->get_type() == J) { + // TODO:handle push pop + // branch taken + if (this->pc != this->curr_instr->get_s1()) { + if (this->curr_instr->get_mnemonic() == JAL) { + // set link register to next instruction + this->gprs[1] = this->pc + 1; + } + this->pc = this->curr_instr->get_s1(); + // clear pending registers and squash pipeline + this->checked_out = {}; + this->next->squash(); + } + } + this->status = OK; } |