diff options
author | bd <bdunahu@operationnull.com> | 2025-03-30 14:28:45 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-03-30 14:28:45 -0400 |
commit | 8c46ba4f216aec9f512cd398317f891be9b07e84 (patch) | |
tree | cb502366f721c6bca60becc309fd9de288769d87 /src/sim/stage.cc | |
parent | 916949133a5797772dcd6966e469c12230ffc3fa (diff) |
Add mock stage, proper decode tests
Diffstat (limited to 'src/sim/stage.cc')
-rw-r--r-- | src/sim/stage.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/sim/stage.cc b/src/sim/stage.cc index d8c882a..929a4b9 100644 --- a/src/sim/stage.cc +++ b/src/sim/stage.cc @@ -7,7 +7,7 @@ Stage::Stage(Stage *next) { this->next = next; this->curr_instr = nullptr; - this->status = OK; + this->status = STALLED; this->checked_out = {}; } @@ -21,6 +21,27 @@ Storage *Stage::storage; bool Stage::is_pipelined; int Stage::clock_cycle; +InstrDTO *Stage::advance(Response p) +{ + InstrDTO *r = nullptr; + Response n; + + this->advance_helper(); + if (this->status == OK && p == OK) { + // 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; + } + + n = (p != OK || this->status != OK) ? STALLED : OK; + // the power of consent + this->curr_instr = this->next->advance(n); + return r; +} + void Stage::set_condition(CC c, bool v) { if (v) |