feat(tb): add Vivado XSIM Verilog testbenches for all 10 sync modules

Add file-based vector testbenches ( + ) for:
- mod_add_sync, rng_sync, poly_arith_sync, comp_decomp_sync
- s_bram/sd_bram, sha3_chain_top
- ntt_core, poly_mul_sync
- sample_cbd_sync, sample_ntt_sync

Each module includes:
- tb_<module>_xsim.v: Vivado XSIM testbench
- gen_vectors.py: Python vector generator (stdlib only)
- vectors/<module>_input.hex: test input vectors
- xsim_run.tcl: compile + elaborate + simulate script
This commit is contained in:
2026-06-25 20:48:38 +08:00
parent ae5f0ca048
commit d4c3fc86fc
42 changed files with 7745 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
# xsim_run.tcl - Vivado xsim compilation and simulation script for rng_sync
#
# Compiles rng_sync RTL plus the file-based vector testbench and runs simulation.
# Run from the project root: ~/Dev/mlkem/
#
# Prerequisites:
# source /opt/Xilinx/Vivado/2019.2/settings64.sh
#
# Usage:
# vivado -mode batch -source sync_rtl/rng/TB/xsim_run.tcl
#
# # Or step-by-step:
# xvlog -sv sync_rtl/rng/rng_sync.v
# xvlog -sv sync_rtl/rng/TB/tb_rng_xsim.v
# xelab tb_rng_xsim -s tb_rng_xsim
# xsim tb_rng_xsim -R
# ================================================================
# Configuration
# ================================================================
set SRC_DIR sync_rtl/rng
set TB_DIR sync_rtl/rng/TB
# ================================================================
# Step 1: Compile all source files (xvlog)
# ================================================================
puts "=== Compiling RTL sources ==="
# rng_sync (self-contained, no external dependencies)
xvlog -sv ${SRC_DIR}/rng_sync.v
# ================================================================
# Step 2: Compile testbench
# ================================================================
puts "=== Compiling testbench ==="
# File-based vector testbench
xvlog -sv ${TB_DIR}/tb_rng_xsim.v
# ================================================================
# Step 3: Elaborate snapshot (xelab)
# ================================================================
puts "=== Elaborating snapshot ==="
xelab tb_rng_xsim -s tb_rng_xsim
# ================================================================
# Step 4: Run simulation
# ================================================================
puts "=== Running rng_sync file-based vector test ==="
xsim tb_rng_xsim -R
puts ""
puts "=== rng_sync simulation complete ==="