forked from Xilinx/Vitis-Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
141 lines (112 loc) · 5.26 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
# Makefile input options
TARGET := hw_emu
PFM := tutorial
# File names and locations
GRAPH := aie/graph.cpp
GRAPH_O := libadf.a
KERNEL := s2mm.cpp mm2s.cpp polar_clip.cpp
KERNEL_XO := s2mm.xo mm2s.xo polar_clip.xo
CONFIG_FILE := system.cfg
BASE_PLATFORM := ${PLATFORM_REPO_PATHS}/xilinx_vck190_es1_base_202020_1/xilinx_vck190_es1_base_202020_1.xpfm
# Command-line options
VPP := v++
AIECC := aiecompiler
AIE_INCLUDE_FLAGS := -include="$(XILINX_VITIS)/aietools/include" -include="./aie" -include="./data" -include="./aie/kernels" -include="./"
AIE_FLAGS := --target=hw $(AIE_INCLUDE_FLAGS) --pl-freq=200 -workdir=./Work
VPP_XO_FLAGS := -c --platform $(BASE_PLATFORM) --save-temps -g
VPP_LINK_FLAGS := -l --platform $(BASE_PLATFORM) $(KERNEL_XO) $(GRAPH_O) -t $(TARGET) --save-temps -g --config $(CONFIG_FILE) -o $(PFM).xclbin
GCC_FLAGS := -Wall -c \
-std=c++14 \
-Wno-int-to-pointer-cast \
GCC_INCLUDES := -I$(SDKTARGETSYSROOT)/usr/include/xrt \
-I$(SDKTARGETSYSROOT)/usr/include \
-I./ -I../aie \
-I${XILINX_VITIS}/aietools/include \
-I${XILINX_VITIS}/include
GCC_LIB := -lxaiengine -ladf_api_xrt -lxrt_core -lxrt_coreutil \
-L$(SDKTARGETSYSROOT)/usr/lib \
-L${XILINX_VITIS}/aietools/lib/aarch64.o
.ONESHELL:
.PHONY: clean all kernels aie xclbin host package run_emu
###
# Guarding Checks. Do not modify.
###
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))
guard-PLATFORM_REPO_PATHS:
$(call check_defined, PLATFORM_REPO_PATHS, Set your where you downloaded xilinx_vck190_es1_base_2020210_1)
guard-ROOTFS:
$(call check_defined, ROOTFS, Set to: xilinx-versal-common-v2020.2/rootfs.ext4)
guard-IMAGE:
$(call check_defined, IMAGE, Set to: xilinx-versal-common-v2020.2/Image)
guard-CXX:
$(call check_defined, CXX, Run: xilinx-versal-common-v2020.2/environment-setup-aarch64-xilinx-linux)
guard-SDKTARGETSYSROOT:
$(call check_defined, SDKTARGETSYSROOT, Run: xilinx-versal-common-v2020.2/environment-setup-aarch64-xilinx-linux)
###
all: kernels aie xclbin host package
######################################################
# This step compiles the HLS C kernels and creates an ADF Graph
# the %.xo is used as the output and creates from the %.cpp files
# The graph is generated by having the -target=hw
kernels: guard-PLATFORM_REPO_PATHS $(KERNEL_XO)
@echo "COMPLETE: Kernels Created."
%.xo: pl_kernels/%.cpp
$(VPP) $(VPP_XO_FLAGS) -k $(basename $(notdir $<)) $< -o $@
aie: $(GRAPH_O)
aiesim: $(GRAPH_O)
aiesmulator --pkg-dir=./Work
$(GRAPH_O): $(GRAPH)
$(AIECC) $(AIE_FLAGS) $(GRAPH)
@echo "COMPLETE: libadf.a created."
#####################################################
########################################################
# Once the kernels and graph are generated, you can build
# the hardware part of the design. This creates an xclbin
# that will be used to run the design on the platform.
xclbin: guard-PLATFORM_REPO_PATHS $(GRAPH_O) $(KERNEL_XO)
$(VPP) $(VPP_LINK_FLAGS) || (echo "task: [xclbin] failed error code: $$?"; exit 1)
@echo "COMPLETE: .xclbin created."
########################################################
############################################################################################################################
# For hardware and hardware emulation, compile the PS code and generate the host.exe. This is needed for creating the sd_card.
host: guard-CXX guard-SDKTARGETSYSROOT
cd ./sw
$(CXX) $(GCC_FLAGS) $(GCC_INCLUDES) -o aie_control_xrt.o ../Work/ps/c_rts/aie_control_xrt.cpp
$(CXX) $(GCC_FLAGS) $(GCC_INCLUDES) -o main.o host.cpp
$(CXX) *.o $(GCC_LIB) -std=c++14 -o host.exe
@echo "COMPLETE: Host application created."
############################################################################################################################
##################################################################################################
# Depending on the TARGET, it'll either generate the PDI for hw_emu or hw.
package: guard-IMAGE guard-ROOTFS guard-PLATFORM_REPO_PATHS
cd ./sw
v++ -p -t ${TARGET} \
-f ${BASE_PLATFORM} \
--package.rootfs=${ROOTFS} \
--package.image_format=ext4 \
--package.boot_mode=sd \
--package.kernel_image=${IMAGE} \
--package.defer_aie_run \
--package.sd_file host.exe ../tutorial.xclbin ../libadf.a
@echo "COMPLETE: hw_emu package created."
###################################################################################################
###########################################################################
# If the target is for HW_EMU, launch the emulator
# If the target is for HW, you'll have to load it onto an sd_card for the device
run_emu:
ifeq (${TARGET},hw_emu)
cd ./sw
./launch_hw_emu.sh
else
@echo "Hardware build, no emulation executed."
endif
###########################################################################
clean:
rm -rf _x v++* $(KERNEL_XO) $(GRAPH_O) *.o *.compile_summary* *.xpe xnwOut *.xclbin* *.log *.xsa Work *.db *.csv *$(PFM)* *.jou .Xil
rm -rf sw/*.log sw/*.xclbin sw/cfg/ sw/*.sh sw/qemu_dts_files sw/emu_qemu_scripts sw/*.exe sw/_x/ sw/*summary sw/*.o sw/*.elf sw/*.xpe sw/xnwOut sw/Work sw/*.csv sw/*.db sw/*.bin sw/*.BIN sw/*.bif sw/launch_hw_emulator.sh sw/*.txt sw/emulation sw/.Xil
rm -rf sw/sd_card sw/sd_card.img