From 6721c3c0c1765c1219c2c43d8890a6c2bd6f71e3 Mon Sep 17 00:00:00 2001 From: FallenSigh Date: Sat, 27 Jun 2026 02:19:22 +0800 Subject: [PATCH] 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 --- create_project.tcl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/create_project.tcl b/create_project.tcl index a57f886..c370839 100644 --- a/create_project.tcl +++ b/create_project.tcl @@ -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 "========================================"