Expand description
ddr2_phy — a full custom hand-rolled DDR2 controller + PHY for the Nexys A7-100T’s on-board
Micron MT47H64M16 (1 Gb, x16, 8 banks, DDR2-800). This is Phase 1 of the DRAM-into-Compute
campaign: total ownership in the openXC7 flow (no vendor MIG), tied directly to the
dram_executor command engine (super::dram), so the SAME command stream that drives the
JEDEC-legal schedule also drives the deliberately-illegal ComputeDRAM cadences.
Built in gated, iverilog-verified sub-steps (each proven against a behavioral DDR2 model before the board): • 1a — command layer (THIS brick first): op field → DDR2 pins, single source of truth; clocking + I/O primitives (MMCM/PLL, SSTL18, ODDR/IDDR, IDELAY); • 1b — init / mode-register sequence; • 1c — closed-loop per-byte-lane read calibration; • 1d — full controller (ODT, refresh, power-down, bank-interleave, status); • 1e — memtest over the full 128 MiB (the Phase-1 gate).
The command layer maps the dram_executor op field (0=ACT 1=RD 2=WR 3=PRE 4=REFpb — see
super::dram::delta_encode) plus the init commands (NOP / DESELECT / LOAD-MODE) to the JEDEC
DDR2 command truth table on {CS#, RAS#, CAS#, WE#}. The Verilog ddr2_cmd_encoder is GENERATED
from ddr2_pins, so the netlist and the model can never drift.
Enums§
- Ddr2Cmd
- A DDR2 command (JEDEC truth table over {CS#, RAS#, CAS#, WE#}, with CKE held high).
- Init
Step - One step of the DDR2 power-up init sequence.
- ModeReg
- A DDR2 mode register, identified by its
BA[1:0]selector.
Constants§
- EMR1_
DLL_ ENABLE - EMR1 with the DLL ENABLED (A0 = 0), full drive, ODT off, AL = 0, OCD exit — the first EMR1.
- EMR1_
OCD_ DEFAULT - EMR1 OCD calibration DEFAULT (A9:A7 = 111).
- EMR1_
OCD_ EXIT - EMR1 OCD calibration EXIT (A9:A7 = 000), DLL still enabled.
Functions§
- ddr2_
init_ sequence - The JEDEC DDR2 power-up init sequence for this part, as data.
cke_low_cyclesis the ≥200 µs power-up hold expressed in controller cycles (a deployment parameter of the chosen clock). - ddr2_
pins - The
(cs_n, ras_n, cas_n, we_n)pin levels for a DDR2 command — the JEDEC DDR2 command truth table. This is the SINGLE SOURCE OF TRUTH the Verilog encoder is generated from. - emit_
ddr2_ bank_ model_ verilog - Emit
ddr2_bank_model— a behavioral DDR2 array that stores/returns data (CL read latency) AND enforces tRCD/tRAS/tRP/tWR, raisingmodel_erroron any violation (the round-trip checker). - emit_
ddr2_ cmd_ encoder_ testbench - A self-checking testbench for
ddr2_cmd_encoder: drives every op with issue = 0 and issue = 1 and asserts the pins equalddr2_pins(expectations GENERATED from the same truth table). PASS/FAIL. - emit_
ddr2_ command_ encoder_ verilog - Emit the combinational
ddr2_cmd_encoder— op field +issue→ DDR2 command pins. Whenissueis low the bus holds NOP (CS# low, RAS#/CAS#/WE# high). Thecasearms are GENERATED fromddr2_pins, so the netlist is by-construction consistent with the model/oracle. - emit_
ddr2_ controller_ testbench - Emit
tb_ddr2_ctrl— writesn_words(distinct bank/col addresses), reads them back, and asserts each read equals the written data with nomodel_error. The access pattern is generated here. - emit_
ddr2_ controller_ verilog - Emit
ddr2_ctrl— the request-driven DDR2 controller FSM (timings baked from the table). - emit_
ddr2_ init_ fsm_ verilog - Emit
ddr2_init_fsm— a ROM-driven power-up sequencer. The ROM is GENERATED fromddr2_init_sequence; the FSM drives{cke, cs_n, ras_n, cas_n, we_n, ba, a}per entry, waits its cycle count, advances, and latchesinit_done. (Behavioral iverilog validation lands with the controller-integration brick; this brick pins the ROM to the JEDEC spec.) - emit_
ddr2_ init_ testbench - A behavioral testbench for
ddr2_init_fsm: a bus monitor records each isolated real command (NOP/DESELECT skipped) the FSM issues during power-up, and asserts the recorded log equals the JEDEC command sequence (generated fromddr2_init_sequence) and thatinit_doneasserts. - emit_
transaction - Emit the controller’s per-request command sequence for one closed-page DDR2 access.
- executor_
op_ to_ cmd - Map a
dram_executorop field (0=ACT 1=RD 2=WR 3=PRE 4=REFpb) to its DDR2 command. ReturnsNonefor op codes outside the executor’s issued set. - init_
rom_ word - Pack an init step into the 44-bit
ddr2_init_fsmROM word{cke, cs_n, ras_n, cas_n, we_n, ba[1:0], a[12:0], wait[23:0]}— the SINGLE encoding shared by the emitter and the drift lock, with the command pins taken fromddr2_pins. - mr_
opcode - Encode the Mode Register (BA = 00) opcode from the timing table: burst length (A2:A0), sequential burst type (A3 = 0), CAS latency (A6:A4, == tRCD on the 5-5-5 grade), DLL reset (A8), and write recovery WR-1 (A11:A9).