diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/controller.cc | 85 | ||||
-rw-r--r-- | tests/ex.cc | 2 | ||||
-rw-r--r-- | tests/id.cc | 16 | ||||
-rw-r--r-- | tests/if.cc | 6 |
4 files changed, 12 insertions, 97 deletions
diff --git a/tests/controller.cc b/tests/controller.cc index a009a70..59f1d81 100644 --- a/tests/controller.cc +++ b/tests/controller.cc @@ -16,7 +16,7 @@ class ControllerPipeFixture ControllerPipeFixture() { this->d = new Dram(1); - this->c = new Cache(this->d, 0); + this->c = new Cache(this->d, 5, 0, 0); IF *f = new IF(nullptr); ID *d = new ID(f); @@ -107,11 +107,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); 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_time_of(MEM) == 6); - CHECK(i->get_time_of(WRITE) == 7); CHECK(i->get_s1() == 0x200); CHECK(i->get_s2() == 0x0); CHECK(i->get_s3() == 0x200); @@ -124,11 +119,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 4); - CHECK(i->get_time_of(DCDE) == 5); - CHECK(i->get_time_of(EXEC) == 6); - CHECK(i->get_time_of(MEM) == 7); - CHECK(i->get_time_of(WRITE) == 8); CHECK(i->get_s1() == 0x1); CHECK(i->get_s2() == 0x0); CHECK(i->get_s3() == 0x1); @@ -152,13 +142,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 5); - CHECK( - i->get_time_of(DCDE) == - 8); // the previous conflicting instruction wrote here! - CHECK(i->get_time_of(EXEC) == 9); - CHECK(i->get_time_of(MEM) == 14); // waited for fetch + 3 dram - CHECK(i->get_time_of(WRITE) == 15); CHECK(i->get_s1() == 0x200); CHECK(i->get_s2() == 0x1); CHECK(i->get_s3() == 0x0); @@ -173,11 +156,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 8); - CHECK(i->get_time_of(DCDE) == 9); - CHECK(i->get_time_of(EXEC) == 14); - CHECK(i->get_time_of(MEM) == 15); - CHECK(i->get_time_of(WRITE) == 16); CHECK(i->get_s1() == 0x2); CHECK(i->get_s2() == 0x1); // the previous value in the destination register CHECK(i->get_s3() == 0x2); @@ -194,13 +172,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 14); // fetching new line + mem - CHECK( - i->get_time_of(DCDE) == - 16); // the previous conflicting instruction wrote here! - CHECK(i->get_time_of(EXEC) == 17); - CHECK(i->get_time_of(MEM) == 18); - CHECK(i->get_time_of(WRITE) == 19); CHECK(i->get_s1() == 0x201); CHECK(i->get_s2() == 0x2); // address CHECK(i->get_s3() == 0x1); // offset @@ -215,11 +186,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 16); - CHECK(i->get_time_of(DCDE) == 17); - CHECK(i->get_time_of(EXEC) == 18); - CHECK(i->get_time_of(MEM) == 19); - CHECK(i->get_time_of(WRITE) == 20); CHECK(i->get_s1() == 0x0); CHECK(i->get_s2() == 0x2); CHECK(i->get_s3() == 0x0); @@ -232,11 +198,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 17); - CHECK(i->get_time_of(DCDE) == 18); - CHECK(i->get_time_of(EXEC) == 19); - CHECK(i->get_time_of(MEM) == 20); - CHECK(i->get_time_of(WRITE) == 21); CHECK(i->get_s1() == 0x1); CHECK(i->get_s2() == 0x0); CHECK(i->get_s3() == 0x1); @@ -251,11 +212,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 18); - CHECK(i->get_time_of(DCDE) == 19); - CHECK(i->get_time_of(EXEC) == 20); - CHECK(i->get_time_of(MEM) == 21); - CHECK(i->get_time_of(WRITE) == 22); CHECK(i->get_s1() == 0xE); CHECK(i->get_s2() == 0x7); CHECK(this->ct->get_gprs().at(2) == 0x200); @@ -283,13 +239,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK( - i->get_time_of(FETCH) == - 24); // 6 greater than last fetch (4 flush pipe, 2 dram) - CHECK(i->get_time_of(DCDE) == 25); - CHECK(i->get_time_of(EXEC) == 26); - CHECK(i->get_time_of(MEM) == 27); - CHECK(i->get_time_of(WRITE) == 28); CHECK(i->get_s1() == 0x1); CHECK(i->get_s2() == 0x0); CHECK(i->get_s3() == 0x0); @@ -305,13 +254,8 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 25); - CHECK(i->get_time_of(DCDE) == 26); - CHECK(i->get_time_of(EXEC) == 27); - CHECK(i->get_time_of(MEM) == 28); - CHECK(i->get_time_of(WRITE) == 29); CHECK(i->get_s1() == 0x8); - CHECK(i->get_s2() == 0b111111111111111111001); + CHECK(i->get_s2() == 0xfffffff9); CHECK(this->ct->get_gprs().at(2) == 0x200); CHECK(this->ct->get_gprs().at(5) == 0x0); CHECK(this->ct->get_gprs().at(6) == 0x1); @@ -335,11 +279,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); // it was already in cache - CHECK(i->get_time_of(FETCH) == 29); // clear out pipe (4) - CHECK(i->get_time_of(DCDE) == 30); - CHECK(i->get_time_of(EXEC) == 31); - CHECK(i->get_time_of(MEM) == 32); - CHECK(i->get_time_of(WRITE) == 33); CHECK(i->get_s1() == 0x200); CHECK(i->get_s2() == 0x0); CHECK(i->get_s3() == 0x0); @@ -360,11 +299,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 30); - CHECK(i->get_time_of(DCDE) == 33); - CHECK(i->get_time_of(EXEC) == 34); - CHECK(i->get_time_of(MEM) == 35); - CHECK(i->get_time_of(WRITE) == 36); CHECK(i->get_s1() == 0x1); CHECK(i->get_s2() == 0x0); CHECK(i->get_s3() == 0x0); @@ -380,11 +314,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 33); - CHECK(i->get_time_of(DCDE) == 34); - CHECK(i->get_time_of(EXEC) == 35); - CHECK(i->get_time_of(MEM) == 36); - CHECK(i->get_time_of(WRITE) == 37); CHECK(i->get_s1() == 0x2); CHECK(i->get_s2() == 0x0); CHECK(i->get_s3() == 0x1); @@ -405,11 +334,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 34); - CHECK(i->get_time_of(DCDE) == 37); - CHECK(i->get_time_of(EXEC) == 38); - CHECK(i->get_time_of(MEM) == 39); - CHECK(i->get_time_of(WRITE) == 40); CHECK(i->get_s1() == 0x3); CHECK(i->get_s2() == 0x2); CHECK(i->get_s3() == 0x1); @@ -429,11 +353,6 @@ TEST_CASE_METHOD(ControllerPipeFixture, "two num adder", "[full pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == 37); - CHECK(i->get_time_of(DCDE) == 40); - CHECK(i->get_time_of(EXEC) == 41); - CHECK(i->get_time_of(MEM) == 42); - CHECK(i->get_time_of(WRITE) == 43); CHECK(i->get_s1() == 0x200); CHECK(i->get_s2() == 0x3); CHECK(i->get_s3() == 0x0); diff --git a/tests/ex.cc b/tests/ex.cc index 13437f7..a493a21 100644 --- a/tests/ex.cc +++ b/tests/ex.cc @@ -13,7 +13,7 @@ class EXFixture EXFixture() { this->dr = new Dram(3); - this->c = new Cache(this->dr, 1); + this->c = new Cache(this->dr, 5, 0, 1); this->dum = new DUM(nullptr); this->e = new EX(dum); this->ct = new Controller(this->e, this->c, true); diff --git a/tests/id.cc b/tests/id.cc index 77a7cd9..06eec0c 100644 --- a/tests/id.cc +++ b/tests/id.cc @@ -13,7 +13,7 @@ class IDFixture IDFixture() { this->dr = new Dram(3); - this->c = new Cache(this->dr, 1); + this->c = new Cache(this->dr, 5, 0, 1); this->dum = new DUM(nullptr); this->d = new ID(dum); this->ct = new Controller(this->d, this->c, true); @@ -140,7 +140,7 @@ TEST_CASE_METHOD(IDFixture, "Parse arbitrary i-type # one", "[id]") CHECK(i->get_s1() == 0x00000000); // registers are empty CHECK(i->get_s2() == 0x00000000); CHECK(i->get_s3() == 0xF); - CHECK(i->get_mnemonic() == SFTLI); + CHECK(i->get_mnemonic() == ANDI); delete i; } @@ -152,11 +152,11 @@ TEST_CASE_METHOD(IDFixture, "Parse arbitrary i-type # two", "[id]") t = this->encode_I_type(0xCC, 0b010, 0b101, 0b1011, 0b1); i = this->decode_bits(t); - + CHECK(i->get_s1() == 0x00000000); // registers are empty CHECK(i->get_s2() == 0x00000000); CHECK(i->get_s3() == 0xCC); - CHECK(i->get_mnemonic() == STORE); + CHECK(i->get_mnemonic() == STOREV); delete i; } @@ -185,7 +185,7 @@ TEST_CASE_METHOD(IDFixture, "Parse arbitrary j-type # two", "[id]") i = this->decode_bits(t); CHECK(i->get_s1() == 0x00000000); // registers are empty - CHECK(i->get_s2() == 0xBBCCF); + CHECK(i->get_s2() == 0xFFFBBCCF); CHECK(i->get_mnemonic() == JAL); delete i; @@ -254,7 +254,7 @@ TEST_CASE_METHOD(IDFixture, "stores indefinite conflicts", "[id]") signed int v, ov; Response r; - v = 0b0; + v = 0b1; ov = v; while (v < 0b110) { this->d->write_guard(v); @@ -269,8 +269,8 @@ TEST_CASE_METHOD(IDFixture, "stores indefinite conflicts", "[id]") CHECK(v == 0b110); REQUIRE(r == STALLED); - v = 0b0; + v = 0b1; r = this->d->read_guard(v); - CHECK(v == 0b0); + CHECK(v == 0b1); REQUIRE(r == STALLED); } diff --git a/tests/if.cc b/tests/if.cc index d6c1bca..01070ef 100644 --- a/tests/if.cc +++ b/tests/if.cc @@ -17,7 +17,7 @@ class IFFixture p = {0xC000, 0xC001, 0xC002, 0xC003}; d->load(p); - this->c = new Cache(d, this->c_delay); + this->c = new Cache(d, 5, 0, this->c_delay); this->f = new IF(nullptr); this->ct = new Controller(this->f, this->c, true); } @@ -77,7 +77,6 @@ TEST_CASE_METHOD(IFFixture, "fetch returns single instuction", "[if_pipe]") expected_cycles = this->m_delay + this->c_delay + 2; i = this->fetch_through(); - CHECK(i->get_time_of(FETCH) == expected_cycles); REQUIRE(i->get_instr_bits() == this->p[0]); delete i; @@ -91,14 +90,12 @@ TEST_CASE_METHOD(IFFixture, "fetch returns two instuctions", "[if_pipe]") expected_cycles = this->m_delay + this->c_delay + 2; i = this->fetch_through(); - CHECK(i->get_time_of(FETCH) == expected_cycles); REQUIRE(i->get_instr_bits() == this->p[0]); delete i; expected_cycles += this->c_delay + 1; i = this->fetch_cache(); - CHECK(i->get_time_of(FETCH) == expected_cycles); REQUIRE(i->get_instr_bits() == this->p[1]); delete i; } @@ -129,7 +126,6 @@ TEST_CASE_METHOD(IFFixture, "fetch waits with old instruction", "[if_pipe]") i = this->ct->advance(WAIT); REQUIRE(i != nullptr); - CHECK(i->get_time_of(FETCH) == expected_cycles); REQUIRE(i->get_instr_bits() == this->p[0]); delete i; |