From 2f46c0790fe8263d3b262df7b66f8a497b425f40 Mon Sep 17 00:00:00 2001 From: FallenSigh Date: Sun, 28 Jun 2026 02:29:58 +0800 Subject: [PATCH] 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. --- sync_rtl/top/TB/xsim_run.tcl | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 sync_rtl/top/TB/xsim_run.tcl diff --git a/sync_rtl/top/TB/xsim_run.tcl b/sync_rtl/top/TB/xsim_run.tcl new file mode 100644 index 0000000..feade0e --- /dev/null +++ b/sync_rtl/top/TB/xsim_run.tcl @@ -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