Home / Projects / OpenHW on ALINX / CVE2 EP10 case
Case study · OpenHW on ALINX · Ep.10

CVE2 goes gigabit: RGMII receive/transmit and UDP echo, from 7% bad frames to zero

Nine episodes wired CVE2 to interrupts, buses, memory and boot; this one wires it to Ethernet. The board is an ALINX PI-AR035-F1-1 (XC7A35T + RTL8211F). Gigabit RGMII uses just fourteen wires: four data lanes, one control line and one clock, sampled on both edges. The hard part is never "can it transmit" — it is whether the 2 ns receive delay comes from the PHY or from the FPGA IDELAY, and it must be added exactly once. This episode takes the link from "only ~7% of received frames pass CRC" to 11,243 frames with zero errors.

Verified on hardware · 2026-11-24 CVE2 · 50 MHz · RV32IM RGMII · 1000M full duplex UDP 8080 echo 12 / 12
0
CRC errors across 11,243 received frames
8 / 8
Sequential echo rounds returning byte-identical payloads
LINK 1 · 1000M
Read from the on-board PHY status, not inferred on the host
3 fixes
Dual RX clock buffers, fixed IDELAY tap, calibration gating
−2.164 / +0.040 ns
WNS / WHS; violations confined to 5 RX input endpoints
7,809 LUT · 13.5 BRAM
37.54% LUT, 26.77% FF, 10 DSP
2,192,137 B
Final bitstream, sha256 594fd2e4…
Two caveats, stated up front. First, the WNS of −2.164 ns is not a physical violation: it lands only on the five rgmii_rxctl / rgmii_rxd[*] → IDDR.D endpoints, where the report computes DCD = 3.153 ns by counting the BUFIO insertion delay on top of the port-level create_clock; the same link runs 11,243 frames with zero CRC errors on the board. Second, the echo is a 1 Hz periodic repeater, not a per-packet responder: the vendor MAC sends the most recent payload once per second, so burst tests at high rates must show a low hit rate — that is the design, not a bug.

On-hardware results: three acceptance criteria

CriterionRequirementMeasured
1 · LinkLINK=1, SPEED=1000ETH_STATUS=00000046 LINK=1 SPEED=1000, PHY at address 0x01
2 · Frame integrityZero CRC errorsGMII_CRC_OK=11,249 / GMII_CRC_BAD=0, ETH_RX_FRAMES=11,243
3 · UDP echoByte-identical payloadSEQ_RESULT ok=8/8 rate=100.0% over 8 sequential rounds
ETH_STATUS=00000046 LINK=1 SPEED=1000 LED=00000008 ETH_RX_FRAMES=11243 TX_FRAMES=191 RX_BYTES=1237007 TX_BYTES=16342 GMII_CRC_OK=11249 GMII_CRC_BAD=0 --- echo acceptance, one tag per round, ARP refresh + 2.5 s wait --- SEQ-00 ECHO_OK ... SEQ-07 ECHO_OK SEQ_RESULT ok=8/8 rate=100.0%

Root cause: three broken details in the RX sampling path

The r63 symptom looked like a sampling-point offset: only ~7% of frames passed CRC. But sweeping all 32 IDELAY taps produced a flat line (6.4%–8.5%), and changing the CRC window made no difference — so it was never "the eye centre was wrong", it was the sampling clock itself. Comparing against the official 16_ethernet_test reference isolated three differences.

StageBroken (r60–r63)Official (restored in r64)
RXC bufferingSingle BUFG shared by IDDR and fabricBUFG for fabric plus BUFIO for the IDDR
IDELAYVAR_LOAD + firmware tap sweep 1~31FIXED, IDELAY_VALUE=13 (≈1.0 ns)
Calibration gatingGroup attribute only, RDY unconnectedRDY gates the MAC reset: delay_ready && link && speed==2'b10

They are coupled: the PHY strap already adds internal delay to RXC (RXDLY defaults pulled up), so the FPGA only needs to add about 1 ns once through IDELAY and feed the IDDR a clean BUFIO clock. Without the BUFIO, the IDDR is clocked through the BUFG, the insertion delays no longer match the data path, and no tap value helps.

The expensive lesson: never measure on a topology you already broke, then use that measurement to blame the hardware. Twelve iterations of a hand-written RX module, a 32-point tap table and a 7% pass rate all sat on top of a sampling chain that had been modified away from the reference.

Why "per-packet echo rate" cannot be measured here

The vendor mac_test state machine fires once every pack_total_len cycles (1 s), sending the most recent received payload with length udp_rec_data_length − 8. Three test styles therefore give three completely different numbers.

Test styleResultNote
Burst, 40 frames @ 20 ms0 / 40Frames are overwritten; the last one still waits for the next 1 s tick
Burst, 200 frames @ 50 ms2 / 200Same semantics, not packet loss
One tag per round + 2.5 s wait8 / 8ARP refresh each round; 2.5 s covers a full tick

That is why the criterion is written as "echo correctness" rather than "per-packet echo rate". A true per-packet responder requires reworking the MAC handshake; two attempts deadlocked the TX path and were rolled back, so they are not presented as results.

Reproducing it

# 1. build (Vivado 2025.2) vivado -mode batch -source tcl/build_ep10_r5.tcl # 2. program (hw_server 127.0.0.1:3121) vivado -mode batch -source tcl/program_r67.tcl # 3. board-side criteria (115200 8N1) stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb raw -echo timeout 40 cat /dev/ttyUSB0 > /tmp/uart.log # 4. host-side raw frames (root, AF_PACKET) sudo python3 scripts/r64_seq.py 8

Fixed host-side addressing: board MAC 00:0a:35:01:fe:c0, board IP 192.168.8.50, host 192.168.8.237, UDP 8080. Frames are hand-built to bypass kernel offload, which would otherwise rewrite checksums and invalidate the test.

Evidence bundle (18 files · 2.5 MB)

Bitstream, timing and utilization reports, build and programming logs, UART captures, RTL, XDC, Tcl, acceptance scripts, and a SHA256 manifest.

Related episodes Ep.9 · Flash boot Ep.11 · SCCB camera + HDMI bars

Subscribe to fpga.love

Daily Briefing · Weekly Digest · Monthly Deep Dive