fpga.love
中文 App
Home / Projects / CVE2 EP02 case
Verified case · OpenHW on ALINX · Episode 02

CVE2 exceptions, interrupts and CSR: six trap cases pass on PI-AR035-F1-1

Episode 01 only proved reset, UART TX and LED. Episode 02 brings the CVE2 trap and interrupt entries up for real: four CSR readbacks, three synchronous exceptions and three local interrupt sources, each printed as PASS on the UART.

Verified on hardware · 2026-11-20 CVE2 / RV32IM 50 MHz Vivado 2025.2 Episode 02 / 12

The point is not another blinking LED. It is to prove that CVE2's mtvec, mepc, mcause, mstatus, mie and a minimal CLINT close the loop on one board: exceptions enter, record and return; interrupts pend, fire and clear.

BoardALINX PI-AR035-F1-1Engineering board, not yet in the board catalogue; link will be added once listed
ChipAMD Artix-7 · XC7A35TChinese spec page & same-family boards → ProjectOpenHW CVE2 / CV32E20Upstream repository & commit →
Board
ALINX PI-AR035-F1-1
ISA
RV32IM (test firmware, no C)
Clock
50 MHz
Interrupt controller
Minimal CLINT @ 0x2000_0000
UART
115200 8N1
Upstream commit
d7f2156

1. Verification result

After JTAG programming, /dev/ttyUSB0 prints the complete test result. The last line is RESULT: PASS with no FAIL item:

CASE csr mscratch=5a5a1234 PASS
CASE csr mie=00000888 PASS
CASE csr mstatus.MIE=00000001 PASS
CASE csr mtvec=00000101 PASS
EP02 CVE2 TRAP/IRQ TEST
mtvec=00000100
CASE ecall mcause=0000000b mepc=00000704 PASS
CASE ebreak mcause=00000003 mepc=00000728 PASS
CASE illegal mcause=00000002 mepc=0000074c PASS
CASE timer count=00000001 mcause=80000007 PASS
CASE software count=00000001 mcause=80000003 PASS
CASE external count=00000001 mcause=8000000b PASS
counts exc=00000001 timer=00000001 sw=00000001 ext=00000001
RESULT: PASS

The four CSR checks run before the exception tests, so the CSR lines appear first and the banner follows. That is the firmware's real order, not a re-ordered transcript.

2. Test matrix

GroupTestExpectedObservedResult
CSRmscratch write 0x5a5a1234, read back0x5a5a12340x5a5a1234PASS
CSRmie write 0x888, read back0x8880x00000888PASS
CSRmstatus.MIE set, read back11PASS
CSRmtvec readbackbase 0x100, MODE=10x00000101PASS
Exceptionecallmcause=110x0000000bPASS
Exceptionebreak (32-bit)mcause=30x00000003PASS
ExceptionIllegal instruction 0x00000000mcause=20x00000002PASS
InterruptTimer IRQ 7mcause=0x800000070x80000007PASS
InterruptSoftware IRQ 3mcause=0x800000030x80000003PASS
InterruptExternal IRQ 11 (CLINT injected)mcause=0x8000000b0x8000000bPASS

The timer interval is mtime + 50000, about 1 ms at 50 MHz. Each interrupt count is 1, so each source fires once, clears its pending bit and does not retrigger.

3. Minimal CLINT and vector table

50 MHz oscillatorY18
→
CVE2 coreRV32IM / OBI
→
16 KiB instruction RAM0x0000_0000
16 KiB data RAM0x0000_0000
→
UART TX0x1000_0000 / L5
CLINT0x2000_0000

CVE2's mtvec is forced vectored (MODE=1). Exceptions enter at base; interrupts enter at base + irq_id*4. The firmware puts the table at 0x100:

EntryAddressPurpose
exception0x100ecall / ebreak / illegal
software IRQ 30x10cmsip injected
timer IRQ 70x11cmtime >= mtimecmp
external IRQ 110x12cext_pending injected

The CLINT implements only the registers needed for this test: mtime low/high, mtimecmp low/high, msip, an external pending bit and an IRQ status word. No full 64-bit timer rollover test and no real peripheral interrupt source.

4. Resources and timing

ItemValueUtilization
Slice LUTs3,29515.84%
Slice Registers2,5546.14%
Block RAM Tile816.00%
DSPs1112.22%
Bonded IOB41.60%
WNS / WHS2.340 ns / 0.132 nsTNS / THS = 0, failing endpoints 0

Versus episode 01, LUTs rise from 3,170 to 3,295 (+125) and registers from 2,397 to 2,554; BRAM and DSP are unchanged. Bitstream: top_cve2_ep02.bit, 2,192,137 bytes.

Vivado reports one Register as Latch (<0.01%). There is no explicit latch in the design, and timing and function both pass; the item is recorded for later clean-up.

5. Pitfalls

6. Reproduction

  1. Prepare Vivado 2025.2 and riscv-nuclei-elf-gcc (GCC 10.2).
  2. Build firmware: cd sw && make clean && make; confirm firmware.hex is updated.
  3. Confirm INIT_FILE in top_cve2_ep02.sv points at EP02's sw/firmware.hex.
  4. Synthesize and implement: vivado -mode batch -source build_ep02.tcl.
  5. Start the 2025.2 hw_server on 3122 and program: vivado -mode batch -source program_ep02.tcl.
  6. Open UART: stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb raw -echo; timeout 20 cat /dev/ttyUSB0.
cd sw && make clean && make
cd ..
/media/alinx/nvme4t/Xilinx/2025.2/Vivado/bin/vivado -mode batch -source build_ep02.tcl
/media/alinx/nvme4t/Xilinx/2025.2/Vivado/bin/vivado -mode batch -source program_ep02.tcl
stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb raw -echo
timeout 20 cat /dev/ttyUSB0

7. Project files

These files come directly from the verified project. The canonical CVE2 source remains the upstream repository.

This episode verifies exception entries, three local interrupt sources and four CSR readbacks. Not verified: nested interrupts/priority, multiple simultaneous sources, 64-bit mtime rollover, real peripheral interrupts, debug mode and UART RX.

8. Related

Subscribe to fpga.love

Daily Briefing · Weekly Digest · Monthly Deep Dive