From 9a0b9ed3d77bde99b1f1ba341850117c188f0156 Mon Sep 17 00:00:00 2001 From: bd Date: Mon, 24 Mar 2025 14:41:13 -0400 Subject: Add skeleton classes for 5 major pipeline stages --- src/sim/controller.cc | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/sim/controller.cc') diff --git a/src/sim/controller.cc b/src/sim/controller.cc index 8d48dc9..93fd0e0 100644 --- a/src/sim/controller.cc +++ b/src/sim/controller.cc @@ -1,7 +1,14 @@ #include "controller.h" +#include "ex.h" +#include "id.h" +#include "if.h" +#include "mm.h" +#include "response.h" #include "storage.h" +#include "wb.h" Controller::Controller(Storage *storage, bool is_pipelined) + : Stage(nullptr) { this->clock_cycle = 0; this->storage = storage; @@ -9,12 +16,14 @@ Controller::Controller(Storage *storage, bool is_pipelined) this->pc = 0x0; this->gprs = {0}; - // setup the other pipeline stages - this->next = nullptr; + IF *f = new IF(nullptr); + ID *d = new ID(f); + EX *e = new EX(d); + MM *m = new MM(e); + WB *w = new WB(m); + this->next = w; } -Controller::~Controller() { ; } - void Controller::run_for(int number) { int i; @@ -25,14 +34,13 @@ void Controller::run_for(int number) int Controller::get_clock_cycle() { return this->clock_cycle; } -std::array Controller::get_gprs() { - return this->gprs; -} +std::array Controller::get_gprs() { return this->gprs; } int Controller::get_pc() { return this->pc; } -void Controller::advance() { - ; - // this->next->advance() +Response Controller::advance() +{ + this->next->advance(); ++this->clock_cycle; + return OK; } -- cgit v1.2.3