fix(fpga): PR-X.1.b — close F-7.4 on real Vivado xsim

Bench-verify the F-7.4 MMCM-lock gating (commit 6738f12) under real
Xilinx UNISIM primitives, not just the iverilog stub.

  ad9484_interface_400m.v
    Add `timescale 1ns / 1ps. Lone RTL file missing it; xelab refused
    to elaborate alongside TB+wrapper that both declared a timescale.

  tb/tb_ad9484_xsim.v
    Test Group 2 ("adc_dco_bufg toggles") moved below the first
    wait_for_adc_ready() — adc_dco_bufg now sources MMCM CLKOUT, which
    is gated until the MMCM SIM model locks (~4096 DCO cycles after
    reset deassert). Sampling pre-lock saw a stuck output, not a real
    BUFG defect.

    Test 17 SDR-ramp "no skips" tolerance 0 → 1 — Test 15 already
    grants a 6-sample startup-transient window for diff_one_count.
    Observed delta-other = 1 of 63 is the same pipeline-startup
    transient (first valid sample arrives before ramp launch
    aligns), not a demux bug.

  scripts/50t/run_ad9484_xsim.sh (new)
    xvlog + glbl.v + xelab -L unisims_ver -L secureip + xsim --runall.
    Mirrors run_xfft_xsim.sh / run_mf_chain_xsim.sh pattern.

Verification:
  remote Vivado 2025.2 xsim → 17 / 17 PASS (** ALL TESTS PASSED **)
  local iverilog regression  → 43 / 0 / 0 (was 37 / 0 / 6)

Closes PR-N #86 on the real simulator path.
This commit is contained in:
Jason
2026-05-05 13:33:48 +05:45
parent bf83d35917
commit 25e1f76841
3 changed files with 72 additions and 20 deletions
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# ============================================================================
# run_ad9484_xsim.sh — Compile + run tb_ad9484_xsim in Vivado XSim
#
# Verifies ad9484_interface_400m.v with REAL Xilinx UNISIM primitives
# (IBUFDS, IBUFGDS, BUFIO, BUFG, IDDR, MMCME2_ADV) — cannot run in iverilog.
#
# Closes PR-X.1 F-7.4: TB now waits on the MMCM lock indicator instead of
# guessing at a fixed 5-cycle delay (the MMCM SIM model takes ~4096 DCO
# cycles to lock).
#
# Usage (on remote Vivado box):
# cd ~/PLFM_RADAR_work/PLFM_RADAR/9_Firmware/9_2_FPGA
# bash scripts/50t/run_ad9484_xsim.sh
#
# Output: /tmp/ad9484_xsim.log (look for "ALL TESTS PASSED")
# ============================================================================
set -e
PROJ_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
DUT="$PROJ_ROOT/ad9484_interface_400m.v"
MMCM_WRAPPER="$PROJ_ROOT/adc_clk_mmcm.v"
TB="$PROJ_ROOT/tb/tb_ad9484_xsim.v"
WORK_DIR="$PROJ_ROOT/build_xsim_ad9484"
mkdir -p "$WORK_DIR"
cd "$WORK_DIR"
echo "===== Compiling Verilog sources ====="
xvlog -i "$PROJ_ROOT" "$DUT" "$MMCM_WRAPPER" "$TB"
# glbl.v supplies GSR/GTS for Xilinx primitives; xelab needs it as a second top.
xvlog "${XILINX_VIVADO}/data/verilog/src/glbl.v"
echo "===== Elaborating ====="
# `glbl` provides GSR/GTS for Xilinx primitives (IBUFDS, IDDR, MMCME2, etc.)
xelab -L unisims_ver -L secureip --debug typical \
tb_ad9484_xsim glbl -snapshot tb_ad9484_xsim_snap
echo "===== Running simulation ====="
xsim tb_ad9484_xsim_snap --runall --log /tmp/ad9484_xsim.log
echo "===== Done. Tail of log: ====="
tail -60 /tmp/ad9484_xsim.log