This repository has been archived by the owner on Jul 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
267 lines (204 loc) · 7.88 KB
/
Makefile
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
#
# Usage:
# $ make (DEBUG=true) {compile,test,clean}-{docs,lane,rtl}
#
.DEFAULT_GOAL: all
all: clean compile test
#
# Options; can be overridden by environment variables
#
LATEXMK_OUT ?= ./build/
LATEXMK_OPTS ?= -emulate-aux-dir -auxdir=./docs/ -output-directory=$(LATEXMK_OUT)
export TEXINPUTS := $(CURDIR)/docs//:$(TEXINPUTS):
export BIBINPUTS := $(CURDIR)/docs//:
LANE_DEPS ?= -lm
LANE_SRCS ?= $(wildcard ./src/lane_*.c)
#LANE_TESTS ?= $(wildcard ./test/lane_*_test.c)
LANE_TESTS ?= ./test/lane_image_ppm_test.c
LANE_OUT ?= ./build/lane
ifdef DEBUG
LANE_OPTS ?= -g3 -Wall -Werror -Wno-error=unknown-pragmas -DLANE_LOG_ENABLE
else
LANE_OPTS ?= -Wno-error=unknown-pragmas
endif
RC_DEPS ?= `pkg-config sigc++-3.0 gtkmm-4.0 --cflags --libs`
RC_OPTS ?= -std=c++20 -Wall
RC_OUT ?= ./build/rc
DOXYGEN_CONF ?= ./Doxyfile
VALGRIND_OPTS ?= --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1
DATA_EXEC ?= ./data/extract.sh
DATA_OUT ?= ./data/
DATA_TARGETS ?= $(wildcard $(DATA_OUT).ppm)$(wildcard $(DATA_OUT).jpg)
RTL_SRCS ?= $(wildcard ./rtl/hw_*.vhd)
RTL_OUT ?= ./build/
RTL_TARGET ?= hw_grayscale
RTL_SIMTIME ?= 100ns
RTL_WAVE ?= $(RTL_OUT)$(RTL_TARGET).vcd
#RTL_DEST ?= smb://z2/xilinx/jupyter_notebooks/lane
RTL_DEST ?= /run/user/1000/gvfs/smb-share:server=192.168.2.99,share=xilinx/jupyter_notebooks/lane
ifdef DEBUG
RTL_GOALS ?= "-a ../rtl/$(RTL_TARGET).vhd" \
"-e $(RTL_TARGET)" \
"-r $(RTL_TARGET) --vcd=$(RTL_TARGET).vcd --stop-time=$(RTL_SIMTIME)"
else
# als we niet willen debuggen is analysis en elaboration genoeg
RTL_GOALS ?= "-a ../rtl/$(RTL_TARGET).vhd" \
"-e $(RTL_TARGET)"
endif
#
# Executable paths; can be overridden by env vars
#
LATEXMK_EXEC ?= /usr/bin/latexmk
GCC_EXEC ?= /usr/bin/gcc
GXX_EXEC ?= /usr/bin/g++
VALGRIND_EXEC ?= /usr/bin/valgrind
GHDL_EXEC ?= /usr/bin/ghdl
DOXYGEN_EXEC ?= /usr/bin/doxygen
GTKWAVE_EXEC ?= /usr/bin/gtkwave
XDG_OPEN_EXEC ?= /usr/bin/xdg-open
RM_EXEC ?= /usr/bin/rm
MKDIR_EXEC ?= /usr/bin/mkdir
GIO_EXEC ?= /usr/bin/gio
MAKE_EXEC ?= /usr/bin/make
CHMOD_EXEC ?= /usr/bin/chmod
GIT_EXEC ?= /usr/bin/git
VIVADO_FOUND := $(shell which vitis_hls 2> /dev/null)
#
# Library paths; can be overridden by env vars
#
export OPENCV_INCLUDE ?= /usr/include/opencv4
export OPENCV_LIB ?= /usr/lib
export VISION_INCLUDE ?= /home/mbr/ext/Vitis_Libraries/vision/L1/include
#
# Compilation-related targets
#
make-out-dir:
$(MKDIR_EXEC) -p $(LATEXMK_OUT)
# TODO wildcard based approach for doc rules
compile-docs-project:
$(LATEXMK_EXEC) $(LATEXMK_OPTS) docs/plan-of-action/project.tex
compile-docs-timetable:
$(LATEXMK_EXEC) $(LATEXMK_OPTS) docs/timetable/timetable.tex
compile-docs-research:
$(LATEXMK_EXEC) $(LATEXMK_OPTS) docs/research-paper/research.tex
compile-docs-fd:
$(LATEXMK_EXEC) $(LATEXMK_OPTS) docs/functional-design/fd.tex
compile-docs-td:
$(LATEXMK_EXEC) $(LATEXMK_OPTS) docs/technical-design/td.tex
compile-docs-code:
$(DOXYGEN_EXEC) $(DOXYGEN_CONF)
cd ./build/latex && $(MAKE_EXEC) all
compile-docs: make-out-dir compile-docs-project compile-docs-timetable compile-docs-research compile-docs-fd compile-docs-td compile-docs-code
compile-lane: make-out-dir
$(GCC_EXEC) $(LANE_OPTS) src/lane_*.c -o $(LANE_OUT) $(LANE_DEPS)
compile-rc: make-out-dir
$(GXX_EXEC) $(RC_OPTS) rc/rc_*.cpp -o $(RC_OUT) $(RC_DEPS)
test-rtl: make-out-dir
# GHDL uses current directory as output, so cd into build dir first
#(cd $(RTL_OUT) && eval "$(GHDL_EXEC) ${goal}");
for goal in $(RTL_GOALS); do \
(cd $(RTL_OUT); echo "$$goal"; eval "ghdl $$goal"); \
done
compile-hls: make-out-dir
ifndef VIVADO_FOUND
$(error "Vivado scripts not found in PATH; make sure they are sourced")
endif
unset SIM && export SYNTH=1 && export TARGET_PART=zynq && vitis_hls -f hls.tcl
compile-hw: #compile-hls
# Just override the usage of all targets right now, maybe adjust this later TODO
export SYNTH=1 && export IMPL=1 && export TIMING=1 && ./hw.tcl
compile: compile-docs compile-lane # compile-hw
#
# Cleaning-related targets
#
clean-docs-project:
$(LATEXMK_EXEC) $(LATEXMK_OPTS) -CA docs/plan-of-action/project.tex
clean-docs-timetable:
$(LATEXMK_EXEC) $(LATEXMK_OPTS) -CA docs/timetable/timetable.tex
clean-docs-research:
$(LATEXMK_EXEC) $(LATEXMK_OPTS) -CA docs/research-paper/research.tex
clean-docs: clean-docs-project clean-docs-timetable clean-docs-research
$(RM_EXEC) -rf $(LATEXMK_OUT)
# latexmk doesn't delete snm,nav,runxml, and other files, so just nuke those:
find . -iregex '.*\.\(aux\|fls\|log\|nav\|fdb_latexmk\|out\|snm\|toc\|xdv\|run.xml\|bbl\|bcf\|lot\|lof\|blg\|synctex.gz\)$$' -type f -delete
clean-lane:
$(RM_EXEC) -rf $(LANE_OUT)
clean-rtl:
$(RM_EXEC) -rf $(RTL_OUT)
clean-hls:
# As far as I've noticed these are the only products Vitis creates but there may be more
$(RM_EXEC) -rf vitis_hls.log ./build/lane_vpu.prj ./build/misc
clean-hw:
$(RM_EXEC) -rf ./build/lane_hw** ./build/syn_*.* ./build/imp_*.* ./build/vivado.*
clean: clean-docs clean-lane clean-rtl clean-hls clean-hw
#
# Program execution target
# (todo: remove because lane_main.c is not used anymore, only test cases are used)
#
run-lane:
$(LANE_OUT) data/0a0a0b1a-7c39d841.ppm data/0a0a0b1a-7c39d841.out.ppm
run-rc:
$(RC_OUT)
run: run-lane
#
# Inspect-** targets can be used on desktop to open
# the output of tasks in a GUI application.
#
inspect-rtl:
$(GTKWAVE_EXEC) $(RTL_WAVE)
inspect-docs-project:
$(XDG_OPEN_EXEC) docs/project.tex
inspect-docs-timetable:
$(XDG_OPEN_EXEC) docs/timetable.tex
inspect-docs-research:
$(XDG_OPEN_EXEC) docs/research.tex
install-git-hook:
cp git-info-hook.sh .git/hooks/post-checkout
cp git-info-hook.sh .git/hooks/post-commit
cp git-info-hook.sh .git/hooks/post-merge
$(CHMOD_EXEC) g+x .git/hooks/post-*
$(GIT_EXEC) config --local include.path ../.gitconfig
#
# Test
#
test-lane-compile: compile-lane
$(GCC_EXEC) $(LANE_OPTS) $(LANE_TESTS) $(filter-out ./src/lane_main.c, $(LANE_SRCS)) -I ./src/ -o build/lane_image_ppm_test $(LANE_DEPS)
test-lane-exec: test-lane-compile
build/lane_image_ppm_test data/0a0a0b1a-7c39d841.ppm data/0a0a0b1a-7c39d841.out.ppm
test-lane-verify: test-lane-exec
test/lane_image_ppm_test.sh
# Manual test, needs env vars ARG_SAMPLE and ARG_TEST
test-lane-man: make-out-dir
$(GCC_EXEC) $(LANE_OPTS) "test/lane_$(ARG_TEST)_test.c" $(filter-out ./src/lane_main.c, $(LANE_SRCS)) -I ./src/ -o build/man_test $(LANE_DEPS)
ifdef VALGRIND
$(VALGRIND_EXEC) $(VALGRIND_OPTS) --log-file="build/$(ARG_TEST).valgrind.log" build/man_test "data/$(ARG_SAMPLE).ppm" "data/$(ARG_SAMPLE).$(ARG_TEST).out.ppm"
else
build/man_test "data/$(ARG_SAMPLE).ppm" "data/$(ARG_SAMPLE).$(ARG_TEST).out.ppm"
endif
$(XDG_OPEN_EXEC) "data/$(ARG_SAMPLE).$(ARG_TEST).out.ppm"
test-lane: test-lane-verify
test-hls-sim: make-out-dir
ifndef VIVADO_FOUND
$(error "Vivado scripts not found in PATH; make sure they are sourced")
endif
export SIM=1 && unset SYNTH && unset COSIM && export TARGET_PART=zynq && vitis_hls -f hls.tcl
test-hls-cosim: make-out-dir
ifndef VIVADO_FOUND
$(error "Vivado scripts not found in PATH; make sure they are sourced")
endif
unset SIM && export SYNTH=1 && export COSIM=1 && export TARGET_PART=zynq && vitis_hls -f hls.tcl
test-hls: test-hls-sim test-hls-cosim
test: test-lane
#
# Transfer bitstream to device
#
transfer-bitstream:
# If it is mounted via GVFS:
mkdir -p $(RTL_DEST)
$(GIO_EXEC) copy ${RTL_OUT}/lane_hw.runs/impl_1/bd_wrapper.bit $(RTL_DEST)/hw_overlay.bit
$(GIO_EXEC) copy ${RTL_OUT}/lane_hw.gen/sources_1/bd/bd/hw_handoff/bd.hwh $(RTL_DEST)/hw_overlay.hwh
$(GIO_EXEC) copy ./rtl/driver.ipynb $(RTL_DEST)/driver.ipynb
# Otherwise:
#curl --upload-file ${RTL_OUT}/lane_hw.runs/impl_1/bd_wrapper.bit --user "WORKGROUP\xilinx:xilinx" $(RTL_DEST)/hw_overlay.bit
#curl --upload-file ${RTL_OUT}/lane_hw.gen/sources_1/bd/bd/hw_handoff/bd.hwh --user "WORKGROUP\xilinx:xilinx" $(RTL_DEST)/hw_overlay.bit
#curl --upload-file ./rtl/driver.ipynb --user "WORKGROUP\xilinx:xilinx" $(RTL_DEST)/driver.ipynb