diff options
author | bd <bdunahu@operationnull.com> | 2025-04-17 20:52:55 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-17 20:52:55 -0400 |
commit | 496a08fbfafb8399c9addaf2501262fee228ffd6 (patch) | |
tree | 3e87aed03b50673c8e8c53dba98a45f32f979f48 /tests/id.cc | |
parent | 025cdd8e174fcf1a229355ecaf63861ac388fa63 (diff) | |
parent | 984ce6eef2e439955ff991f90c2b654be7c6c3f3 (diff) |
Merge remote-tracking branch 'origin/bdunahu' into dev-sid
Diffstat (limited to 'tests/id.cc')
-rw-r--r-- | tests/id.cc | 78 |
1 files changed, 5 insertions, 73 deletions
diff --git a/tests/id.cc b/tests/id.cc index 06eec0c..321c013 100644 --- a/tests/id.cc +++ b/tests/id.cc @@ -102,7 +102,7 @@ TEST_CASE_METHOD(IDFixture, "Parse arbitrary r-type # one", "[id]") signed int t; InstrDTO *i; - t = this->encode_R_type(0b0, 0b1, 0b10, 0b11, 0b0); + t = this->encode_R_type(0b101, 0b110, 0b111, 0b11, 0b0); i = this->decode_bits(t); CHECK(i->get_s1() == 0x00000000); // registers are empty @@ -134,7 +134,7 @@ TEST_CASE_METHOD(IDFixture, "Parse arbitrary i-type # one", "[id]") signed int t; InstrDTO *i; - t = this->encode_I_type(0xF, 0b1, 0b10, 0b0111, 0b1); + t = this->encode_I_type(0xF, 0b101, 0b110, 0b0111, 0b1); i = this->decode_bits(t); CHECK(i->get_s1() == 0x00000000); // registers are empty @@ -150,7 +150,7 @@ TEST_CASE_METHOD(IDFixture, "Parse arbitrary i-type # two", "[id]") signed int t; InstrDTO *i; - t = this->encode_I_type(0xCC, 0b010, 0b101, 0b1011, 0b1); + t = this->encode_I_type(0xCC, 0b101, 0b110, 0b1011, 0b1); i = this->decode_bits(t); CHECK(i->get_s1() == 0x00000000); // registers are empty @@ -184,8 +184,9 @@ TEST_CASE_METHOD(IDFixture, "Parse arbitrary j-type # two", "[id]") t = this->encode_J_type(0xBBCCF, 0b10101, 0b0011, 0b10); i = this->decode_bits(t); + t = 0xFFFBBCCF; CHECK(i->get_s1() == 0x00000000); // registers are empty - CHECK(i->get_s2() == 0xFFFBBCCF); + CHECK(i->get_s2() == t); CHECK(i->get_mnemonic() == JAL); delete i; @@ -205,72 +206,3 @@ TEST_CASE_METHOD(IDFixture, "read does not conflict with read", "[id]") this->d->read_guard(v); REQUIRE(v == 0b0); } - -TEST_CASE_METHOD(IDFixture, "write does not conflict with write", "[id]") -{ - signed int v; - - v = 0b1; - this->d->write_guard(v); - REQUIRE(v == 0b0); - - v = 0b1; - this->d->write_guard(v); - REQUIRE(v == 0b0); -} - -TEST_CASE_METHOD(IDFixture, "write does not conflict with read", "[id]") -{ - signed int v; - Response r; - - v = 0b1; - r = this->d->read_guard(v); - CHECK(v == 0b0); - REQUIRE(r == OK); - - v = 0b1; - this->d->write_guard(v); - REQUIRE(v == 0b0); -} - -TEST_CASE_METHOD(IDFixture, "read does conflict with write", "[id]") -{ - signed int v; - Response r; - - v = 0b1; - this->d->write_guard(v); - REQUIRE(v == 0b0); - - v = 0b1; - r = this->d->read_guard(v); - CHECK(v == 0b01); - REQUIRE(r == STALLED); -} - -TEST_CASE_METHOD(IDFixture, "stores indefinite conflicts", "[id]") -{ - signed int v, ov; - Response r; - - v = 0b1; - ov = v; - while (v < 0b110) { - this->d->write_guard(v); - REQUIRE(v == 0b0); - v = ++ov; - } - this->d->write_guard(v); - REQUIRE(v == 0b0); - - v = 0b110; - r = this->d->read_guard(v); - CHECK(v == 0b110); - REQUIRE(r == STALLED); - - v = 0b1; - r = this->d->read_guard(v); - CHECK(v == 0b1); - REQUIRE(r == STALLED); -} |