forked from OpenCAPI/oc-accel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snap_env
executable file
·306 lines (275 loc) · 11.3 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
#!/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 PSL_DCP
unset ACTION_ROOT
unset OCSE_ROOT
unset TIMING_LABLIMIT
unset ILA_SETUP_FILE
unset DCP_ROOT
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 "== SNAP 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
####### checking path to OCSE (only if simulation is enabled)
# Note: SIMULATOR is defined via snap_config
if [ "$SIMULATOR" != "nosim" ]; then
echo "=====Simulation setup: Setting up OCSE version=========="
# if [ "$CAPI10" == "y" ]; then
# PSLVER="8"
# else
# PSLVER="9"
# fi
# echo "Setting PSLVER to: \"$PSLVER\""
# sed -i '/export[ ^]*PSLVER[ ^]*=/ d' $snap_env_sh
# sed -i '1s/^/export PSLVER='$PSLVER'\n/' $snap_env_sh
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/xxxxxxxxx/ocse FIXME!!"
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" ]; then
AR='${SNAP_ROOT}/actions/hls_memcopy'
elif [ -n "$HLS_MEMCOPY_1024" ]; then
AR='${SNAP_ROOT}/actions/hls_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_LATENCY_EVAL_1024" ]; then
AR='${SNAP_ROOT}/actions/hls_latency_eval_1024'
elif [ -n "$HLS_HELLOWORLD" ]; then
AR='${SNAP_ROOT}/actions/hls_helloworld'
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 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 DCP_ROOT $snap_env_sh`
if [ -z "$RESP" ]; then
echo "export DCP_ROOT=" >> $snap_env_sh
fi
echo "DCP_ROOT is set to: \"$DCP_ROOT\""
if [ -z "$DCP_ROOT" ]; then
SETUP_EMPTY="$SETUP_EMPTY\n DCP_ROOT"
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
####### 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
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