summaryrefslogtreecommitdiff
path: root/src/sim/stage.cc
diff options
context:
space:
mode:
authorSiddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com>2025-03-30 19:34:17 -0400
committerGitHub <noreply@github.com>2025-03-30 19:34:17 -0400
commit12a9e93f913c0057f2ef32f5894931c8b4bd3a85 (patch)
tree88669ed2be55b4f455ef4ac56263a01dd5f70a40 /src/sim/stage.cc
parenteedf9686eb60f2008e7766cc9a5d3e037b9dae64 (diff)
parent36dabe6183af98b2e3f6d0316436dc3affc3d986 (diff)
Merge pull request #41 from bdunahu/bdunahu
Add mock stage, proper decode tests changes look good
Diffstat (limited to 'src/sim/stage.cc')
-rw-r--r--src/sim/stage.cc35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/sim/stage.cc b/src/sim/stage.cc
index 62a7fd6..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,39 @@ 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)
+ this->gprs[3] = this->gprs[3] & 1 << c;
+ else
+ this->gprs[3] = this->gprs[3] & ~(1 << c);
+}
+
+bool Stage::get_condition(CC c) {
+ return (this->gprs[3] >> c) & 1;
+}
+
signed int Stage::dereference_register(signed int v)
{
signed int r;