# 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