-
Notifications
You must be signed in to change notification settings - Fork 45
/
snap_env
executable file
·369 lines (332 loc) · 14.6 KB
/
snap_env
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
#!/bin/bash
############################################################################
############################################################################
##
## Copyright 2016,2017 International Business Machines
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE#2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions AND
## limitations under the License.
##
############################################################################
############################################################################
#
snapdir=$(dirname $(readlink -f "$BASH_SOURCE")) # path containing this script
PATH=$snapdir:$PATH
snap_env_sh=$snapdir/snap_env.sh
unset ACTION_ROOT
unset OCSE_ROOT
unset TIMING_LABLIMIT
unset ILA_SETUP_FILE
unset BASE_DCP_DIR
unset config_script
unset snap_env_info
TIMING_LABLIMIT_DEFAULT="-200"
while [[ $# -gt 0 ]]; do
case "$1" in
"config")
snap_env_info=y
shift
;;
"ignore_action_root")
ignore_action_root=y
shift
;;
*)
config_script=$1
shift
;;
esac
done
if [ -e "$config_script" ]; then
source $config_script
fi
if [ -e "$snap_env_sh" ]; then
source "$snap_env_sh"
else
touch "$snap_env_sh"
fi
unset SETUP_DONE
while [ -z "$SETUP_DONE" ]; do
SETUP_WARNING=""
SETUP_INFO=""
SETUP_EMPTY=""
echo " ___ ____ ______ ___ ___ ___ __";
echo " ___ / __ \/ ____/ ___ / | _____________ / /";
echo " ___ / / / / / ______ / /| |/ ___/ ___/ _ \/ / ";
echo "___ / /_/ / /___ /_____/ / ___ / /__/ /__/ __/ / ";
echo " ___ \____/\____/ ___ /_/ |_\___/\___/\___/_/ ";
echo "";
echo "======================================================="
echo "== OC-ACCEL ENVIRONMENT SETUP =="
echo "======================================================="
####### checking Xilinx Vivado
if [ ! -d "$XILINX_VIVADO" ]; then
SETUP_WARNING="$SETUP_WARNING\n### WARNING ### XILINX_VIVADO (set to \"$XILINX_VIVADO\") is not pointing to a directory:"
SETUP_WARNING="$SETUP_WARNING\n Please source settings64.sh from your Vivado installation"
fi
if [ -z "$XILINXD_LICENSE_FILE" ]; then
SETUP_WARNING="$SETUP_WARNING\n### WARNING ### XILINXD_LICENSE_FILE is not set:"
SETUP_WARNING="$SETUP_WARNING\n The following command needs to be executed before initiating hardware builds:"
SETUP_WARNING="$SETUP_WARNING\n export XILINXD_LICENSE_FILE=<pointer to Vivado license>"
fi
# printing Vivado version
if [ -z `which vivado 2> /dev/null` ]; then
SETUP_WARNING="$SETUP_WARNING\n### WARNING ### Path to vivado is not set:"
SETUP_WARNING="$SETUP_WARNING\n Please add to environment variable \$PATH"
else
echo "Path to vivado is set to: `which vivado`"
echo "Vivado version is set to: `vivado -version|head -n1`"
fi
VIVADO_RELEASE=`vivado -version | grep Vivado | cut -d '(' -f1 | tr -d "Vivado "`
VIVADO_MAJOR_RELEASE=`echo ${VIVADO_RELEASE} |cut -d '.' -f1`
VIVADO_MINOR_RELEASE=`echo ${VIVADO_RELEASE} |cut -d '.' -f2`
if [ "$VIVADO_MAJOR_RELEASE" -ge "2020" ]; then
if [ "$VIVADO_MINOR_RELEASE" -gt "1" ]; then
echo "HLS tool is set to: `vitis_hls -version |head -n1`"
else
#echo "Using Vivado HLS (could use Vitis HLS)"
echo "HLS tool is set to: `vivado_hls -version |head -n1`"
fi
else
echo "HLS tool is set to: `vivado_hls -version |head -n1`"
fi
####### checking path to OCSE (only if simulation is enabled)
# Note: SIMULATOR is defined via snap_config
if [ "$SIMULATOR" != "nosim" ]; then
echo "=====Simulation setup: Checking path to OCSE=========="
echo "OCSE_ROOT is set to: \"$OCSE_ROOT\""
RESP=`grep OCSE_ROOT $snap_env_sh`
if [ -z "$RESP" ]; then
tmp_pwd=`pwd`
abs_OCSE_PATH=$(cd $OCSE_PATH && echo $PWD)
cd $tmp_pwd
echo "export OCSE_ROOT=$abs_OCSE_PATH" >> $snap_env_sh
OCSE_ROOT=$abs_OCSE_PATH
fi
if [ -z "$OCSE_ROOT" ]; then
if [ ! -n "$HDL_UNIT_SIM" ]; then
SETUP_EMPTY="$SETUP_EMPTY\n OCSE_ROOT"
fi
elif [ ! -d "$OCSE_ROOT" ]; then
SETUP_WARNING="$SETUP_WARNING\n### WARNING ### Path to OCSE not set properly."
SETUP_WARNING="$SETUP_WARNING\n For simulation please clone OpenCAPI Simulation Environment (OCSE)"
SETUP_WARNING="$SETUP_WARNING\n from https://github.com/OpenCAPI/ocse"
SETUP_WARNING="$SETUP_WARNING\n and let \$OCSE_ROOT point to it."
SETUP_WARNING="$SETUP_WARNING\n Please set Simulator to 'nosim' if you do not intend to run simulation."
fi
fi
####### SNAP path variables
echo "=====ACTION ROOT setup================================="
unset AR
if [ -n "$HDL_EXAMPLE" ]; then
AR='${SNAP_ROOT}/actions/hdl_example'
elif [ -n "$HLS_MEMCOPY_512" ]; then
AR='${SNAP_ROOT}/actions/hls_memcopy_512'
elif [ -n "$HLS_MEMCOPY_1024" ]; then
AR='${SNAP_ROOT}/actions/hls_memcopy_1024'
elif [ -n "$HLS_HBM_MEMCOPY_1024" ]; then
AR='${SNAP_ROOT}/actions/hls_hbm_memcopy_1024'
elif [ -n "$HLS_SPONGE" ]; then
AR='${SNAP_ROOT}/actions/hls_sponge'
elif [ -n "$HLS_LATENCY_EVAL" ]; then
AR='${SNAP_ROOT}/actions/hls_latency_eval'
elif [ -n "$HLS_DECIMAL_MULT" ]; then
AR='${SNAP_ROOT}/actions/hls_decimal_mult'
elif [ -n "$HLS_LATENCY_EVAL_1024" ]; then
AR='${SNAP_ROOT}/actions/hls_latency_eval_1024'
elif [ -n "$HLS_RX100G" ]; then
AR='${SNAP_ROOT}/actions/hls_rx100G'
elif [ -n "$HLS_UDP" ]; then
AR='${SNAP_ROOT}/actions/hls_udp_512'
elif [ -n "$HLS_HELLOWORLD_512" ]; then
AR='${SNAP_ROOT}/actions/hls_helloworld_512'
elif [ -n "$HLS_HELLOWORLD_1024" ]; then
AR='${SNAP_ROOT}/actions/hls_helloworld_1024'
elif [ -n "$HLS_HELLOWORLD_PYTHON" ]; then
AR='${SNAP_ROOT}/actions/hls_helloworld_python'
elif [ -n "$HLS_IMAGE_FILTER" ]; then
AR='${SNAP_ROOT}/actions/hls_image_filter'
elif [ -n "$HDL_HELLOWORLD" ]; then
AR='${SNAP_ROOT}/actions/hdl_helloworld'
elif [ -n "$HDL_SINGLE_ENGINE" ]; then
AR='${SNAP_ROOT}/actions/hdl_single_engine'
elif [ -n "$HDL_MULTI_PROCESS" ]; then
AR='${SNAP_ROOT}/actions/hdl_multi_process'
elif [ -n "$HDL_UNIT_SIM" ]; then
AR='${SNAP_ROOT}/actions/hdl_unit_sim'
fi
if [ -z "$AR" ] && [ -n "$ACTION_ROOT" ]; then
AR=$ACTION_ROOT
echo "ACTION_ROOT is kept and set to: \"$ACTION_ROOT\""
SETUP_INFO="$SETUP_INFO\n### INFO ### Kept ACTION_ROOT from previous configuration."
else
echo "Setting ACTION_ROOT to: \"$AR\""
sed -i '/export[ ^]*ACTION_ROOT[ ^]*=/ d' $snap_env_sh
{ echo "export ACTION_ROOT=$AR"; cat $snap_env_sh; } > $snap_env_sh.tmp && mv $snap_env_sh.tmp $snap_env_sh
fi
if [ -z "$AR" ] && [ "$ignore_action_root" != "y" ]; then
SETUP_EMPTY="$SETUP_EMPTY\n ACTION_ROOT"
else
SNAP_ROOT=$snapdir
eval ACTION_ROOT=$AR
if [ "$ignore_action_root" == "y" ]; then
SETUP_INFO="$SETUP_INFO\n### INFO ### Skipping ACTION_ROOT check"
elif [ ! -d "$ACTION_ROOT" ] && ( ( [ -z `echo "x$ACTION_ROOT" | grep -i /HLS` ] && [ "${HLS_SUPPORT^^}" != "TRUE" ] ) || [ `basename "x$ACTION_ROOT"` != "vhdl" ] ); then
SETUP_WARNING="$SETUP_WARNING\n### WARNING ### Please make sure that ACTION_ROOT points to an existing directory."
fi
fi
####### settings for ILA Debug
# Note: ILA_DEBUG is defined via snap_config
if [ "$ILA_DEBUG" == "TRUE" ]; then
echo "=====ILA Debug setup==================================="
echo "ILA_SETUP_FILE is set to: \"$ILA_SETUP_FILE\""
RESP=`grep ILA_SETUP_FILE $snap_env_sh`
if [ -z "$RESP" ]; then
echo "export ILA_SETUP_FILE=" >> $snap_env_sh
fi
if [ -z "$ILA_SETUP_FILE" ]; then
#SETUP_EMPTY="$SETUP_EMPTY\n ILA_SETUP_FILE"
echo "You can still manually instantiate ila cores in logic design."
else
if [ `echo "$ILA_SETUP_FILE" | tr a-z A-Z` = "TRUE" ] && [ ! -e "$ILA_SETUP_FILE" ]; then
SETUP_WARNING="$SETUP_WARNING\n### WARNING ### ILA_DEBUG is set to $ILA_DEBUG but ILA_SETUP_FILE (set to \"$ILA_SETUP_FILE\") is not pointing to a file!"
fi
fi
fi
####### settings for Partial Reconfiguration flow
# Note: USE_PRFLOW is defined via snap_config
if [ "$USE_PRFLOW" == "TRUE" ]; then
echo "=====PR flow setup====================================="
RESP=`grep BASE_DCP_DIR $snap_env_sh`
if [ -z "$RESP" ]; then
echo "export BASE_DCP_DIR=${SNAP_ROOT}/hardware/BASE_DCP" >> $snap_env_sh
BASE_DCP_DIR=${SNAP_ROOT}/hardware/BASE_DCP
fi
echo "BASE_DCP_DIR is set to: \"$BASE_DCP_DIR\""
if [ -z "$BASE_DCP_DIR" ]; then
SETUP_EMPTY="$SETUP_EMPTY\n BASE_DCP_DIR"
fi
fi
####### checking TIMNG LIMITS setup
if [ -z "$TIMING_LABLIMIT" ]; then
TIMING_LABLIMIT="$TIMING_LABLIMIT_DEFAULT"
sed -i '/export[ ^]*TIMING_LABLIMIT[ ^]*=/ d' $snap_env_sh
{ echo "export TIMING_LABLIMIT=\"$TIMING_LABLIMIT_DEFAULT\""; cat $snap_env_sh; } > $snap_env_sh.tmp && mv $snap_env_sh.tmp $snap_env_sh
SETUP_INFO="$SETUP_INFO\n### INFO ### Timing limit for FPGA image build got set to default value $TIMING_LABLIMIT_DEFAULT"
fi
echo "=====Timing limit for FPGA image build in ps============"
echo "TIMING_LABLIMIT is set to: \"$TIMING_LABLIMIT\""
####### Cadence simulation setup:
# Note: SIMULATOR is defined via snap_config
if [ "$SIMULATOR" == "irun" ]; then
echo "=====Cadence simulation setup=========================="
if [ -z `which irun 2> /dev/null` ]; then
SETUP_WARNING="$SETUP_WARNING\n### WARNING ### Path to irun not set, Cadence simulation won't work"
else
echo "Path to irun is: \"`which irun`\""
# checking version
echo "irun version is: \"$(irun -version| cut -f 3)\""
if [ -z "$CDS_INST_DIR" ]; then
SETUP_WARNING="$SETUP_WARNING\n### WARNING ### SIMULATOR is $SIMULATOR but CDS_INST_DIR is not set. Simulation may not work."
fi
echo "CDS_INST_DIR is set to: \"$CDS_INST_DIR\""
fi
if [ -f "$IES_LIBS/cds.lib" ]; then
echo "cds.lib (IES_LIBS) found in: \"$IES_LIBS\""
else
SETUP_WARNING="$SETUP_WARNING\n### WARNING ### Cannot find cds.lib in IES_LIBS=$IES_LIBS. Cadence compilation won't work."
fi
if [ -z "$CDS_LIC_FILE" ] && [ -z "$LM_LICENSE_FILE" ]; then
SETUP_WARNING="$SETUP_WARNING\n### WARNING ### Cadence license not defined with CDS_LIC_FILE or LM_LICENSE_FILE. Simulation may not work."
else
if [ -n "$CDS_LIC_FILE" ]; then
echo "CDS_LIC_FILE is set to: \"$CDS_LIC_FILE\""
fi
if [ -n "$LM_LICENSE_FILE" ]; then
echo "LM_LICENSE_FILE is set to: \"$LM_LICENSE_FILE\""
fi
fi
fi
# Note: NVME_USED and DENALI_USED are defined via snap_config
if [ "$NVME_USED" == "TRUE" ] && [ "$DENALI_USED" == "TRUE" ]; then
echo "=====Denali setup======================================"
if [ -z "$DENALI" ]; then
SETUP_INFO="$SETUP_INFO\n### INFO ### Setting of NVME_USED=$NVME_USED and setting of DENALI_USED=$DENALI_USED but DENALI not set!"
else
echo "DENALI is set to: \"$DENALI\""
fi
fi
# Note: HBM is defined via snap_config
if [ "$BRAM_USED" == "TRUE" ]; then
#echo "=====HBM setup========================================="
SETUP_INFO="$SETUP_INFO\n### INFO ### Actual setting of HBM/DDR is NOT implementing real HBM/DDR!"
fi
if [ "$SIM_XSIM" == "y" ] && [ "$HBM_USED" == "TRUE" ] && [ "$BRAM_USED" == "FALSE" ]; then
SETUP_INFO="$SETUP_INFO\n### WARNING ### Simulating HBM with xsim is not supported by Xilinx, but you can build an image!"
SETUP_INFO="$SETUP_INFO\n To simulate a design with HBM, it is recommended to use xcelium simulator (license needed) or use BRAM / URAM option."
fi
# Note: ETHERNET_USED is defined via snap_config
if [ "$ETHERNET_USED" == "TRUE" ] && [ "$ETH_LOOP_BACK" == "TRUE" ]; then
#echo "=====Ethernet setup===================================="
SETUP_INFO="$SETUP_INFO\n### INFO ### Setting of ETHERNET is a loopback with NO MAC"
fi
if [ "$SIM_XSIM" == "y" ] && [ "$ETHERNET_USED" == "TRUE" ] && [ "$ETH_LOOP_BACK" != "TRUE" ]; then
#echo "=====Ethernet setup===================================="
SETUP_INFO="$SETUP_INFO\n### WARNING ### Simulating EMAC with xsim is not supported by Xilinx, but you can build an image!"
SETUP_INFO="$SETUP_INFO\n To simulate a design with EMAC, it is recommended to use xcelium simulator (license needed) or use the Ethernet Loop-back option."
fi
# Note: USERCODE requested
if [ "$ENABLE_USERCODE" == "y" ]; then
echo "USERCODE has been set to : ${USERCODE:0:8}";
fi
####### Print warning messages and create $snap_env_sh
echo -e "======================================================="
echo -e "\n=====Content of $(basename $snap_env_sh)============================"
cat $snap_env_sh
echo -e "======================================================="
RC=0
if [ -n "$SETUP_WARNING" ]; then
RC=1
echo -e "$SETUP_WARNING"
echo -e "\nPlease add the required environment settings to the file $(basename $snap_env_sh)"
echo -e "All of the variables above have to be filled with the correct values."
fi
if [ "$snap_env_info" == "y" ] && [ -n "$SETUP_INFO" ]; then
echo -e "$SETUP_INFO"
fi
if [ -n "$SETUP_EMPTY" ]; then
let "RC = 2 - $RC"
echo -e "\nThe following environment variables need to get defined:$SETUP_EMPTY"
echo -e "Please edit $(basename $snap_env_sh) and add the correct values"
fi
echo
#if no warning then display message
if [ -z "$SETUP_WARNING" ]; then
if [ "$USE_PRFLOW" == "TRUE" ]; then
echo " Suggested next step: to run a simulation, execute: make sim"
echo " or to build the FPGA binary, execute: make cloud_base or make cloud_action"
else
echo " Suggested next step: to run a simulation, execute: make sim"
echo " or to build the FPGA binary, execute: make image"
fi
fi
SETUP_DONE="1"
done
if [ -z "$snap_env_info" ]; then
if [ "$0" == "bash" ]; then
# return value in case that this file was sourced
return $RC
else
# otherwise set an exit state
exit $RC
fi
fi