diff options
author | bd <bdunahu@operationnull.com> | 2025-03-30 22:00:28 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-03-30 22:00:28 -0400 |
commit | 723d582d1108975caf071a76c1556a01fb0553d1 (patch) | |
tree | 331984395d884650278f680fc15390824d90c4af /tests | |
parent | 6a15f66bef28de9e1b982c3adda4d9b75c818852 (diff) |
Sanity check for pipeline up to exe
Diffstat (limited to 'tests')
-rw-r--r-- | tests/controller.cc | 47 | ||||
-rw-r--r-- | tests/ex.cc | 5 |
2 files changed, 45 insertions, 7 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; +} diff --git a/tests/ex.cc b/tests/ex.cc index 9def9fe..9543c66 100644 --- a/tests/ex.cc +++ b/tests/ex.cc @@ -476,8 +476,7 @@ TEST_CASE_METHOD(EXFixture, "SUBI within bounds", "[ex]") InstrDTO *i; m = SUBI; - s1 = 200, s2 = 0; - s3 = 131; + s1 = 200, s2 = 0, s3 = 131; i = execute_instr(s1, s2, s3, m); CHECK(i->get_s1() == 69); @@ -641,7 +640,7 @@ TEST_CASE_METHOD(EXFixture, "JRL", "[ex]") InstrDTO *i; m = JRL; - s1 = 100, s2 = -42027, s3; + s1 = 100, s2 = -42027, s3 = 0; this->ct->set_pc(42096); i = execute_instr(s1, s2, s3, m); |