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.
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.
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| Size | Beats | Write cycles | Read cycles | Write MB/s | Read MB/s | CRC MB/s | Errors | CRC-32 |
|---|---|---|---|---|---|---|---|---|
| 1 MiB | 65,536 | 142,930 | 73,814 | 733 | 1,420 | 40 | 0 | 0x79a0a3d5 |
| 16 MiB | 1,048,576 | 2,287,072 | 1,179,723 | 733 | 1,422 | 39 | 0 | 0x16774634 |
| 256 MiB | 16,777,216 | 36,593,140 | 18,874,495 | 733 | 1,422 | 39 | 0 | 0x3ac478a7 |
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.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.
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.
| Register | Offset | Function |
|---|---|---|
| CTRL | 0x00 | bit0 start toggle, bits[3:1] size, bit4 CRC enable |
| STATUS | 0x04 | calib / busy / done / fail / crc_ok / state |
| SIZE | 0x08 | 0x1000_0000, 256 MiB |
| WR / RD / CRC_CYCLES | 0x0c / 0x10 / 0x14 | ui_clk cycles per phase |
| BEATS / ERRORS / FIRST_ERR | 0x18 / 0x1c / 0x20 | Beats returned, errors, first failing address |
| CRC_DATA / CRC_EXPECTED | 0x24 / 0x28 | Measured and expected CRC-32 |
| VERSION | 0x2c | 0x4550_3037 (“EP07”) |
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.
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.| Item | Result | Note |
|---|---|---|
| LUT | 9,333 / 20,800 · 44.87% | MIG and DMA data path added over EP06’s 4,332 |
| FF | 8,865 / 41,600 · 21.31% | Outstanding read queue and CRC state machine |
| BRAM | 32 / 50 · 64.00% | CVE2 instruction/data RAM plus FIFOs |
| DSP | 11 / 90 · 12.22% | Used inside MIG |
| IOB | 73 / 250 · 29.20% | 48 DDR3 signals plus board peripherals |
| WNS / WHS | 0.194 / 0.001 ns | TNS/THS 0, 25,668 endpoints, 0 failing |
| DRC | 0 error / 0 warning | Final 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.
ui_clk is 100 MHz, not 200 MHz. The 4:1 PHY divides the 400 MHz DDR clock down to a 100 MHz UI clock. The first bandwidth formula assumed 200 MHz and doubled every number.XML_INPUT_FILE is relative. The factory file says ../../../../factory_mig.prj. Placing the IP at proj/factory.srcs/sources_1/ip/ddr3/ddr3.xci and the PRJ at the project root makes four levels up land exactly at the root; otherwise generation escapes the project directory.clk_pll_i are timed as synchronous, the tool reports a 1.060 ns hold violation. set_clock_groups -asynchronous cleans it up.firmware.hex initialises the simple_ram through INIT_FILE; changing one print requires resynthesis and implementation, not just reloading the ELF.cap_serial.py first, then download.# 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.tclThe 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.
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.
Daily Briefing · Weekly Digest · Monthly Deep Dive