test(top): add xsim_run.tcl so run_tb.sh top runs KeyGen KAT 0..4

./run_tb.sh top now compiles the full KeyGen datapath + tb_mlkem_kg_katN
and runs all 5 NIST KAT cases (ek==pk 800B, dk==sk 1632B byte-exact).
Also registers 'top' in ./run_tb.sh --list.
This commit is contained in:
2026-06-28 02:29:58 +08:00
parent 42d3748ab6
commit 2f46c0790f

View File

@@ -0,0 +1,45 @@
# xsim_run.tcl - Vivado XSIM for mlkem_top ML-KEM-512 KeyGen.
#
# Compiles the full KeyGen datapath + all leaf modules, then runs the
# end-to-end NIST KAT testbench for count=0..4 (each verifies ek==KAT.pk
# 800B and dk==KAT.sk 1632B byte-exact).
#
# Run from project root:
# ./run_tb.sh top
# (or: vivado-style step-by-step with the commands below)
# ================================================================
# Step 1: Compile RTL sources (leaf modules + top)
# ================================================================
xvlog -sv --relax -i . sync_rtl/sha3/keccak_round.v
xvlog -sv --relax -i . sync_rtl/sha3/keccak_core.v
xvlog -sv --relax -i . sync_rtl/sha3/sha3_top.v
xvlog -sv --relax -i . sync_rtl/sample_ntt/sample_ntt_sync.v
xvlog -sv --relax -i . sync_rtl/sample_cbd/sample_cbd_sync.v
xvlog -sv --relax -i . sync_rtl/ntt/barrett_mul.v
xvlog -sv --relax -i . sync_rtl/ntt/zeta_rom.v
xvlog -sv --relax -i . sync_rtl/ntt/butterfly_unit.v
xvlog -sv --relax -i . sync_rtl/ntt/ntt_core.v
xvlog -sv --relax -i . sync_rtl/poly_mul/basecase_mul.v
xvlog -sv --relax -i . sync_rtl/poly_mul/poly_mul_zeta_rom.v
xvlog -sv --relax -i . sync_rtl/poly_mul/poly_mul_sync.v
xvlog -sv --relax -i . sync_rtl/top/mlkem_top.v
# ================================================================
# Step 2: Compile KAT testbench (parameterized by +CASE=n)
# ================================================================
xvlog -sv --relax sync_rtl/top/TB/tb_mlkem_kg_katN_xsim.v
# ================================================================
# Step 3: Elaborate snapshot
# ================================================================
xelab tb_mlkem_kg_katN_xsim -s mlkem_kg_kat --timescale 1ns/1ps
# ================================================================
# Step 4: Run all 5 KAT cases (count=0..4)
# ================================================================
xsim mlkem_kg_kat -R -testplusarg CASE=0
xsim mlkem_kg_kat -R -testplusarg CASE=1
xsim mlkem_kg_kat -R -testplusarg CASE=2
xsim mlkem_kg_kat -R -testplusarg CASE=3
xsim mlkem_kg_kat -R -testplusarg CASE=4