third bug

This commit is contained in:
2026-10-07 19:01:30 -04:00
parent 6780f10461
commit c53b63108c
3 changed files with 147 additions and 5 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

+45
View File
@@ -670,6 +670,51 @@ module cpu_tb_top;
}; };
run_directed("alu_carry_bit8", prog); 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 // CHIP-LEVEL DIRECTED TESTS
run_reset_while_running(); run_reset_while_running();
run_external_halt(); run_external_halt();
+102 -5
View File
@@ -1536,21 +1536,118 @@ Include a screenshot showing the offending instruction and the first incorrect a
### Conclusion ### Conclusion
**Trigger:** sw + beq **Trigger:** imm in sw causes some type of bit mismatch, the addresses are all off by 0x100 bytes
<!-- Smallest condition that causes the failure. --> <!-- Smallest condition that causes the failure. -->
**Expected behavior:** one single sw and beq is successful **Expected behavior:** addr is computed correctly
<!-- ISA-correct behavior. --> <!-- ISA-correct behavior. -->
**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
<!-- What the encrypted CPU does instead. --> <!-- What the encrypted CPU does instead. -->
**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
<!-- One precise sentence. Do not speculate about hidden RTL. -->
##### 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
<!-- State the first register, memory, or control-flow result that becomes incorrect. -->
### 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
<!-- Smallest condition that causes the failure. -->
**Expected behavior:** addr is computed correctly
<!-- ISA-correct behavior. -->
**Observed behavior:** store goes to sum without the carry from bit 7 to bit 8
<!-- What the encrypted CPU does instead. -->
**Behavioral characterization:** the ALU is computing the correct address, but somewhere the bit carry when using the store address is lost
<!-- One precise sentence. Do not speculate about hidden RTL. --> <!-- One precise sentence. Do not speculate about hidden RTL. -->
### 5. Code coverage >98% for cpu_tb_top ### 5. Code coverage >98% for cpu_tb_top
![[Pasted image 20261006143238.png]] ![[Pasted image 20261006143238.png]]