fix(create_project): replace -cd with -tclbatch pre-simulation vector copy

Vivado 2019.2 xsim does not support -cd flag. Instead:
- Generate copy_vectors_pre.tcl that copies hex files
- Pass via -tclbatch for pre-simulation execution
-  can then find vectors relative to xsim work dir
This commit is contained in:
2026-06-27 02:19:22 +08:00
parent 9ef6d96117
commit 6721c3c0c1

View File

@@ -71,8 +71,21 @@ set_property include_dirs ${PROJECT_DIR} [current_fileset -simset]
set_property -name {xsim.simulate.runtime} -value {all} -objects [get_filesets sim_1]
set_property -name {xsim.elaborate.xelab.more_options} -value {--timescale 1ns/1ps} -objects [get_filesets sim_1]
# Set simulation working directory to project root (for $readmemh to find vectors/)
set_property -name {xsim.simulate.xsim.more_options} -value "-cd ${PROJECT_DIR}" -objects [get_filesets sim_1]
# Copy test vectors to simulation directory before run
# (Vivado GUI runs xsim in vivado_prj/mlkem.sim/sim_1/behav/xsim/)
# $readmemh looks relative to the xsim working directory
set pre_tcl [file join ${PROJECT_DIR} vivado_prj copy_vectors_pre.tcl]
set fp [open $pre_tcl w]
puts $fp "# Auto-generated: copy test vectors to xsim working directory"
puts $fp "file mkdir sync_rtl/top/TB/vectors"
puts $fp "file copy -force [file join ${PROJECT_DIR} sync_rtl top TB vectors mlkem_top_input.hex] sync_rtl/top/TB/vectors/"
puts $fp "file copy -force [file join ${PROJECT_DIR} sync_rtl top TB vectors mlkem_top_expected.hex] sync_rtl/top/TB/vectors/"
puts $fp "puts {Vectors copied successfully}"
close $fp
set_property -name {xsim.simulate.xsim.more_options} \
-value "-tclbatch $pre_tcl" \
-objects [get_filesets sim_1]
# Save project
puts "========================================"