Files
mlkem-sync/sync_rtl/sha3_chain/TB/xsim_run.tcl
FallenSigh 79653ac3a5 fix(tb): fix Vivado 2019.2 compatibility and add run_tb.sh
- Replace -include_dirs . with -i . (Vivado 2019.2 syntax)
- Add --timescale 1ns/1ps to all xelab commands
- Add LD_PRELOAD comment for ncurses compatibility
- Add run_tb.sh convenience script
  Usage: ./run_tb.sh mod_add
         ./run_tb.sh --list
- Update spec with Vivado 2019.2 compatibility notes
2026-06-25 20:53:47 +08:00

69 lines
2.2 KiB
Tcl

# 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 ${SHA3_DIR}/keccak_round.v
# Keccak core (24-round sequential core)
xvlog -sv ${SHA3_DIR}/keccak_core.v
# SHA3 top wrapper (G/H/J modes)
xvlog -sv ${SHA3_DIR}/sha3_top.v
# sha3_chain_top (ML-KEM G function)
xvlog -sv ${SHA3_CHAIN_DIR}/sha3_chain_top.v
# ================================================================
# Step 2: Compile testbench
# ================================================================
puts "=== Compiling testbench ==="
xvlog -sv ${TB_DIR}/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 ==="