aboutsummaryrefslogtreecommitdiff
path: root/rv64cpu/tb/unit/tb_regfile.cc
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-03-18 19:48:35 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-03-18 19:48:35 +0800
commit1d4ed362e1caccc22aa4bd0dc2a9316e999f849a (patch)
tree3c8d3a0c5ed61ef0e0e54995b0ab95411c289215 /rv64cpu/tb/unit/tb_regfile.cc
parent5e18d160d16771252292ccebcb66ae4ba8cc9d64 (diff)
downloadrcc-project-1d4ed362e1caccc22aa4bd0dc2a9316e999f849a.tar.gz
rcc-project-1d4ed362e1caccc22aa4bd0dc2a9316e999f849a.tar.xz
Add fibonacci tests and fix bugs
Diffstat (limited to 'rv64cpu/tb/unit/tb_regfile.cc')
-rw-r--r--rv64cpu/tb/unit/tb_regfile.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/rv64cpu/tb/unit/tb_regfile.cc b/rv64cpu/tb/unit/tb_regfile.cc
index 3d08dd5..8e210ec 100644
--- a/rv64cpu/tb/unit/tb_regfile.cc
+++ b/rv64cpu/tb/unit/tb_regfile.cc
@@ -122,6 +122,7 @@ int main(int argc, char** argv) {
// Apply reset
dut->rst = 1;
+ dut->reg_write_en = 0; // Clear write enable from previous test
tick(dut);
dut->rst = 0;
@@ -139,21 +140,21 @@ int main(int argc, char** argv) {
std::cout << "\033[32m[PASS] Full memory reset verified\033[0m" << std::endl;
// Test 7: Read-After-Write (Same cycle collision check)
- // Combinational read should return the OLD value on the cycle WE is asserted
- // NOTE: Verilator handles combinational loops. Before the clock edge, it evaluates.
- dut->reg_write_en = 1;
+ // With internal bypass added, combinational read should return the NEW bypassed value immediately.
+ dut->reg_write_en = 0;
dut->rd_addr = 15;
- dut->rd_wdata = 0x55555555; // Pseudo
+ dut->rd_wdata = 0x55555555;
+ tick(dut); // Write 0x55555555 to x15 to set old value
// Setup for RAW
dut->reg_write_en = 1;
dut->rd_addr = 15;
dut->rd_wdata = 0x99999999;
- // Before tick, read should be 0 (from previous reset)
+ // Before tick, read should be the new bypassed value (0x99999999)
dut->rs1_addr = 15;
dut->eval();
- assert(dut->rs1_rdata == 0);
+ assert(dut->rs1_rdata == 0x99999999);
tick(dut); // Clock edge happens