fpga: tools: Add utility to upgrade TCL-based BD

Original-commit: a99bed698576c1e0ab6c6c6aae68d5da75e6bd75
This commit is contained in:
Sam O'Brien
2022-08-25 13:55:30 -05:00
committed by skooNI
parent 81bb2ae28f
commit 187c81719b
3 changed files with 53 additions and 4 deletions
+11 -1
View File
@@ -40,12 +40,22 @@ function print_color {
# Functions # Functions
#------------------------------------------ #------------------------------------------
export VLINT_PLATFORM=$(uname -o)
function resolve_vlint_path {
if [[ $VLINT_PLATFORM = "Cygwin" ]]; then
echo $(cygpath -am $1)
else
echo $1
fi
}
# Replace any directories with the files they include # Replace any directories with the files they include
function replace_dirs_with_source { function replace_dirs_with_source {
for file in "$@" for file in "$@"
do do
if [ -d $file ]; then if [ -d $file ]; then
echo "$(realpath $(find $file -maxdepth 1 -type f)) " # Quotes so that resolve_vlint_path converts all paths
echo "$(resolve_vlint_path "$(realpath $(find $file -maxdepth 1 -type f))") "
else else
echo "$file " echo "$file "
fi fi
+37 -3
View File
@@ -267,7 +267,7 @@ if [[ $VSIM_PATH ]]; then
# Set MSIM_MODELSIM_INI to an empty string to use the modelsim.ini in the # Set MSIM_MODELSIM_INI to an empty string to use the modelsim.ini in the
# ModelSim installation folder. # ModelSim installation folder.
if [[ ! -v MSIM_MODELSIM_INI ]]; then if [[ ! -v MSIM_MODELSIM_INI ]]; then
export MODELSIM_INI=$SIM_COMPLIBDIR/modelsim.ini export MODELSIM_INI=$(resolve_viv_path $SIM_COMPLIBDIR/modelsim.ini)
fi fi
fi fi
@@ -276,9 +276,9 @@ function build_simlibs {
pushd $SIM_COMPLIBDIR pushd $SIM_COMPLIBDIR
CMD_PATH=`mktemp XXXXXXXX.vivado_simgen.tcl` CMD_PATH=`mktemp XXXXXXXX.vivado_simgen.tcl`
if [[ $MODELSIM_64BIT -eq 1 ]]; then if [[ $MODELSIM_64BIT -eq 1 ]]; then
echo "compile_simlib -force -simulator modelsim -family all -language all -library all -directory $SIM_COMPLIBDIR" > $CMD_PATH echo "compile_simlib -force -simulator modelsim -family all -language all -library all -directory ." > $CMD_PATH
else else
echo "compile_simlib -force -simulator modelsim -family all -language all -library all -32 -directory $SIM_COMPLIBDIR" > $CMD_PATH echo "compile_simlib -force -simulator modelsim -family all -language all -library all -32bit -directory ." > $CMD_PATH
fi fi
$VIVADO_EXEC -mode batch -source $(resolve_viv_path $CMD_PATH) -nolog -nojournal $VIVADO_EXEC -mode batch -source $(resolve_viv_path $CMD_PATH) -nolog -nojournal
rm -f $CMD_PATH rm -f $CMD_PATH
@@ -432,6 +432,40 @@ function viv_modify_tcl_bd {
fi fi
} }
function viv_upgrade_tcl_bd {
if [[ -z $1 || -z $2 || -z $3 ]]; then
echo "Upgrade an existing Vivado TCL-based Block Design instance to a newer Vivado version."
echo ""
echo "Usage: viv_modify_bd_tcl <TCL Path> <Product> <Old Vivado Path> <Mode>"
echo "- <TCL Path>: Path to the TCL source file."
echo "- <Product> : Product to generate IP for. Choose from: ${!PRODUCT_ID_MAP[@]}"
echo "- <Old Vivado Path> : Path to the old vivado executable, e.g. /opt/Xilinx/Vivado/2021.1/bin/vivado"
echo "- <Mode> : (optional) if gui, will launch old vivado in gui mode (defaults to batch)"
return 1
fi
viv_mode="batch"
if [ "$4" == "gui" ]; then
viv_mode="gui"
fi
src_path=$(readlink -f $1)
part_name=$(python3 $REPO_BASE_PATH/tools/scripts/viv_gen_part_id.py "${PRODUCT_ID_MAP[$2]}")
if [[ $? -ne 0 ]]; then
echo "ERROR: Invalid product name $2. Supported: ${!PRODUCT_ID_MAP[@]}"
return 1
fi
bd_ip_repo="${src_path%/top*}/lib/vivado_ipi"
if [[ -f $src_path ]]; then
$3 -mode $viv_mode -source $(resolve_viv_path $VIV_IP_UTILS) -nolog -nojournal -tclargs modify_bdtcl $part_name $(resolve_viv_path $src_path) $(resolve_viv_path $bd_ip_repo)
echo "INFO: Vivado BD loaded, writing updated source TCL..."
$VIVADO_EXEC -mode $viv_mode -source $(resolve_viv_path $VIV_IP_UTILS) -nolog -nojournal -tclargs write_bdtcl $part_name $(resolve_viv_path $src_path) upgrade
else
echo "ERROR: IP $src_path not found."
return 1
fi
}
function viv_ls_ip { function viv_ls_ip {
if [[ -z $1 ]]; then if [[ -z $1 ]]; then
echo "List the items in the Vivado IP catalog" echo "List the items in the Vivado IP catalog"
+5
View File
@@ -120,6 +120,11 @@ if { [string compare $cmd "create"] == 0 } {
# Open project and BD design # Open project and BD design
open_project "$tmp_bddir/tmp_bd.xpr" open_project "$tmp_bddir/tmp_bd.xpr"
open_bd_design [get_files "$src_rootname.bd"] open_bd_design [get_files "$src_rootname.bd"]
if [expr $argc > 3 && [string equal [lindex $argv 3] "upgrade"]] {
puts "INFO: Upgrading IP"
upgrade_ip [get_ips *]
validate_bd_design
}
# Rewrite TCL BD file # Rewrite TCL BD file
write_bd_tcl -make_local -force "$src_dir/$src_rootname.tcl" write_bd_tcl -make_local -force "$src_dir/$src_rootname.tcl"
puts "INFO: BD TCL source updated: $src_dir/$src_rootname.tcl" puts "INFO: BD TCL source updated: $src_dir/$src_rootname.tcl"