summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorbd <bdunaisky@umass.edu>2025-03-23 17:47:34 +0000
committerGitHub <noreply@github.com>2025-03-23 17:47:34 +0000
commit877aa98855fad77ef93a8c9f5a5e8191fbb9e699 (patch)
tree75d92632f6e9b2f112e45791af9dc01389039557 /src/sim
parent8a0a483c0e63fd2be6f514a20ae7309e2e768c94 (diff)
parentdf2391b70b89f15be7932d18fa77f950fc452f31 (diff)
Merge pull request #30 from bdunahu/bdunahu
Add controller.h, implementation and tests.
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/controller.cc38
-rw-r--r--src/sim/stage.cc5
2 files changed, 43 insertions, 0 deletions
diff --git a/src/sim/controller.cc b/src/sim/controller.cc
new file mode 100644
index 0000000..8d48dc9
--- /dev/null
+++ b/src/sim/controller.cc
@@ -0,0 +1,38 @@
+#include "controller.h"
+#include "storage.h"
+
+Controller::Controller(Storage *storage, bool is_pipelined)
+{
+ this->clock_cycle = 0;
+ this->storage = storage;
+ this->is_pipelined = is_pipelined;
+ this->pc = 0x0;
+ this->gprs = {0};
+
+ // setup the other pipeline stages
+ this->next = nullptr;
+}
+
+Controller::~Controller() { ; }
+
+void Controller::run_for(int number)
+{
+ int i;
+ for (i = 0; i < number; ++i) {
+ this->advance();
+ }
+}
+
+int Controller::get_clock_cycle() { return this->clock_cycle; }
+
+std::array<int, GPR_NUM> Controller::get_gprs() {
+ return this->gprs;
+}
+
+int Controller::get_pc() { return this->pc; }
+
+void Controller::advance() {
+ ;
+ // this->next->advance()
+ ++this->clock_cycle;
+}
diff --git a/src/sim/stage.cc b/src/sim/stage.cc
new file mode 100644
index 0000000..7d3a678
--- /dev/null
+++ b/src/sim/stage.cc
@@ -0,0 +1,5 @@
+#include "stage.h"
+
+std::array<int, GPR_NUM> Stage::gprs;
+int Stage::pc;
+Storage *Stage::storage;