From 2416cce2eec7ecdf0587896620806c465747eada Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 22 Mar 2025 14:19:10 -0400 Subject: Add controller.h, implementation and tests. --- src/sim/controller.cc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/sim/controller.cc (limited to 'src/sim/controller.cc') diff --git a/src/sim/controller.cc b/src/sim/controller.cc new file mode 100644 index 0000000..c6d1bff --- /dev/null +++ b/src/sim/controller.cc @@ -0,0 +1,37 @@ +#include "controller.h" +#include "storage.h" + +Controller::Controller(Storage *storage, bool is_pipelined) +{ + 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 Controller::get_gprs() { + return this->gprs; +} + +int Controller::get_pc() { return this->pc; } + +void Controller::advance() { + ; + // this->next->advance() + ++this->clock_cycle; +} -- cgit v1.2.3 From df2391b70b89f15be7932d18fa77f950fc452f31 Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 22 Mar 2025 14:24:16 -0400 Subject: Initialize clock_cycle --- src/sim/controller.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sim/controller.cc') diff --git a/src/sim/controller.cc b/src/sim/controller.cc index c6d1bff..8d48dc9 100644 --- a/src/sim/controller.cc +++ b/src/sim/controller.cc @@ -3,6 +3,7 @@ Controller::Controller(Storage *storage, bool is_pipelined) { + this->clock_cycle = 0; this->storage = storage; this->is_pipelined = is_pipelined; this->pc = 0x0; -- cgit v1.2.3