summaryrefslogtreecommitdiff
path: root/src/sim/controller.cc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-17 20:52:55 -0400
committerbd <bdunahu@operationnull.com>2025-04-17 20:52:55 -0400
commit496a08fbfafb8399c9addaf2501262fee228ffd6 (patch)
tree3e87aed03b50673c8e8c53dba98a45f32f979f48 /src/sim/controller.cc
parent025cdd8e174fcf1a229355ecaf63861ac388fa63 (diff)
parent984ce6eef2e439955ff991f90c2b654be7c6c3f3 (diff)
Merge remote-tracking branch 'origin/bdunahu' into dev-sid
Diffstat (limited to 'src/sim/controller.cc')
-rw-r--r--src/sim/controller.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/sim/controller.cc b/src/sim/controller.cc
index 65e5676..db6106c 100644
--- a/src/sim/controller.cc
+++ b/src/sim/controller.cc
@@ -1,4 +1,5 @@
#include "controller.h"
+#include "ex.h"
#include "response.h"
#include "storage.h"
@@ -8,9 +9,11 @@ Controller::Controller(Stage *stage, Storage *storage, bool is_pipelined)
this->clock_cycle = 1;
this->storage = storage;
this->is_pipelined = is_pipelined;
+ this->is_empty = true;
this->pc = 0x0;
this->checked_out = {};
this->gprs = {0};
+ this->gprs.at(2) = MEM_WORDS; // set the stack pointer
// grant side-door access
this->id = SIDE;
}
@@ -19,7 +22,11 @@ void Controller::run_for(int number)
{
int i;
for (i = 0; i < number; ++i) {
- this->advance(WAIT);
+ try {
+ this->advance(WAIT);
+ } catch (HaltException &e) {
+ break;
+ }
}
}
@@ -27,10 +34,6 @@ int Controller::get_clock_cycle() { return this->clock_cycle; }
std::array<int, GPR_NUM> Controller::get_gprs() { return this->gprs; }
-void Controller::set_gprs(int index, int value) { this->gprs[index] = value; }
-
-void Controller::set_pipelined(bool value) { this->is_pipelined = value; }
-
int Controller::get_pc() { return this->pc; }
InstrDTO *Controller::advance(Response p)
@@ -39,6 +42,9 @@ InstrDTO *Controller::advance(Response p)
r = this->next->advance(p);
++this->clock_cycle;
+ if (r)
+ this->is_empty = true;
+
return r;
}