Repository navigation
Description
Environment Setup
Stock XLEN=32 configuration, F enabled, C disabled, IALIGN=32. Tested at commit b447578d9f3bb116d658c614cf3407153f0536da. Driver: rtlsim built DEBUG=1; tests are bare-metal ELFs.
f3_warl/21_mepc_warl/21_mepc_warl.Swritesmepcwith values whose low bits are non-zero and reads it back.f3_warl/22_mtvec_warl/22_mtvec_warl.Swritesmtvecwith MODE=3 and reads it back.
# rtlsim built DEBUG=1 from the commit above (XLEN=32, F on, C off).
P=f3_warl/21_mepc_warl # or f3_warl/22_mtvec_warl
spike -l --log-commits --isa=rv32imaf -m128 $P/ref.elf
./rtlsim $P/dut.elfBoth tests exited 0 on both engines.
Expected behavior
Per the RISC-V Privileged Specification, machine.adoc, Machine Exception Program Counter (mepc) register:
On implementations that support only IALIGN=32, the two low bits (
mepc[1:0]) are always zero.
Observed results
mepc test (21_mepc_warl). It first writes the aligned value 0x80001234 as a control (both engines read back 0x80001234), then writes 0x80001233 and reads it back:
| write | Vortex readback | Spike readback |
|---|---|---|
0x80001234 (control, aligned) |
0x80001234 |
0x80001234 |
0x80001233 |
0x80001233 (bits [1:0] retained) |
0x80001230 (bits [1:0] masked) |
DUT (logs/21_mepc_warl_dut.dbg.log, commit of csrr t4,mepc at PC 0x8000001c):
361: ...-commit commit: ... PC=0x8000001c, ex=SFU, rd=29, ... data={0x80001233, ...} <--
Spike (logs/<test>_ref.commits, same <test> as above):
core 0: 3 0x80000008 (0x34129373) x6 0x00000000 c833_mepc 0x80001234
core 0: 3 0x8000000c (0x341023f3) x7 0x80001234
core 0: 3 0x80000018 (0x34129e73) x28 0x80001234 c833_mepc 0x80001230
core 0: 3 0x8000001c (0x34102ef3) x29 0x80001230 <--
mtvec test (22_mtvec_warl). Its writes use MODE=3 (reserved; only 0 and 1 are defined). Spike legalises the BASE alignment and keeps MODE=1; Vortex retains the written value including the low MODE bits:
| write | Vortex readback | Spike readback |
|---|---|---|
0x80000100 (MODE=0) |
0x80000100 |
0x80000100 |
0x80000101 (MODE=1) |
0x80000101 |
0x80000101 |
0x80000103 (MODE=3) |
0x80000103 |
0x80000101 |
DUT (logs/22_mtvec_warl_dut.dbg.log, commits of the three csrr ...,mtvec reads):
289: ... PC=0x8000000c ... data={0x80000100, ...}
361: ... PC=0x8000001c ... data={0x80000101, ...}
433: ... PC=0x8000002c ... data={0x80000103, ...} <--
Spike (logs/<test>_ref.commits, same <test> as above):
core 0: 3 0x80000028 (0x30529f73) x30 0x80000101 c773_mtvec 0x80000101
core 0: 3 0x8000002c (0x30502ff3) x31 0x80000101 <--
The mtvec difference is a WARL question: Spike picks MODE=1 as one legal result, and the spec only requires MODE to be a legal value.
The trap CSRs appear to be stored as plain latches, with no WARL legalisation on the write path.
Affected revision and environment
- Tested at commit
b447578d9f3bb116d658c614cf3407153f0536da VERSION:VORTEX_VERSION=3.0,TOOLCHAIN_REV=v3.0.1- DUT simulator:
rtlsimDEBUG=1 - Reference: Spike
--isa=rv32imaf -m128 - OS: Linux 6.8.0-90-generic x86_64.
Minimal RTL reproducer
The log excerpts are from logs/21_mepc_warl_dut.dbg.log and logs/22_mtvec_warl_dut.dbg.log in the attachment.
Attachment: testcase.zip contains both .S sources, their prelinked dut.elf / ref.elf, link.ld, probe_macros.h, and the full DUT and Spike logs for both tests (logs/21_mepc_warl_*, logs/22_mtvec_warl_*).
The mepc masking is the less ambiguous of the two; the mtvec MODE legalisation may be a spec reading Vortex intends differently.
Activity
tinebp commentedon Nov 19, 2026
Fixed by #487.