# NOTE: On some systems, you may need: # export LD_PRELOAD=/usr/lib64/libtinfo.so.5 # before running this script. # xsim_run.tcl - Vivado xsim compilation and simulation script # # Compiles sha3_chain_top with all SHA3 dependencies plus testbench. # Run from the project root: ~/Dev/mlkem/ # # Dependencies: # sync_rtl/sha3/keccak_round.v (combinational Keccak round) # sync_rtl/sha3/keccak_core.v (24-round Keccak core) # sync_rtl/sha3/sha3_top.v (SHA3 G/H/J top wrapper) # sync_rtl/sha3_chain/sha3_chain_top.v (ML-KEM G function) # # Prerequisites: # source /opt/Xilinx/Vivado/2019.2/settings64.sh # # Usage: # xsim -runall xsim_run.tcl # vivado -mode batch -source xsim_run.tcl # ================================================================ # Configuration # ================================================================ set SHA3_DIR sync_rtl/sha3 set SHA3_CHAIN_DIR sync_rtl/sha3_chain set TB_DIR sync_rtl/sha3_chain/TB # ================================================================ # Step 1: Compile RTL sources (xvlog) # ================================================================ puts "=== Compiling SHA3 RTL sources ===" # Core Keccak module (combinational round) xvlog -sv --relax -i . sync_rtl/sha3/keccak_round.v # Keccak core (24-round sequential core) xvlog -sv --relax -i . sync_rtl/sha3/keccak_core.v # SHA3 top wrapper (G/H/J modes) xvlog -sv --relax -i . sync_rtl/sha3/sha3_top.v # sha3_chain_top (ML-KEM G function) xvlog -sv --relax -i . sync_rtl/sha3_chain/sha3_chain_top.v # ================================================================ # Step 2: Compile testbench # ================================================================ puts "=== Compiling testbench ===" xvlog -sv --relax sync_rtl/sha3_chain/TB/tb_sha3_chain_xsim.v # ================================================================ # Step 3: Elaborate snapshot (xelab) # ================================================================ puts "=== Elaborating snapshot ===" xelab tb_sha3_chain_xsim -s tb_sha3_chain_xsim --timescale 1ns/1ps # ================================================================ # Step 4: Run simulation # ================================================================ puts "=== Running sha3_chain test ===" xsim tb_sha3_chain_xsim -R puts "" puts "=== sha3_chain simulation complete ==="