summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-29 17:11:17 -0400
committerbd <bdunahu@operationnull.com>2025-03-29 17:11:17 -0400
commitd21a1a9caa1f1791343a5376121936e552b1124c (patch)
treedf28c01f6d01603e5408bc1b1b111a66adafbff7 /tests
parentac0ae7206491a42cdba70560b0db41cfc8c7f642 (diff)
Fetch stage properly holds objects until parent is ready
Diffstat (limited to 'tests')
-rw-r--r--tests/if.cc34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/if.cc b/tests/if.cc
index 3be3305..bb25afa 100644
--- a/tests/if.cc
+++ b/tests/if.cc
@@ -38,7 +38,7 @@ class IFPipeFixture
for (i = 0; i < this->m_delay + 1; ++i) {
r = this->ct->advance(instr, OK);
// check response
- CHECK(r == BLOCKED);
+ CHECK(r == STALLED);
}
this->fetch_cache(instr);
}
@@ -54,7 +54,7 @@ class IFPipeFixture
for (i = 0; i < this->c_delay; ++i) {
r = this->ct->advance(instr, OK);
// check response
- CHECK(r == WAIT);
+ CHECK(r == STALLED);
}
r = this->ct->advance(instr, OK);
// check response
@@ -98,3 +98,33 @@ TEST_CASE_METHOD(IFPipeFixture, "fetch returns two instuctions", "[if_pipe]")
CHECK(instr.get_time_of(FETCH) == expected_cycles);
REQUIRE(instr.get_instr_bits() == this->p[1]);
}
+
+TEST_CASE_METHOD(IFPipeFixture, "fetch waits with old instruction", "[if_pipe]")
+{
+ Response r;
+ InstrDTO instr;
+ int i, expected_cycles, fetch_cycles;
+
+ fetch_cycles = this->m_delay + this->c_delay + 2;
+ expected_cycles = this->m_delay + (this->c_delay * 2) + 1;
+
+ for (i = 0; i < this->m_delay + 1; ++i) {
+ r = this->ct->advance(instr, BLOCKED);
+ // check response
+ CHECK(r == STALLED);
+ }
+ for (i = 0; i < this->c_delay; ++i) {
+ r = this->ct->advance(instr, BLOCKED);
+ // check response
+ CHECK(r == STALLED);
+ }
+ for (i = 0; i < expected_cycles - fetch_cycles; ++i) {
+ r = this->ct->advance(instr, BLOCKED);
+ // check response
+ CHECK(r == OK);
+ }
+
+ r = this->ct->advance(instr, OK);
+ CHECK(instr.get_time_of(FETCH) == expected_cycles);
+ REQUIRE(instr.get_instr_bits() == this->p[0]);
+}