fix(tb): fix run_tb.sh TCL variable extraction

Convert TCL 'set VAR path' to bash VAR=path before executing
xvlog/xelab/xsim commands extracted from xsim_run.tcl files.
This commit is contained in:
2026-06-25 20:57:30 +08:00
parent 79653ac3a5
commit db0a559826

View File

@@ -57,26 +57,27 @@ echo "========================================"
echo " Running testbench for: $MODULE" echo " Running testbench for: $MODULE"
echo "========================================" echo "========================================"
# Run xvlog + xelab + xsim commands directly (not via vivado batch) # Save TCL variables as bash variables, run commands with substitution
# Extract and execute xvlog, xelab, xsim lines from the TCL execute_tcl() {
grep -E '^xvlog ' "$TCL_FILE" | while read -r cmd; do local tcl_file="$1"
if [[ "$cmd" != \#* ]]; then local tmp_script="/tmp/run_tb_$$.sh"
echo " $cmd"
eval "$cmd" 2>&1 | grep -E "ERROR|WARNING|analyzing|Compiling|Built" || true
fi
done
grep -E '^xelab ' "$TCL_FILE" | while read -r cmd; do # Convert TCL 'set VAR value' to bash 'VAR=value'
if [[ "$cmd" != \#* ]]; then {
echo " $cmd" grep -E '^set [A-Z_]+ ' "$tcl_file" | while read -r _ var value; do
eval "$cmd" 2>&1 | grep -E "ERROR|WARNING|Compiling|Built" || true echo "${var}=${value}"
fi done
done
echo "" # Extract xvlog, xelab, xsim commands with bash variable expansion
echo "--- Running simulation ---" grep -E '^(xvlog|xelab|xsim) ' "$tcl_file" | while read -r cmd; do
grep -E '^xsim ' "$TCL_FILE" | while read -r cmd; do printf 'echo " %s"\n' "$cmd"
if [[ "$cmd" != \#* ]]; then printf '%s 2>&1\n' "$cmd"
eval "$cmd" 2>&1 done
fi } > "$tmp_script"
done
chmod +x "$tmp_script"
. "$tmp_script"
rm -f "$tmp_script"
}
execute_tcl "$TCL_FILE"