No. 37 / project of 147 on the ladder

RV32IM Zicsr/Zifencei closure

introduces — Writable mscratch and legal fence.i for the first passing CSR and instruction-fence extension batches

harden statelast run2026-05-02
cells27,157non-filler
slack8.74ns setup
area900 x 900 die, 191927 stdcell areaμm²
signoff
  • DRCPASS
  • LVSPASS
  • antennaPASS

P37 keeps the P36 RV32IM platform and closes the first two extension gaps from the compliance sweep: Zicsr and Zifencei.

Status: hardened. LibreLane run RUN_2026-05-02_22-49-46 produced a final GDS and passed Magic DRC, KLayout DRC, LVS, antenna, routing DRC, setup timing, hold timing, and max fanout in the recorded metrics. The flow’s max-slew and max-cap checkers passed, but the slow-corner (max_ss_100C_1v60) recorded 83 slew and 8 cap warnings on the new CSR datapath - a partial regression of the P36 DRV win.

The Result

Run it:

make -C projects/37_rv32im_zicsr_zifencei/test clean all

Result: PASS

checkresult
Build linked rv32im_zicsr runtime ELFPASS
UART-load compiled imagePASS
Execute C *, /, and % through RV32MPASS
Execute mulh, mulhsu, and mulhuPASS
Check divide-by-zero and overflow edge casesPASS
MMIO UART writes M, T, EPASS
MMIO timer interrupt visible to CPASS
External interrupt visible to CPASS
Halt with x5 = 1PASS

ACT4/Sail rv32i/I: PASS=39 FAIL=0 NOT RUN=0

ACT4/Sail rv32i/M: PASS=8 FAIL=0 NOT RUN=0

ACT4/Sail rv32i/Zicsr: PASS=6 FAIL=0 NOT RUN=0

ACT4/Sail rv32i/Zifencei: PASS=1 FAIL=0 NOT RUN=0

Full RISC-V compliance: PARTIAL

Harden Result

LibreLane flow: PASS

harden checkresult
Run directoryprojects/37_rv32im_zicsr_zifencei/librelane/runs/RUN_2026-05-02_22-49-46
Final GDSprojects/37_rv32im_zicsr_zifencei/librelane/runs/RUN_2026-05-02_22-49-46/final/gds/top.gds
Metricsprojects/37_rv32im_zicsr_zifencei/librelane/runs/RUN_2026-05-02_22-49-46/final/metrics.json
Magic DRCPASS (0 errors)
KLayout DRCPASS (0 errors)
LVSPASS (0 errors)
AntennaPASS (0 net violations, 0 pin violations)
Routing DRCPASS (0 errors)
Magic/KLayout XORPASS (0 differences)
Setup timingPASS (0 violations, worst setup slack 8.742 ns)
Hold timingPASS (0 violations, worst hold slack 0.105 ns)
Max slew (flow checker)PASS
Max cap (flow checker)PASS
Max fanoutPASS (0 violations against signoff limit 13)

The flow checkers passed, but the recorded slow-corner metrics show a partial DRV regression vs P36. max_ss_100C_1v60 came back with 83 max-slew and 8 max-cap warnings. Every other corner stayed at 0.

P35 -> P36 -> P37 backend comparison:

metricP35P36P37
Worst setup slack8.048 ns5.903 ns8.742 ns
Worst hold slack0.100 ns0.070 ns0.105 ns
Max slew vio (max_ss)13083
Max cap vio (max_ss)108
Max fanout vio000
Standard-cell area188652 um^2191659 um^2191927 um^2
Standard-cell count268832722327157

The new logic is small in cells but adds a writable mscratch register and new CSR-readout muxes that participate in the existing CSR datapath. That is where the new slow-corner slew/cap warnings live. The honest read is that the P36 DRV win was sensitive to the exact CSR datapath shape and recovered partially when that shape changed. Setup and hold both improved relative to P36, so timing is not the pressure point.

What Changed

P37 adds writable mscratch at CSR address 0x340. The existing CSR execution path already knew how to perform csrrw, csrrs, csrrc, and the immediate forms; it needed a writable architectural CSR that the official tests could use without tripping illegal-instruction handling.

P37 also makes fence.i legal. In this core there is no instruction cache and no hidden prefetch queue, so fence.i is a no-op for hardware state. The important part is that decode now recognizes it as a real instruction instead of treating it as illegal.

misa still reports RV32IM (0x40001100). That is intentional because Zicsr and Zifencei do not have their own single-letter misa bits.

Scope

instruction familystatus
RV32I base integer instructionsPASS in scoped ACT4/Sail rv32i/I
MUL, MULH, MULHSU, MULHUPASS in scoped ACT4/Sail rv32i/M
DIV, DIVU, REM, REMUPASS in scoped ACT4/Sail rv32i/M
csrrw, csrrs, csrrcPASS in scoped ACT4/Sail rv32i/Zicsr
csrrwi, csrrsi, csrrciPASS in scoped ACT4/Sail rv32i/Zicsr
fence.iPASS in scoped ACT4/Sail rv32i/Zifencei

Still unsupported or NOT RUN: atomics, compressed instructions, floating point, bitmanip, cache-block operations, supervisor mode, vectored mtvec, delegation CSRs, satp, PMP, an MMU, and official full compliance packaging.

What We Learned

The P36 failures were real but narrow. We did not need a new runtime, a new bus, or a larger memory system to pass the first CSR and instruction-fence extension batches. We needed mscratch and a deliberate fence.i answer.

That turns P37 into a clean architectural checkpoint: RV32I, RV32M, Zicsr, and Zifencei all pass the scoped ACT4/Sail batches we have wired into the repo. The next useful RISC-V work should expand the official-test surface rather than keep poking at the already-green I/M/CSR/fence lane.