REPRODUCTION CASE · OpenHW on ALINX · EPISODE 07

DDR3 DMA: pattern, CRC-32 and 1.42 GB/s read bandwidth

Episode 07 turns the factory MIG native UI into a programmable DMA. The CPU only writes CSRs; the engine writes an address-derived 128-bit pattern, reads every beat back for comparison, then re-reads the range to compute CRC-32. 1 MiB, 16 MiB and 256 MiB all finish with zero errors, and two independent FPGA configurations produce byte-identical UART logs: 1,422 MB/s read, 733 MB/s write.

Verified on hardware · 2026-11-20 CVE2 / RV32IM MIG native UI · 128-bit @ 100 MHz DDR3 16-bit · 800 MT/s Episode 07 / 12

What this proves is that data really lands in DDR3 and comes back intact — not that MIG can be generated. At 256 MiB the engine checks 16,777,216 beats, reports err=0, and gets 0x3ac478a7 from both the data and the expected CRC. Two boots x two rounds of 1/16/256 MiB verify 1.07 GiB in total and end with EP07 RESULT: PASS.

BOARDALINX PI-AR035-F1-1Engineering board, not yet in the board selector; link will be added when listed
CHIPAMD Artix-7 · XC7A35TParameters and related boards → PROJECTOpenHW CVE2 / CV32E20Upstream repository and commit →
Read
1,422 MB/s · 88.9% of peak
Write
733 MB/s · 45.8% of peak
Sizes
1 MiB / 16 MiB / 256 MiB
Errors
0 · 17.89 M beats per round
CRC-32 @ 256 MiB
0x3ac478a7
Timing
WNS 0.194 / WHS 0.001 ns
Logic
LUT 9,333 / FF 8,865
BRAM
32 / 50 · 64.0%

1. Hardware result: three sizes, two boots, zero errors

Each boot runs two rounds; each round walks 1 MiB, 16 MiB and 256 MiB in order. This is the raw 256 MiB UART line, with no script-side post-processing:

EP07 VERSION=0x45503037 DDR_SIZE=268435456 UI_CLK=100000000 EP07 CALIB: PASS EP07 METRIC size=268435456 beats=16777216 wr_cycles=36593140 rd_cycles=18874495 crc_cycles=671088668 wr_MBps=733 rd_MBps=1422 crc_MBps=39 err=0 crc_data=0x3ac478a7 crc_exp=0x3ac478a7 EP07 RESULT: PASS
SizeBeatsWrite cyclesRead cyclesWrite MB/sRead MB/sCRC MB/sErrorsCRC-32
1 MiB65,536142,93073,8147331,4204000x79a0a3d5
16 MiB1,048,5762,287,0721,179,7237331,4223900x16774634
256 MiB16,777,21636,593,14018,874,4957331,4223900x3ac478a7
uart_ep07_run1.txt and uart_ep07_run2.txt are byte-identical, both md5 51949e1bbde8f1f413b5a40210a8a81b. This is not a single lucky boot: the same bit and firmware were reloaded after a full reconfiguration and produced the same text.

2. Architecture: the CPU touches only CSRs; the data path is all DMA

CVE2RV32IM · 50 MHz
→
CSR0x2001_0000 · 12 registers
→
ddr3_dma128-bit · native UI
→
MIG 7 Series4:1 · ui_clk 100 MHz
→
DDR3MT41J128M16 · 256 MiB

The factory design exposes a native app interface, not AXI4. There is no AXI interconnect and no AXI4-to-native adapter in this design, so this page deliberately does not call it an “AXI4 DMA”. The native UI is a 128-bit data path with separate command and data handshakes: app_addr, app_cmd, app_en, app_rdy, app_wdf_data, app_wdf_wren, app_wdf_rdy, app_rd_data, app_rd_data_valid.

The clocking is not “50 MHz straight into MIG”. The top level uses an MMCME2_BASE to multiply the board’s 50 MHz up to 200 MHz for sys_clk_i; the MIG 4:1 PHY then produces a 100 MHz ui_clk. Every crossing between the 50 MHz CPU domain and the 100 MHz UI domain goes through 2FF/3FF synchronizers. The final implementation also applies set_clock_groups -asynchronous; without it, a false 1.060 ns hold violation appears.

