This repository has been archived by the owner on Jul 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvinterp.sh
executable file
·65 lines (51 loc) · 2.01 KB
/
vinterp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/zsh
#
# This is a script interpreter that executes the argument Tcl file in Vivado Tcl mode.
# Put the shebang "#!/path/to/vinterp.sh" at the top of your Tcl file to use it.
# If the Xilinx environment is not sourced, this script tries to source it by checking
# if it's installed at the default path (/opt/Xilinx) or else exits with an error.
# -- mbr 2021
#
# Working directory of the target script
WORK_DIR=$(dirname "$1")
# Relative path to the directory to store the log and journal in
LOG_DIR=${3:=/build}
# Make this script also work for Vitis HLS if you pass vitis_hls as the 2rd arg
PROGRAM_NAME=${2:=vivado}
# The default path of the Vivado installation
VIVADO_DIR_DEFAULT=/opt/Xilinx/Vivado
# The user specified Vivado installation path (may be undefined)
VIVADO_DIR_ARG=${4:=${VIVADO_DIR_DEFAULT}}
# Use a regex to find all Vivado installations (yyyy.v) and sort it in descending order
# so that the latest version appears as the first element in the array
VIVADO_DIR_GLOB=(${(Ofi)"$(find "$VIVADO_DIR_DEFAULT" -maxdepth 1 -type d | grep -P "\d{4}.\d{1}")"})
# Check if the input file exists and is a regular file
if [ ! -f "$1" ]; then
echo "No such file: \'$1\'"
exit 1
fi
# Check if Vivado environment is already sourced
if (( ! $+commands[vivado] )); then
# If no installation paths were found
if [ 0 -eq ${#VIVADO_DIR_GLOB[@]} ]; then
echo "Vivado not found, please source the environment first"
exit 2
fi
# Check if the settings file exists before we source it
SETTINGS="${VIVADO_DIR_GLOB[1]}/settings64.sh"
if [ ! -f "${SETTINGS}" ]; then
echo "File settings64.sh not found at expected path \'${SETTINGS}\'"
exit 3
fi
# We found the latest environment correctly, now source the settings file.
source "${SETTINGS}"
fi
# Change directory to the working directory
cd $WORK_DIR
# Launch vivado in Tcl mode with the log and journal outputting to LOG_DIR
$PROGRAM_NAME -mode tcl \
-source $1 \
-verbose \
-log $WORK_DIR/$LOG_DIR/$PROGRAM_NAME.log \
-journal $WORK_DIR/$LOG_DIR/$PROGRAM_NAME.jou
times