-
Notifications
You must be signed in to change notification settings - Fork 86
/
startsg
executable file
·221 lines (190 loc) · 7.15 KB
/
startsg
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
###########################################################################
# #
# DO NOT PUT LOCAL CONFIGURATION INFORMATION IN THIS FILE! #
# #
###########################################################################
# #
# This "startsg" script is used to start the CASPER XSG/FPGA toolflow. #
# #
# Put local definitions in "startsg.local" in the same directory as this #
# file. At a minimum, the "startsg.local" file should define MATLAB_PATH #
# and XILINX_PATH environment variables that point to the base directory #
# of the respective installation directories. You should define the #
# PLATFORM variable (probably as lin64) in that file as well. You should #
# define the JASPER_BACKEND variable (probably as vivado) in that file as #
# well. #
# #
# #
# See the `startsg.local.example` file for an example. #
# #
###########################################################################
# Find canonical ("real") directory of this script
SCRIPT_DIR=$(dirname `readlink -e "${BASH_SOURCE[0]}"`)
#echo "SCRIPT_DIR=${SCRIPT_DIR}"
# Find basename of this script
SCRIPT_BASE=$(basename "${BASH_SOURCE[0]}")
#echo "SCRIPT_BASE=${SCRIPT_BASE}"
# If local defs file passed on command line, use it
if [ -n "${1}" ]
then
LOCALDEFS="${1}"
# First look for local defs in current directory
elif [ -f "./${SCRIPT_BASE}.local" ]
then
LOCALDEFS="./${SCRIPT_BASE}.local"
# Next, look in directory where symlink points
elif [ -f "${SCRIPT_DIR}/${SCRIPT_BASE}.local" ]
then
LOCALDEFS="${SCRIPT_DIR}/${SCRIPT_BASE}.local"
fi
# Errors need to return if this file is being sourced,
# but need to exit if this file is being executed.
on_error=return
if [ "$0" == "${BASH_SOURCE[0]}" ]
then
on_error=exit
fi
if [ -n "${LOCALDEFS}" -a -f "${LOCALDEFS}" ]
then
echo "Reading local definitions from '${LOCALDEFS}'"
source "${LOCALDEFS}"
else
# If local defs was passed on command line, this is an error. Otherwise it
# is just a warning because the user may be settng up their own environment.
if [ -n "${1}" ]
then
echo "ERROR: Local environment file '${LOCALDEFS}' not found."
$on_error 1
else
echo "WARNING: Local environment file not found."
fi
fi
# Verify that MATLAB_PATH and XILINX_PATH are reasonable
if ! [ -n "${MATLAB_PATH}" ]
then
echo "ERROR: MATLAB_PATH is not defined in the current environment."
$on_error 1
elif ! [ -d "${MATLAB_PATH}" -a -r "${MATLAB_PATH}" ]
then
echo "ERROR: MATLAB_PATH '${MATLAB_PATH}' is not a readable directory."
$on_error 1
fi
if ! [ -n "${COMPOSER_PATH}" ]
then
echo "ERROR: COMPOSER_PATH is not defined in the current environment."
$on_error 1
elif ! [ -d "${COMPOSER_PATH}" -a -r "${COMPOSER_PATH}" ]
then
echo "ERROR: COMPOSER_PATH '${COMPOSER_PATH}' is not a readable directory."
$on_error 1
fi
if ! [ -n "${XILINX_PATH}" ]
then
echo "ERROR: XILINX_PATH is not defined in the current environment."
$on_error 1
elif ! [ -d "${XILINX_PATH}" -a -r "${XILINX_PATH}" ]
then
echo "ERROR: XILINX_PATH '${XILINX_PATH}' is not a readable directory."
$on_error 1
fi
if ! [ -n "${PLATFORM}" ]
then
echo "WARNING: PLATFORM is not defined in the current environment, assuming 'lin64'."
export PLATFORM="lin64"
fi
if ! [ -n "${JASPER_BACKEND}" ]
then
echo "WARNING: JASPER_BACKEND is not defined in the current environment, assuming 'vivado'."
export JASPER_BACKEND="vivado"
fi
# If not yet defined, set MLIB_DEVEL_PATH based on canonicalized directory of
# this script. This is probably what you want, so just don't define it
# elsewhere.
if ! [ -n "${MLIB_DEVEL_PATH}" ]
then
export MLIB_DEVEL_PATH="${SCRIPT_DIR}"
fi
# Check that casper_library directory is writable
# (required by downconverter and bus libraries).
if ! [ -w "${MLIB_DEVEL_PATH}/casper_library" ]
then
echo "ERROR: Directory ${MLIB_DEVEL_PATH}/casper_library is not writable by you."
$on_error 1
fi
# Check for a custom python environment to load
if [ -n "$CASPER_PYTHON_VENV_ON_START" ]
then
echo "Found python on start variable"
if ! [ -d -a "${CASPER_PYTHON_VENV_ON_START}/bin/activate" ]
then
echo "ERROR: Python activation script cannot be found at ${CASPER_PYTHON_VENV_ON_START}/bin/activate"
$on_error 1
else
source ${CASPER_PYTHON_VENV_ON_START}/bin/activate
fi
fi
# If user has defined HDL_DSP_DEVEL_PATH, include relevant libraries
if [ -n "${HDL_DSP_DEVEL_PATH}" ]
then
echo "Using DSP HDL libraries from ${HDL_DSP_DEVEL_PATH}"
if [ -d "${HDL_DSP_DEVEL_PATH}/wrappers/simulink" ]
then
HDL_DSP_DEVEL_PATH=`readlink -e ${HDL_DSP_DEVEL_PATH}`
export DSP_HDL_SL_PATH="${HDL_DSP_DEVEL_PATH}/wrappers/simulink"
echo "Found DSP Simulink bindings at ${DSP_HDL_SL_PATH}"
else
echo "Error finding DSP HDL simulink libraries at ${HDL_DSP_DEVEL_PATH}/wrappers/simulink"
echo "Continuing without DSP HDL libraries"
unset DSP_HDL_SL_PATH
fi
fi
# Make sure that these variables are exported
export XILINX_PATH
export COMPOSER_PATH
export MATLAB_PATH
export PLATFORM
export MLIB_DEVEL_PATH
export JASPER_BACKEND
export HDL_DSP_DEVEL_PATH
# Show environment essentials
echo "Using MATLAB_PATH=${MATLAB_PATH}"
echo "Using XILINX_PATH=${XILINX_PATH}"
echo "Using COMPOSER_PATH=${COMPOSER_PATH}"
echo "Using PLATFORM=${PLATFORM}"
echo "Using MLIB_DEVEL_PATH=${MLIB_DEVEL_PATH}"
echo "Using JASPER_BACKEND=${JASPER_BACKEND}"
echo "Using XML2VHDL_PATH=${XML2VHDL_PATH}"
echo "Using LD_PRELOAD=${LD_PRELOAD}"
echo "Using DSP_HDL_DEVEL_PATH = ${HDL_DSP_DEVEL_PATH}"
echo "Using python: `which python`"
# Finish environment setup
export SYSGEN_SCRIPT="$MLIB_DEVEL_PATH/startsg"
export XPS_BASE_PATH="$MLIB_DEVEL_PATH/xps_base"
export MATLAB="$MATLAB_PATH"
export CASPER_BASE_PATH="$MLIB_DEVEL_PATH"
export HDL_ROOT="$CASPER_BASE_PATH/jasper_library/hdl_sources"
if [ -f "${COMPOSER_PATH}/settings64.sh" ]
then
source "${COMPOSER_PATH}/settings64.sh" > /dev/null
else
echo "ERROR: Xilink settings script '${COMPOSER_PATH}/settings64.sh' not found."
$on_error 1
fi
export PATH="${MATLAB_PATH}/bin:${PATH}"
# Set umask to allow group writes
umask 002
unset MYVIVADO
if [ "$0" == "${BASH_SOURCE[0]}" ]
then
# Save start-up directory (if defined, startup.m will cd there)
export CASPER_STARTUP_DIR=`pwd`
echo "Changing to directory: ${MLIB_DEVEL_PATH}"
# Change into the MLIB_DEVEL_PATH directory
# (so MATLAB will find our startup.m file).
cd "${MLIB_DEVEL_PATH}"
# Start sysgen in OPENGL graphics mode to prevent java errors
echo "Starting model_composer"
#"${COMPOSER_PATH}/bin/model_composer"
model_composer
fi