OpenHW CVE2 on ALINX PI-AR035-F1-1 - Episode 05: CoreMark / CPI performance baseline ==================================================================================== What it does ------------ CVE2 (RV32IM, 50 MHz) gets 64 KiB instruction RAM and 64 KiB data RAM, and runs the EEMBC CoreMark 2K workload. Cycle and retired-instruction counts come from the architectural machine CSRs mcycle (0xB00) / minstret (0xB02), read as 64-bit high-low-high snapshots. Two bitstreams are built from the same RTL: one initialises BRAM with the -O2 firmware, the other with the -Os firmware. Each was downloaded over JTAG and captured from UART at 115200 8N1. Verified result (2026-11-20) ---------------------------- CoreMark 2K performance run, 50 iterations, STATIC-64K, HAS_FLOAT=0, GCC 10.2.0. -O2 -Os Total ticks 23,724,157 31,085,723 Total time 0.474 s 0.621 s Iterations/Sec 105.377 80.422 CoreMark/MHz 2.108 1.608 Whole-run CPI 1.561 1.625 .text 20,448 B 17,876 B seedcrc 0xe9f5 0xe9f5 crclist 0xe714 0xe714 crcmatrix 0x1fd7 0x1fd7 crcstate 0x8e3a 0x8e3a crcfinal 0x0158 0x0158 -O2 is 1.310x the -Os score (+31.0%). The official CRC check printed "Correct operation validated" for both builds. Microbenchmarks (same firmware, both optimisation levels): workload -O2 cycles/inst/CPI -Os cycles/inst/CPI CRC32 4 KiB 319,508 / 249,876 / 1.279 331,833 / 258,089 / 1.286 memcpy 4 KiB x16 622,677 / 348,277 / 1.788 696,569 / 417,962 / 1.667 16x16 matmul 56,258 / 31,645 / 1.778 61,225 / 36,052 / 1.698 sieve 4,096 103,785 / 65,835 / 1.576 124,461 / 71,660 / 1.737 Counters -------- COUNTER_A lo=003864a2 hi=00000000 COUNTER_B lo=00492d89 hi=00000000 delta = 1,117,927 cycles for delay(100000), i.e. about 11.18 cycles per loop. Resources / timing (identical for both bitstreams) -------------------------------------------------- LUT 4,266 (20.51%), FF 3,687 (8.86%), BRAM 32 (64.00%), DSP 11 (12.22%), IOB 25 (10.00%). WNS 1.239 ns / WHS 0.053 ns, 0 failing endpoints. Both bitstreams 2,192,137 B. O2 bitstream SHA-256 571e1c2df4a6275755cb39e419b6a97f09004eacb3d335ad53f8b8bb52d73b88 Os bitstream SHA-256 689ff3e18f333f47117296ca84164a04b773ace2bf5ab5b918c81fd22d63cc1d O2 firmware.bin SHA-256 ada1ed8713b5add2ed43822b11923a3aeb985f7bf834d80b1a8fd9821495c571 Os firmware.bin SHA-256 a3395b2a9e810f19bec1321fe43a8b5d1cd76cf6d31c4204add953bbac4d42d3 Both HEX images are 16,384 words / 65,536 B. Build ----- cd sw && make clean && make EP05_VARIANT=o2 vivado -mode batch -source build_ep05.tcl EP05_VARIANT=os vivado -mode batch -source build_ep05.tcl EP05_VARIANT=o2 vivado -mode batch -source program_ep05.tcl # hw_server TCP:127.0.0.1:3122 EP05_VARIANT=os vivado -mode batch -source program_ep05.tcl Start UART capture before programming and drain 0.8-1 s first. Pitfalls -------- 1. rdcycle / rdcycleh (CSR 0xC00 / 0xC80) are not implemented in CVE2. Early firmware printed CRC32 cycles=3988292384 (0xEDB88320, the CRC polynomial) and inst=0. Use csrr 0xb00/0xb80 (mcycle/mcycleh) and csrr 0xb02/0xb82 (minstret/minstreth) instead. Read high-low-high to avoid low-word wrap. 2. rsync --delete removed generated firmware_o2.hex on the build machine, so Vivado reported "could not open $readmem data file" at synthesis. Sync sources only, keep generated files, and run make clean && make before synth. 3. An implementation report taken before phys_opt_design -hold_fix is not valid for sign-off. Only the final post-route report counts (WHS 0.053 ns). 4. Stock CoreMark time_in_secs() returns whole seconds; 0.474 s truncated to 0 and Iterations/Sec became 0. The port reports milliseconds instead. 5. $readmemh runs inside *_runs/synth_1, so the RTL uses an absolute HEX path and the build script checks that the file exists. Notes / limits -------------- CoreMark was run with only 50 iterations (0.474 s / 0.621 s), below the official >=10 s recommendation, but repeated twice bit-for-bit. Results apply only to this CVE2 configuration: no I/D cache, no DDR, 64 KiB BRAM, 50 MHz, GCC 10.2, rv32im. No temperature/voltage corner or cross-core comparison is claimed. License ------- Upstream CVE2 is Apache-2.0; see LICENSE. CoreMark is distributed under the EEMBC CoreMark license, see sw/coremark/LICENSE.md.