3. Three phases: write pattern → read/compare → CRC-32

Write pattern. The address starts at the base and advances by 16 B per beat. Each beat is generated as tag={4'hA, addr}, pattern={tag, ~tag, tag^0x55AA33CC, tag^0xF00F9696}. Because the pattern depends on the address, an address decode error, a bank swap or a stuck data lane shows up during readback; a constant pattern would not catch those.

Read and compare. The read path keeps up to 32 requests outstanding and compares every returned beat with the expected pattern. Any mismatch increments ERRORS and records the first failing address in FIRST_ERR. At 256 MiB all 16,777,216 beats are compared and ERRORS=0.

CRC-32. The engine reads the range again, splits each 128-bit beat into 16 bytes, and updates a reflected CRC-32 with polynomial 0xEDB88320, initial value and final XOR both 0xFFFFFFFF. This path issues one read at a time and computes CRC serially, hence only 39–40 MB/s. Its job is an independent second check, not CRC throughput.

RegisterOffsetFunction
CTRL0x00bit0 start toggle, bits[3:1] size, bit4 CRC enable
STATUS0x04calib / busy / done / fail / crc_ok / state
SIZE0x080x1000_0000, 256 MiB
WR / RD / CRC_CYCLES0x0c / 0x10 / 0x14ui_clk cycles per phase
BEATS / ERRORS / FIRST_ERR0x18 / 0x1c / 0x20Beats returned, errors, first failing address
CRC_DATA / CRC_EXPECTED0x24 / 0x28Measured and expected CRC-32
VERSION0x2c0x4550_3037 (“EP07”)

4. Bandwidth: 89% read, 46% write, and why

A 16-bit DDR3 at 400 MHz DDR has a theoretical peak of 1.6 GB/s (800 MT/s x 2 B). This design reaches 1,422 MB/s on reads, about 88.9%; 733 MB/s on writes, about 45.8%; and 39–40 MB/s on CRC, about 2.4%.

Reads are fast because addresses and commands can be issued back-to-back and data returns on app_rd_data_valid; 32 outstanding requests hide most of the latency. Writes are slower because this version deliberately keeps the factory self-test’s data one cycle, command the next sequence: every BL8 occupies two ui_clk cycles, which pins the ceiling near half of peak. Issuing data and command in the same cycle is the obvious next optimisation, but it is outside what this episode has verified.

Bandwidth is “useful bytes x 100 MHz / measured cycles”, with the denominator fixed at the 100 MHz ui_clk. The first firmware revision assumed 200 MHz and doubled every printed number; the formula was changed to bytes*100/cycles and the bitstream was rebuilt. The 733 / 1,422 figures on this page are the corrected values.

5. Resources, timing and the final bitstream

ItemResultNote
LUT9,333 / 20,800 · 44.87%MIG and DMA data path added over EP06’s 4,332
FF8,865 / 41,600 · 21.31%Outstanding read queue and CRC state machine
BRAM32 / 50 · 64.00%CVE2 instruction/data RAM plus FIFOs
DSP11 / 90 · 12.22%Used inside MIG
IOB73 / 250 · 29.20%48 DDR3 signals plus board peripherals
WNS / WHS0.194 / 0.001 nsTNS/THS 0, 25,668 endpoints, 0 failing
DRC0 error / 0 warningFinal implementation report

The final bitstream is 2,192,137 B, SHA-256 9a0ef674e4781a6518985d72490574381c74edd9eb3bc88eca13a4a83dda6ab5. The first final implementation reported a −1.060 ns hold violation on sys_clk → clk_pll_i with one failing endpoint. Applying asynchronous clock groups between sys_clk and clk_pll_i after synthesis, then rerunning opt / place / route / phys_opt, produced 0.194 / 0.001 / 0 failing.

WHS is only 0.001 ns: the hold margin is thin, but the current report is 0 failing and the build is releasable. Any device change, temperature corner or MIG reconfiguration must rerun implementation; these timing numbers do not carry over.

6. What went wrong

7. Reproduce

# Build host ssh alinx@192.168.8.237 cd /media/alinx/nvme4t/fpga-love/pi_ar035_f1_1_cve2_ep07 # 1) Synthesis + implementation + reports (final timing needs clock groups) vivado -mode batch -source build_ep07.tcl vivado -mode batch -source impl_cdc_ep07.tcl # 2) Firmware (rerun after any print/logic change; the bit references the HEX) cd sw && make && python3 bin2hex.py && cd .. # 3) Start capture first, then program python3 cap_serial.py /dev/ttyUSB1 115200 /tmp/ep07.log & vivado -mode batch -source program_ep07.tcl

The second independent check is a full power/reconfiguration cycle followed by another program_ep07.tcl run and a fresh UART capture. Compare the two logs directly with cmp; only byte-identical logs count as reproduced. Releasing the CPU without reconfiguring the FPGA is not a second independent boot.

8. Project files (32)

RTL, XDC, Tcl, firmware sources and prebuilt images, the final bitstream, three reports, two independent UART logs, build/program logs, MIG configuration and the DDR3 pin table are all below. Checksums are in SHA256SUMS.txt.

README.txtPackage overview: interface, registers, results, limits metrics/ep07_metrics.jsonMachine-readable metrics: 6 runs, timing, resources, SHA-256 rtl/top_cve2_ep07.svTop: CVE2, MMCM, MIG, DMA, CSR, UART rtl/ddr3_dma.svNative-UI write-pattern / read-compare / CRC-32 engine xdc/pi_ar035_f1_1_cve2_ep07.xdcBoard pins and asynchronous clock groups xdc/ddr3_mig.xdcMIG-generated DDR3 pins and I/O standards tcl/build_ep07.tclSynthesis + implementation + reports tcl/impl_cdc_ep07.tclFinal implementation after clock groups tcl/program_ep07.tclJTAG download of bit and ELF sw/main.cThree sizes x two rounds, CRC and bandwidth printing sw/start.SBSS clear, mtvec, 64-entry trap table sw/link.ldCode / data / stack layout sw/MakefileRISC-V GCC build and HEX generation sw/syscalls.cBare-metal newlib syscall stubs sw/bin2hex.pyBIN to 32-bit HEX sw/firmware.elfDownloadable ELF, 55,688 B sw/firmware.binFlat binary, 7,556 B sw/firmware.hexBRAM init, 17,001 B / 1,889 words sw/firmware.disDisassembly, 78,432 B sw/firmware.mapLinker map bit/top_cve2_ep07.bitFinal bitstream, 2,192,137 B reports/ep07_timing_final.rptWNS 0.194 / WHS 0.001 / 0 failing reports/ep07_util_final.rptLUT 9,333 / FF 8,865 / BRAM 32 / DSP 11 reports/ep07_drc_final.rptDRC 0 error / 0 warning logs/uart_ep07_run1.txtComplete UART log, first independent boot logs/uart_ep07_run2.txtSecond boot, byte-identical to run1 logs/build_ep07.logVivado build log logs/program_ep07_run1.logFirst programming log logs/program_ep07_run2.logSecond programming log SHA256SUMS.txtSHA-256 of every artifact mig/factory_mig.prjMIG project config (MT41J128M16XX-125) pins/ddr3_pins.csv48 DDR3 signals to package pin / IOSTANDARD

9. Related

This episode verifies a single CVE2 core plus a MIG native UI and a 128-bit DMA over linear 1/16/256 MiB ranges: pattern write, readback compare, CRC-32 and bandwidth. Not verified: AXI4 interconnect, scatter/gather, a CPU-visible DDR window, ECC, DDR3 margin/temperature corners, long soak, multiple concurrent masters, or efficiency comparisons against other controllers.

Subscribe to fpga.love

Daily Briefing · Weekly Digest · Monthly Deep Dive