forked from open-power/snap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnap_config
More file actions
executable file
·175 lines (153 loc) · 5.23 KB
/
snap_config
File metadata and controls
executable file
·175 lines (153 loc) · 5.23 KB
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
#!/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
snap_config=$snapdir/.snap_config
snap_config_sh=$snapdir/.snap_config.sh
snap_config_cflags=$snapdir/.snap_config.cflags
if [ -f "$1" ]; then
echo "$0: Sourcing $1 ..."
source $1
fi
unset SETUP_DONE
while [ -z "$SETUP_DONE" ]; do
SNAP_CFG=""
echo "======================================================="
echo "== SNAP CONFIG SETUP =="
echo "======================================================="
####### checking card type
if [ "$FPGACARD" = "N250S" ]; then
SNAP_CFG="CONFIG_N250S=y\n"
elif [ "$FPGACARD" = "ADKU3" ]; then
SNAP_CFG="CONFIG_ADKU3=y\n"
else
echo "($0) ERROR: FPGACARD is not set correctly. Not generating config files."
break
fi
SNAP_CFG="$SNAP_CFG""CONFIG_FPGACARD=$FPGACARD\n"
SNAP_CFG="$SNAP_CFG""CONFIG_FPGACHIP=xcku060-ffva1156-2-e\n"
####### checking num of actions
if [ -z "$NUM_OF_ACTIONS" ]; then
SNAP_CFG="$SNAP_CFG""CONFIG_NUM_OF_ACTIONS=1\n"
else
SNAP_CFG="$SNAP_CFG""CONFIG_NUM_OF_ACTIONS=$NUM_OF_ACTIONS\n"
fi
####### checking HLS support
if [ -z "$HLS_SUPPORT" ]; then
if [ -z `echo "x$ACTION_ROOT" | grep -i /HLS` ]; then
HLS_SUPPORT="FALSE"
else
HLS_SUPPORT="TRUE"
fi
fi
SNAP_CFG="$SNAP_CFG""CONFIG_HLS_SUPPORT=${HLS_SUPPORT^^}\n"
####### checking SDRAM and BRAM
BRAM_USED=${BRAM_USED^^}
if [ "$BRAM_USED" = "TRUE" ]; then
SDRAM_USED="FALSE"
DDR3_USED="FALSE"
DDR4_USED="FALSE"
DDRI_USED="TRUE"
SNAP_CFG="$SNAP_CFG""CONFIG_ENABLE_BRAM=y\n"
SNAP_CFG="$SNAP_CFG""CONFIG_ENABLE_DDRI=y\n"
else
BRAM_USED="FALSE"
SDRAM_USED=${SDRAM_USED^^}
if [ "$SDRAM_USED" = "TRUE" ]; then
if [ "$FPGACARD" = "ADKU3" ]; then
DDR3_USED="TRUE"
DDR4_USED="FALSE"
SNAP_CFG="$SNAP_CFG""CONFIG_ENABLE_DDR3=y\n"
else
DDR3_USED="FALSE"
DDR4_USED="TRUE"
SNAP_CFG="$SNAP_CFG""CONFIG_ENABLE_DDR4=y\n"
fi
SNAP_CFG="$SNAP_CFG""CONFIG_ENABLE_SDRAM=y\n"
SNAP_CFG="$SNAP_CFG""CONFIG_ENABLE_DDRI=y\n"
else
SDRAM_USED="FALSE"
DDR3_USED="FALSE"
DDR4_USED="FALSE"
fi
DDRI_USED="$SDRAM_USED"
fi
SNAP_CFG="$SNAP_CFG""CONFIG_BRAM_USED=$BRAM_USED\n"
SNAP_CFG="$SNAP_CFG""CONFIG_SDRAM_USED=$SDRAM_USED\n"
SNAP_CFG="$SNAP_CFG""CONFIG_DDR3_USED=$DDR3_USED\n"
SNAP_CFG="$SNAP_CFG""CONFIG_DDR4_USED=$DDR4_USED\n"
SNAP_CFG="$SNAP_CFG""CONFIG_DDRI_USED=$DDRI_USED\n"
####### checking NVME
NVME_USED=${NVME_USED^^}
if [ "$NVME_USED" = "TRUE" ]; then
if [ "$FPGACARD" != "N250S" ]; then
echo "($0) ERROR: NVME is enabled but FPGACARD is not set to N250S. Not generating config files."
break
fi
SNAP_CFG="$SNAP_CFG""CONFIG_ENABLE_NVME=y\n"
else
NVME_USED="FALSE"
fi
SNAP_CFG="$SNAP_CFG""CONFIG_NVME_USED=$NVME_USED\n"
####### checking ILA DEBUG
ILA_DEBUG=${ILA_DEBUG^^}
if [ "$ILA_DEBUG" = "TRUE" ]; then
SNAP_CFG="$SNAP_CFG""CONFIG_ENABLE_ILA=y\n"
else
ILA_DEBUG="FALSE"
fi
SNAP_CFG="$SNAP_CFG""CONFIG_ILA_DEBUG=$ILA_DEBUG\n"
####### checking FACTORY_IMAGE
FACTORY_IMAGE=${FACTORY_IMAGE^^}
if [ "$FACTORY_IMAGE" = "TRUE" ]; then
SNAP_CFG="$SNAP_CFG""CONFIG_ENABLE_FACTORY=y\n"
else
FACTORY_IMAGE="FALSE"
fi
SNAP_CFG="$SNAP_CFG""CONFIG_FACTORY_IMAGE=$FACTORY_IMAGE\n"
####### checking SIMULATOR
if [ -z "$SIMULATOR" ]; then
SIMULATOR="xsim"
fi
if [ "$SIMULATOR" = "xsim" ]; then
SNAP_CFG="$SNAP_CFG""CONFIG_SIM_XSIM=y\n"
elif [ "$SIMULATOR" = "irun" ]; then
SNAP_CFG="$SNAP_CFG""CONFIG_SIM_XSIM=y\n"
else
echo "($0) ERROR: SIMULATOR $SIMULATOR is not supported by SNAP. Not generating config files."
break
fi
SNAP_CFG="$SNAP_CFG""CONFIG_SIMULATOR=$SIMULATOR\n"
####### Creating .snap_config files
if [ -n "$SNAP_CFG" ]; then
echo -e "$SNAP_CFG" > $snap_config
cat $snap_config | sed 's/^CONFIG_/export /' > $snap_config.sh
cat $snap_config | tr -d '"' | sed 's/^CONFIG_\(.*\)/SNAP_CFLAGS += "-DCONFIG_\1"/' > $snap_config_cflags
echo "Generation of SNAP config files done. Content of .snap_config is:"
cat $snap_config
fi
echo
SETUP_DONE="1"
done
# set a return value in case that the file was sourced
if [[ "$_" = "$0" ]]; then
if [[ "$SETUP_DONE" == "1" ]]; then return 0; else return 1; fi
fi