V5.2.2 The Shift That Lost a Bit

MediumDebug20 minap_soc v1.5 · recorded retire trace, model compare onReview the topic

A short arithmetic test ran with the model compare on, and the bench stopped it with four mismatch lines. Find the record where the chip and the model first parted, and say why they did.

This chip is a build under bring-up, with one fault in its core. The program does four steps of arithmetic and stores each result. It has no expected values of its own: only the model checks it. The bench compared every record with the model and stopped the run.

The assembly of the recorded run, after three instructions put in front of it (TB_STATUS = 2).
    li   s0, SYSCTL
    la   s1, out
    li   a0, 0x00000013
    li   a1, 0x00001000
step_add:
    add  a2, a0, a1
    sw   a2, 0(s1)
    li   a3, 4
step_sll4:
    sll  a4, a0, a3
    sw   a4, 4(s1)
    li   a3, 20
step_sll20:
    sll  a5, a0, a3
    sw   a5, 8(s1)
step_srl:
    srl  a6, a1, a3
    sw   a6, 12(s1)
    li   t1, 0x900D
    sw   t1, TB_STATUS(s0)
9:  j    9b
out: .word 0, 0, 0, 0

The bench printed four lines. Each names the cycle, the pc, the field that differs, the chip's value (rtl) and the model's.

The mismatch lines of the recorded run.
ISS mismatch cycle=26 pc=80000038 field=rd_wdata rtl=130 model=1300000
ISS mismatch cycle=29 pc=8000003c field=rs2_rdata rtl=130 model=1300000
ISS mismatch cycle=30 pc=80000040 field=rd_wdata rtl=100 model=0
ISS mismatch cycle=32 pc=80000044 field=rs2_rdata rtl=100 model=0

Name the first record where the chip and the model differ. Give its cycle, the field, its address (the instruction's pc) and its label, as the full specification explains. Then choose the cause.

Full specification

The table Retire Records lists every record the chip retired before the bench stopped it. Each row has its cycle, its pc, the instruction and what it changed. The label list of the form holds the program's labels. Answer with the label of the instruction, and its pc as the address.

a0 is 0x13 and a1 is 0x1000 throughout. The shift instructions take their amount from the low five bits of rs2, as the ISA says.

After the first mismatch the model holds other register values than the chip: later lines may follow from the first.

Diagnose the Failing Run

Recorded Console and Result

ISS mismatch cycle=26 pc=80000038 field=rd_wdata rtl=130 model=1300000
ISS mismatch cycle=29 pc=8000003c field=rs2_rdata rtl=130 model=1300000
ISS mismatch cycle=30 pc=80000040 field=rd_wdata rtl=100 model=0
ISS mismatch cycle=32 pc=80000044 field=rs2_rdata rtl=100 model=0
verdict=fail
reason=checker
status=00000002
cycles=35
retired=18
compares=18
mismatches=4
traps=0
interrupts=0
irq_software=0
irq_external=0

Retire Records

CyclePC (hex)InstructionArchitectural change
980000000lui t0, 0x10004t0 ← 0x10004000
1080000004addi t1, zero, 2t1 ← 0x00000002
1280000008sw t1, 32(t0)mem[0x10004020] ← 0x00000002
138000000clui s0, 0x10004s0 ← 0x10004000
1480000010auipc s1, 0x0s1 ← 0x80000010
1580000014addi s1, s1, 72s1 ← 0x80000058
1680000018addi a0, zero, 19a0 ← 0x00000013
178000001clui a1, 0x1a1 ← 0x00001000
1880000020add a2, a0, a1a2 ← 0x00001013
1980000024sw a2, 0(s1)mem[0x80000058] ← 0x00001013
2080000028addi a3, zero, 4a3 ← 0x00000004
218000002csll a4, a0, a3a4 ← 0x00000130
2480000030sw a4, 4(s1)mem[0x8000005c] ← 0x00000130
2580000034addi a3, zero, 20a3 ← 0x00000014
2680000038sll a5, a0, a3a5 ← 0x00000130
298000003csw a5, 8(s1)mem[0x80000060] ← 0x00000130
3080000040srl a6, a1, a3a6 ← 0x00000100
3280000044sw a6, 12(s1)mem[0x80000064] ← 0x00000100
Step 1 · The first bad cycle and signal
Step 2 · The cause

Given Files

Use the listing to identify the instruction in the recording.

defs.S
# defs.S: addresses and helpers of the smoke programs of ap_soc v1.5 (stage E4).
# check-soc-top.mjs puts this text in front of every program. Numbers: gen/ap_soc_regs.h.
.equ ROM,      0x00000000
.equ CLINT,    0x02000000
.equ PLIC,     0x0C000000
.equ UART,     0x10000000
.equ GPIO,     0x10001000
.equ TIMER,    0x10002000
.equ WDOG,     0x10003000
.equ SYSCTL,   0x10004000
.equ SPI,      0x10005000
.equ DMA,      0x10006000
.equ HOLE,     0x10007000
.equ PWRCTL,   0x10008000
.equ SRAM,     0x80000000
.equ TB_STATUS, 0x20
.equ TB_PUTC,   0x24
.equ TB_EVENT,  0x28
.equ TB_ARG,    0x2C