diff --git a/Pasted image 20261007190107.png b/Pasted image 20261007190107.png new file mode 100644 index 0000000..da96cfc Binary files /dev/null and b/Pasted image 20261007190107.png differ diff --git a/src/verilog/tb/cpu_tb_top.sv b/src/verilog/tb/cpu_tb_top.sv index ade179f..020b522 100644 --- a/src/verilog/tb/cpu_tb_top.sv +++ b/src/verilog/tb/cpu_tb_top.sv @@ -670,6 +670,51 @@ module cpu_tb_top; }; run_directed("alu_carry_bit8", prog); + // test derived from bug hunt SEED=4444 + // hault prior to last sw + prog = '{ + asm_instr(.op(OP_SLL), .rd(4), .rs1(1), .rs2(5)), + asm_instr(.op(OP_SLL), .rd(0), .rs1(21), .rs2(2)), + asm_instr(.op(OP_ADD), .rd(31), .rs1(5), .rs2(7)), + asm_instr(.op(OP_LW), .rd(7), .rs1(5), .imm(2032)), + asm_instr(.op(OP_BEQ), .rs1(7), .rs2(3), .imm(8)), + asm_instr(.op(OP_SW), .rs1(31), .rs2(9), .imm(1644)), + asm_instr(.op(OP_BEQ), .rs1(8), .rs2(26), .imm(8)), + asm_instr(.op(OP_BEQ), .rs1(5), .rs2(3), .imm(4)), + EBREAK_WORD + }; + run_directed("hault_prior_to_sw", prog); + + prog = '{ + asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(1)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(0)), + asm_instr(.op(OP_LW), .rd(2), .rs1(0), .imm(0)), + asm_instr(.op(OP_BEQ), .rs1(2), .rs2(0), .imm(8)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(4)), + EBREAK_WORD + }; + run_directed("lw_use_beq", prog); + + prog = '{ + asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(1)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(0)), + asm_instr(.op(OP_LW), .rd(2), .rs1(0), .imm(0)), + asm_instr(.op(OP_ADDI), .rd(0), .rs1(0), .imm(0)), + asm_instr(.op(OP_BEQ), .rs1(2), .rs2(0), .imm(8)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(4)), + EBREAK_WORD + }; + run_directed("lw_nop_beq_control", prog); + + prog = '{ + asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(5)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(0)), + asm_instr(.op(OP_LW), .rd(2), .rs1(0), .imm(0)), + asm_instr(.op(OP_ADD), .rd(3), .rs1(2), .rs2(2)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(3), .imm(4)), + EBREAK_WORD + }; + run_directed("lw_use_alu", prog); // CHIP-LEVEL DIRECTED TESTS run_reset_while_running(); run_external_halt(); diff --git a/testplan_final.md b/testplan_final.md index 71e81d8..3985a8f 100644 --- a/testplan_final.md +++ b/testplan_final.md @@ -1536,21 +1536,118 @@ Include a screenshot showing the offending instruction and the first incorrect a ### Conclusion -**Trigger:** sw + beq +**Trigger:** imm in sw causes some type of bit mismatch, the addresses are all off by 0x100 bytes -**Expected behavior:** one single sw and beq is successful +**Expected behavior:** addr is computed correctly -**Observed behavior:** sw is counted twice, while the scoreboard only expects one store +**Observed behavior:** store goes to sum without the carry from bit 7 to bit 8 -**Behavioral characterization:** the cpu holds write enable high for more than one cycle, leading to two stores +**Behavioral characterization:** the ALU is computing the correct address, but somewhere the bit carry when using the store address is lost + + + +##### 4.3 Bug 3 - Early Halt + +| Field | Evidence | +| ------------------------ | ----------------------------------------------------- | +| Discovery command | `make bug_hunt SEED=random` | +| Numeric `SVSEED` | 4444 | +| Failing iteration | 0 | +| First failure message | CPU halted with 1 predicted store(s) still unobserved | +| Reproduction command | `make bug_hunt SEED=4444` | +| Reproduces consistently? | Yes | + +**Original failing program:** + +```systemverilog +prog = '{ + asm_instr(.op(OP_SLL), .rd(4), .rs1(1), .rs2(5)), + asm_instr(.op(OP_SLL), .rd(0), .rs1(21), .rs2(2)), + asm_instr(.op(OP_ADD), .rd(31), .rs1(5), .rs2(7)), + asm_instr(.op(OP_LW), .rd(7), .rs1(5), .imm(2032)), + asm_instr(.op(OP_BEQ), .rs1(7), .rs2(3), .imm(8)), + asm_instr(.op(OP_SW), .rs1(31), .rs2(9), .imm(1644)), + asm_instr(.op(OP_BEQ), .rs1(8), .rs2(26), .imm(8)), + asm_instr(.op(OP_BEQ), .rs1(5), .rs2(3), .imm(4)), + EBREAK_WORD +}; +run_directed("halt_prior_to_sw", prog); +``` + +### Expected vs. actual + +| Instruction / event | Expected | Actual | Cycle/time | +| ------------------- | ---------- | ------------------------- | ---------- | +| sw x1, 1004(x1) | 0x00000000 | 0x00000000 (stored twice) | | + +**First architectural divergence:** the CPU halts prior to the completion of the program + + +### Minimization + +**Minimized reproducer:** + +```systemverilog +prog = '{ + asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(1)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(0)), + asm_instr(.op(OP_LW), .rd(2), .rs1(0), .imm(0)), + asm_instr(.op(OP_BEQ), .rs1(2), .rs2(0), .imm(8)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(4)), + EBREAK_WORD +}; +run_directed("lw_use_beq", prog); + +prog = '{ + asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(1)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(0)), + asm_instr(.op(OP_LW), .rd(2), .rs1(0), .imm(0)), + asm_instr(.op(OP_ADDI), .rd(0), .rs1(0), .imm(0)), + asm_instr(.op(OP_BEQ), .rs1(2), .rs2(0), .imm(8)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(4)), + EBREAK_WORD +}; +run_directed("lw_nop_beq_control", prog); + +prog = '{ + asm_instr(.op(OP_ADDI), .rd(1), .rs1(0), .imm(5)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(1), .imm(0)), + asm_instr(.op(OP_LW), .rd(2), .rs1(0), .imm(0)), + asm_instr(.op(OP_ADD), .rd(3), .rs1(2), .rs2(2)), + asm_instr(.op(OP_SW), .rs1(0), .rs2(3), .imm(4)), + EBREAK_WORD +}; +run_directed("lw_use_alu", prog); +``` + +### Waveform evidence + +Include a screenshot showing the offending instruction and the first incorrect architectural result. +![[Pasted image 20261007190107.png]] + +### Conclusion + +**Trigger:** imm in sw causes some type of bit mismatch, the addresses are all off by 0x100 bytes + + + +**Expected behavior:** addr is computed correctly + + + +**Observed behavior:** store goes to sum without the carry from bit 7 to bit 8 + + + +**Behavioral characterization:** the ALU is computing the correct address, but somewhere the bit carry when using the store address is lost ### 5. Code coverage >98% for cpu_tb_top -![[Pasted image 20261006143238.png]] \ No newline at end of file +![[Pasted image 20261006143238.png]]