-
Notifications
You must be signed in to change notification settings - Fork 1
/
sdaccel-builder
executable file
·200 lines (173 loc) · 4.48 KB
/
sdaccel-builder
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
#!/bin/bash
set -e
set -o pipefail
export DIR
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export ROOT_DIR="$PWD"
reco_optimize="yes"
reco_memory_interface="axi"
reco_memory_width=64
reco_ports=2
reco_compiler=teak
function parse_yaml {
local file="$1"
local lookup_var="$2"
local default="$3"
# Parse stdin as yaml, grab key according to first argument from dict
# and print it; if that key is missing print a default value.
local prog='
import yaml, sys
filename, key, default = sys.argv[1:]
with open(filename, "rU") as fd: # universal newlines
parsed = yaml.load(fd)
print(parsed.get(key, default))
'
python3 -c "$prog" "$file" "$lookup_var" "$default"
}
if [ -e 'reco.yml' ]; then
reco_optimize="$(parse_yaml reco.yml optimize "$reco_optimize")"
reco_memory_interface="$(parse_yaml reco.yml memory_interface "$reco_memory_interface")"
reco_memory_width="$(parse_yaml reco.yml memory_width "$reco_memory_width")"
reco_ports="$(parse_yaml reco.yml ports "$reco_ports")"
reco_compiler="$(parse_yaml reco.yml compiler "$reco_compiler")"
fi
RECO_ARGS=(
"OPTIMIZE=$reco_optimize"
"MEMORY_INTERFACE=$reco_memory_interface"
"AXI_DATA_WIDTH=$reco_memory_width"
"PORTS=$reco_ports"
"COMPILER=$reco_compiler"
)
MAKE=(
make
--environment-overrides
--file "$DIR/sdaccel-builder.mk"
"${RECO_ARGS[@]}"
)
echo "Using RECO_ARGS ${RECO_ARGS[*]}"
export PATH="$DIR/eTeak:$DIR/eTeak/bin:$DIR/smi/bin:$DIR/bin:$PATH"
# Merge timing and utilization reports.
# Exposed as the command report for easier testing without the full xocc flow.
# e.g. sdaccel-builder report
# Primarily will be used by the build & simulate commands
function report {
"${MAKE[@]}" TARGET=hw report
}
function sim_report {
"${MAKE[@]}" TARGET=hw_emu sim_report
}
function graph {
"${MAKE[@]}" TARGET=hw graph
}
function build {
"${MAKE[@]}" TARGET=hw_emu kernel sim
# run reports after everything
report
}
function image {
"${MAKE[@]}" TARGET=hw kernel
# run reports after everything
report
}
function test_go {
"${MAKE[@]}" verilog
}
function simulate {
# shellcheck source=/dev/null
source "$XILINX_SDACCEL"/settings64.sh
"${MAKE[@]}" TARGET=hw_emu sim cmds kernel
# run reports after everything
sim_report
export PATH="$PWD/.reco-work/sdaccel/dist/":$PATH
# This is for the emconfig.json
cd "$PWD/.reco-work/sdaccel/dist/"
XCL_EMULATION_MODE=hw_emu \
XCL_BINDIR="$PWD/.reco-work/sdaccel/dist/xclbin" \
bash -c "$@"
}
function cmds {
"${MAKE[@]}" cmds
}
function clean {
"${MAKE[@]}" clean
}
function lint {
test_go
TOP=sda_kernel_wrapper_gmem
EXTRA=()
if [ "$reco_memory_interface" == "smi" ]
then
EXTRA=(
"-DAXI_MASTER_DATA_WIDTH=$reco_memory_width"
"-DAXI_MASTER_HAS_WID=1"
"-DKERNEL_HAS_SMI_ADAPTOR=1"
)
fi
reco_arg_width=$("${MAKE[@]}" -s print-ARG_WIDTH)
if [ "$reco_arg_width" -gt 0 ]
then
EXTRA+=(
"-DKERNEL_ARGS_DATA=1"
"-DKERNEL_ARGUMENT_WIDTH=$reco_arg_width"
)
fi
if [ "$reco_compiler" == "rio" ]
then
TOP=sda_kernel_wrapper_rio
# Include gmem stub
EXTRA+=("$DIR/go-teak/src/sdaccel/stubs/sda_kernel_action_stub_gmem.v")
else
# Include rio stub
EXTRA+=("$DIR/go-teak/src/sdaccel/stubs/rio_kernel_action_stub.v")
fi
verilator \
-Wall \
--lint-only \
-I".reco-work/sdaccel/verilog/includes" \
.reco-work/sdaccel/verilog/library/* \
.reco-work/sdaccel/verilog/main.v \
"${EXTRA[@]}" \
--top-module "$TOP" \
--report-unoptflat \
-Wno-REDEFMACRO \
-Wno-DECLFILENAME \
-Wno-UNUSED \
-Wno-UNDRIVEN \
-Wno-MODDUP
}
function main {
case "$1" in
"build")
build "${@:2}"
;;
"report")
report "${@:2}"
;;
"simulate")
simulate "${@:2}"
;;
"image")
image "${@:2}"
;;
"graph")
graph "${@:2}"
;;
"cmds")
cmds "${@:2}"
;;
"test-go")
test_go "${@:2}"
;;
"clean")
clean "${@:2}"
;;
"lint")
lint "${@:2}"
;;
*)
echo "unrecognized command: $1";
exit 1
;;
esac
}
main "$@"