third bug
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 71 KiB |
@@ -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();
|
||||||
|
|||||||
+101
-4
@@ -1536,19 +1536,116 @@ 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. -->
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user