Episode 05 moves CVE2 from “it boots” to “it is measurable”: instruction and data RAM are each expanded to 64 KiB, EEMBC CoreMark 2K is ported, and architectural mcycle/minstret provide cycle and retired-instruction counts. The same RTL is turned into two bitstreams, -O2 and -Os, and each is run on the board for CoreMark, CPI and four microbenchmarks.
Scope first. These numbers are valid only for “CVE2 + 64 KiB BRAM, no cache, no DDR, 50 MHz, GCC 10.2, rv32im”. Do not compare them directly with cores that have I/D caches, DDR or a higher clock. The CoreMark CRC fields match the official run, so this is the standard workload, not a modified loop.
Both bitstreams were downloaded over JTAG and captured from the UART. First the -O2 build:
ALINX AR035 CVE2 Performance EP05
VARIANT=O2 CLK=50000000 BUILD=Nov 20 2026 20:42:57
COUNTER_A lo=003864a2 hi=00000000
COUNTER_B lo=00492d89 hi=00000000
BENCH O2 CRC32 cycles=319508 inst=249876 sink=5e4e1995
BENCH O2 MEMCPY cycles=622677 inst=348277 sink=0007b000
BENCH O2 MATMUL16 cycles=56258 inst=31645 sink=08328000
BENCH O2 SIEVE cycles=103785 inst=65835 sink=00000234
BENCH OS CRC32 cycles=331798 inst=258068 sink=5e4e1995
BENCH OS MEMCPY cycles=696534 inst=417940 sink=0007b000
BENCH OS MATMUL16 cycles=61190 inst=36030 sink=08328000
BENCH OS SIEVE cycles=124426 inst=71638 sink=00000234
COREMARK_BEGIN variant=O2 iterations=50
CoreMark Size : 666
Total ticks : 23724157
Total time (secs): 0.474
Iterations/Sec : 105.377
Iterations : 50
Compiler version : GCC 10.2.0 (riscv-nuclei-elf)
Compiler flags : -O2 -march=rv32im -mabi=ilp32
Memory location : STATIC-64K
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0x0158
Correct operation validated. See README.md for run and reporting rules.
COREMARK_SUMMARY variant=O2 cycles_lo=25909314 cycles_hi=0 inst_lo=16589935 inst_hi=0 cpi_milli=1561 score_milli=96490
EP05 DONE variant=O2
The -Os run differs in the key fields:
VARIANT=Os CLK=50000000 BUILD=Nov 20 2026 20:42:58
Total ticks : 31085723
Total time (secs): 0.621
Iterations/Sec : 80.422
Compiler flags : -Os -march=rv32im -mabi=ilp32
COREMARK_SUMMARY variant=Os cycles_lo=33273071 cycles_hi=0 inst_lo=20469510 inst_hi=0 cpi_milli=1625 score_milli=75135
EP05 DONE variant=Os
A second download of the O2 build produced exactly the same Total ticks=23724157, Iterations/Sec=105.377 and the same cycle/instruction counts for all four microbenchmarks. The five CoreMark CRC fields (seedcrc, crclist, crcmatrix, crcstate, crcfinal) are identical in both builds.
| Metric | -O2 | -Os | Difference |
|---|---|---|---|
| CoreMark iterations | 50 | 50 | same |
| Total ticks (mcycle) | 23,724,157 | 31,085,723 | -Os +31.0% |
| Measured time | 0.474 s | 0.621 s | -Os +31.0% |
| CoreMark score | 105.377 iter/s | 80.422 iter/s | O2 is 1.310× Os |
| CoreMark/MHz | 2.108 | 1.608 | +31.0% |
| Whole-run CPI | 1.561 | 1.625 | -Os +4.1% |
| .text size | 20,448 B | 17,876 B | -Os 12.6% smaller |
| CRC validation | all match | all match | Correct operation validated |
The official CoreMark score uses Total ticks and Iterations/Sec. The “whole-run CPI” column also includes CoreMark calibration, setup and reporting, so it is not the same scope as the microbenchmark CPI. Both are kept to avoid presenting one number as the whole story.
One bench.c exports two symbol sets through BENCH_PREFIX, compiled at -O2 and -Os and linked into the same firmware. A single boot therefore compares both on the same core, same RAM and same temperature, removing run-to-run environment differences.
| Workload | -O2 cycles | -O2 inst | -O2 CPI | -Os cycles | -Os inst | -Os CPI | Cycle delta |
|---|---|---|---|---|---|---|---|
| CRC32 · 4,096 B | 319,508 | 249,876 | 1.279 | 331,833 | 258,089 | 1.286 | +3.9% |
| memcpy · 4,096 B ×16 | 622,677 | 348,277 | 1.788 | 696,569 | 417,962 | 1.667 | +11.9% |
| 16×16 matmul | 56,258 | 31,645 | 1.778 | 61,225 | 36,052 | 1.698 | +8.8% |
| sieve · 4,096 | 103,785 | 65,835 | 1.576 | 124,461 | 71,660 | 1.737 | +19.9% |
-Os is not uniformly worse in CPI. The -Os memcpy and matmul have lower CPI, but retire 20.0% and 13.9% more instructions, so they still take 11.9% and 8.8% more cycles. Sieve is the worst case: both CPI and instruction count rise, for +19.9% cycles. Code size and execution speed are independent curves; neither CPI alone nor .text size alone tells the story.
mcycle (CSR 0xB00) and minstret (CSR 0xB02), with high words at 0xB80/0xB82. Firmware reads high-low-high and retries if the low word wrapped, forming a 64-bit value and avoiding the ~85.9 s low-word wrap at 50 MHz.cycles / instret in 64-bit integer arithmetic. Microbenchmark cycles/inst come from a snapshot around one call; the CoreMark whole-run CPI includes calibration and printing.0c91314d, 2K performance run, MEM_STATIC, SEED_VOLATILE, ITERATIONS=50, HAS_FLOAT=0; the working set lives in a static block inside the 64 KiB data RAM.firmware_o2.hex to firmware_os.hex; build_ep05.tcl selects with EP05_VARIANT. Resource and timing reports are identical for both.COUNTER_A lo=003864a2 hi=00000000
COUNTER_B lo=00492d89 hi=00000000
delta = 0x00492d89 - 0x003864a2 = 1,117,927 cycles
delay loop of 100,000 iterations → ~11.18 cycles/iteration (loop overhead included)
These two lines are the boot-time counter check: between A and B firmware only runs delay(100000), and the cycle delta is 1,117,927. That proves mcycle is actually advancing at 50 MHz rather than returning a stuck register.
| Item | EP04 | EP05 | Change |
|---|---|---|---|
| Instruction / data RAM | 16 KiB + 16 KiB | 64 KiB + 64 KiB | 4× each |
| Slice LUTs | 4,103 | 4,266 | +163 |
| Slice Registers | 3,559 | 3,687 | +128 |
| Block RAM Tile | 8 | 32 | +24 (64.0% used) |
| DSPs | 11 | 11 | unchanged |
| Bonded IOB | 25 | 25 | unchanged |
| WNS / WHS | 1.285 / 0.052 ns | 1.239 / 0.053 ns | 0 failing endpoints |
XC7A35T has only 50 BRAM36 tiles. Two 64 KiB 32-bit RAMs consume 32 of them, 64% of the device. This is the largest resource cost of the episode and a constraint for later episodes: moving to DDR3 or larger working sets cannot keep relying on BRAM. Both bitstreams are 2,192,137 B. O2 SHA-256 571e1c2df4a6275755cb39e419b6a97f09004eacb3d335ad53f8b8bb52d73b88; Os SHA-256 689ff3e18f333f47117296ca84164a04b773ace2bf5ab5b918c81fd22d63cc1d.
rdcycle reads nothing on this core: CVE2 implements machine mcycle/mcycleh at 0xB00/0xB80, not the user aliases at 0xC00/0xC80. The first version printed CRC32 cycles=3988292384 — exactly the CRC polynomial 0xEDB88320 — and inst=0, and the 64-bit read loop could not form a trustworthy value. Switching to csrr machine CSRs restored monotonic, repeatable counts.--delete removed the firmware hex: a source sync with --delete wiped the generated firmware_o2.hex on the build machine. Vivado then reported could not open $readmem data file at synthesis. Now only sources are synced, generated files are kept, and make clean && make always runs before synthesis.phys_opt_design -hold_fix + route_design. Only the final post-route report counts: WHS 0.053 ns. Intermediate reports must not be used for sign-off.time_in_secs() returns whole seconds, so 0.474 s truncated to 0 and Iterations/Sec became 0. The port now reports milliseconds while keeping the raw ticks and CRC fields.$readmemh path for 64 KiB RAM: synthesis runs inside *_runs/synth_1, so a relative hex path is not found. The RTL uses an absolute path and the build script checks the file exists, preventing a “synthesis passed but RAM is all zero” run.riscv-nuclei-elf-gcc (GCC 10.2), JTAG and a USB UART cable.cd sw && make clean && make; confirm firmware_o2.hex and firmware_os.hex are both 16,384 words.EP05_VARIANT=o2 vivado -mode batch -source build_ep05.tcl; then Os with EP05_VARIANT=os.EP05_VARIANT=o2 vivado -mode batch -source program_ep05.tcl, then os.cd sw && make clean && make
cd ..
EP05_VARIANT=o2 /media/alinx/nvme4t/Xilinx/2025.2/Vivado/bin/vivado -mode batch -source build_ep05.tcl
EP05_VARIANT=os /media/alinx/nvme4t/Xilinx/2025.2/Vivado/bin/vivado -mode batch -source build_ep05.tcl
EP05_VARIANT=o2 /media/alinx/nvme4t/Xilinx/2025.2/Vivado/bin/vivado -mode batch -source program_ep05.tcl
python3 cap_serial.py 20 /tmp/ep05_o2.bin # start before programming
These files come directly from the verified project. CoreMark upstream source is included under the EEMBC licence; the canonical repositories are OpenHW and EEMBC.
Daily Briefing · Weekly Digest · Monthly Deep Dive