diff options
author | Siddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com> | 2025-03-30 22:35:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-30 22:35:06 -0400 |
commit | 44cb9d396b909c84ef7ad3338e0a12cfcc082748 (patch) | |
tree | b080d1ad4989ab5f5848d9571b01c0fc505b136a /tests/controller.cc | |
parent | 52e1ca72925444b8e5a9bb5b240a4063a4d7b958 (diff) | |
parent | 723d582d1108975caf071a76c1556a01fb0553d1 (diff) |
Merge pull request #43 from bdunahu/bdunahu
Sanity check for pipeline up to exe
Diffstat (limited to 'tests/controller.cc')
-rw-r--r-- | tests/controller.cc | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/tests/controller.cc b/tests/controller.cc index e3b9f3c..de49629 100644 --- a/tests/controller.cc +++ b/tests/controller.cc @@ -8,21 +8,21 @@ #include "wb.h" #include <algorithm> #include <catch2/catch_test_macros.hpp> +#include <vector> class ControllerPipeFixture { public: ControllerPipeFixture() { - this->c = new Cache(new Dram(3), 1); + this->d = new Dram(1); + this->c = new Cache(this->d, 0); 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->ct = new Controller(w, this->c, true); + this->ct = new Controller(e, this->c, true); } ~ControllerPipeFixture() { @@ -31,6 +31,7 @@ class ControllerPipeFixture }; Cache *c; + Dram *d; Controller *ct; }; @@ -49,3 +50,41 @@ TEST_CASE_METHOD( // change me later CHECK(this->ct->get_pc() == 0); } + +TEST_CASE_METHOD(ControllerPipeFixture, "Add until exec", "[tmp]") +{ + signed int b; + std::vector<signed int> p; + InstrDTO *i; + + b = 0b1010100000000001001101; + p = {b}; + this->d->load(p); + + // dram + i = this->ct->advance(OK); + REQUIRE(i == nullptr); + // fetch + i = this->ct->advance(OK); + REQUIRE(i == nullptr); + // decode + i = this->ct->advance(OK); + REQUIRE(i == nullptr); + // exec + i = this->ct->advance(OK); + REQUIRE(i == nullptr); + // done + i = this->ct->advance(OK); + REQUIRE(i != nullptr); + + CHECK(i->get_time_of(FETCH) == 3); + CHECK(i->get_time_of(DCDE) == 4); + CHECK(i->get_time_of(EXEC) == 5); + CHECK(i->get_s1() == 42); + CHECK(i->get_s2() == 0); + CHECK(i->get_s3() == 42); + CHECK(i->get_mnemonic() == ADDI); + CHECK(i->get_instr_bits() == b); + + delete i; +} |