DDR3 memory for a TxHDL design, with a controller we did not write

#DDR3#FPGA#Vivado#Rust#TxHDL#auto

The Vreteno RISC-V processor originally executed out of 4 KiB of block RAM. In contrast, the Alinx AX7A200 FPGA board provides one gigabyte of external DDR3 SDRAM. Designing a custom DDR3 PHY and memory controller requires extensive calibration circuitry. Rather than rewriting this complex infrastructure, we integrated the open-source UberDDR3 controller into a TxHDL SoC design as a foreign module. This post describes foreign module integration, board simulation with Micron memory models, and synthesis status.

Foreign module instantiation

Prior to this work, all modules in a lowered TxHDL netlist originated from TxHDL source files. A complete DDR3 controller contains low-level FPGA primitives, I/O delay calibrators, and multi-phase clock generators written in Verilog. Reimplementing these vendor-specific blocks in a new language offers little benefit.

TxHDL now supports foreign module declarations. A TxHDL unit can declare its netlist representation as an instance of an external Verilog module, specifying parameter maps and port bindings. The lowering compiler instantiates the named module directly without regenerating its internal logic. During Rust software simulation, the unit evaluates a behavioral software model. For DDR3, the simulation model acts as a Wishbone memory with initial calibration latency delays.

DDR3 bidirectional data and strobe lines require dedicated pin controls. TxHDL introduced a Pad signal type for bidirectional I/O buffers. A Pad passes through the module hierarchy unchanged, generating top-level inout ports that connect directly to external package pins.

Integrating UberDDR3 over AXI

UberDDR3 is an open-source DDR3 memory controller featuring a pipelined Wishbone bus interface. The build system fetches UberDDR3 at a pinned commit under the GPL-3.0 license.

The memory access path consists of four pipeline stages:

  1. The core’s AXI interface routes through an address interconnect. The router maps memory addresses 0x4000_0000 through 0xBFFF_FFFF to the DDR3 controller.
  2. An AxiPer unit handles AXI protocol handshakes on the peripheral boundary.
  3. An AxiWb bridge translates single-beat AXI transactions into pipelined Wishbone requests. All driven signals are registered for timing closure.
  4. A lightweight Verilog wrapper bridges word sizes. UberDDR3 processes eight-word bursts natively. The wrapper narrows accesses to 32-bit words, passing target sub-word offsets over controller auxiliary channels.

Together, the bridge and foreign controller form a composite TxHDL unit called Ddr3Per, which plugs into system interconnects like any other peripheral.

Board top-level architecture

Foreign module support enables the entire board SoC to lower as a single composite TxHDL module. The unified design incorporates the RISC-V core, AXI protocol trackers, an address router, data memory, timers, an AXI-Lite UART, the DDR3 controller, and an interrupt controller. The lowering tool emits this entire hierarchy as a single Verilog module.

A handwritten top-level wrapper handles board-level clocking and resets:

  • A Phase-Locked Loop (PLL) generates four synchronized clock domains. It generates 100 MHz for core logic, 400 MHz for DDR3 memory, a phase-shifted 400 MHz clock (delayed by 90 degrees), and 200 MHz for I/O delay calibration.
  • Reset sequencing delays core startup until DDR3 calibration asserts ready.
  • Four status LEDs display core execution state, a heartbeat timer, memory calibration lock, and PLL lock status.

Full-board simulation

Board verification operates at two levels. First, a software test runs the board hierarchy using the behavioral Rust model. A test binary writes sixteen words across the address range and reads them back.

Second, a gate-level testbench simulates the complete board in the Vivado simulator. This environment instantiates the handwritten top module, the lowered Verilog SoC, the UberDDR3 controller, and two official Micron DDR3 simulation models:

  • The PLL achieves lock at 0.27 microseconds of simulated time.
  • Memory calibration finishes at 12.26 microseconds.
  • The RISC-V core completes memory read-write checks, transmits ddr3 ok over the serial port, and halts at 31.4 microseconds.

An automated terminal monitor captures UART output and verifies the test verdict. Bazel rules supervise simulator execution, ensuring simulation exit codes and test outputs gate CI passes.

Synthesis and timing closure

Vivado synthesizes and routes the complete design for the Alinx AX7A200 board, using pin constraints derived from board schematics. The design meets all timing constraints across all four clock domains, producing zero unconstrained endpoints and zero critical warnings. Resource utilization totals approximately 8,000 LUTs and 7,000 flip-flops.

Current status

Bitstream generation and full-board simulation succeed cleanly in CI. Physical board validation will run on hardware once test benches confirm serial loopbacks.

The board architecture and DDR3 peripheral are documented with full source code in the Vreteno chapter of the TxHDL documentation, with code in the repository.