forked from Xilinx/Vitis-Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·146 lines (120 loc) · 5.58 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
# © Copyright 2020 Xilinx, Inc.
#
# 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.
#Check environment setup
ifndef PLATFORM_REPO_PATHS
PLATFORM_REPO_PATHS=/proj/xbuilds/${TOOLVERSION}/internal_platforms
export PLATFORM_REPO_PATHS
endif
XF_PROJ_ROOT ?= $(shell bash -c 'export MK_PATH=$(MK_PATH); echo $${MK_PATH%/AI_Engine_Development/*}')
# Makefile input options
TARGET := hw_emu
PFM := tutorial
EMU_CMD := ./launch_hw_emu.sh
# File names and locations
GRAPH := aie/graph.cpp
GRAPH_O := libadf.a
KERNEL := s2mm.cpp mm2s.cpp
KERNEL_XO := s2mm.xo mm2s.xo polar_clip.xo
CONFIG_FILE := system.cfg
SDKTARGETSYSROOT ?= $(SYSROOT)
PLATFORM ?= ${PLATFORM_REPO_PATHS}/xilinx_vck190_base_202220_1/xilinx_vck190_base_202220_1.xpfm
ROOTFS ?= ${PLATFORM_REPO_PATHS}/sw/versal/xilinx-versal-common-v2022.2/rootfs.ext4
IMAGE ?= ${PLATFORM_REPO_PATHS}/sw/versal/xilinx-versal-common-v2022.2/Image
# 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) -workdir=./Work
VPP_XO_FLAGS := -c --platform $(PLATFORM) -g --save-temps
VPP_LINK_FLAGS := -l --platform $(PLATFORM) $(KERNEL_XO) $(GRAPH_O) -t $(TARGET) --save-temps -g --config $(CONFIG_FILE) -o $(PFM).xsa
VPP_FLAGS := $(VPP_LINK_FLAGS)
LDCLFLAGS :=
GCC_FLAGS := -Wall -c \
-std=c++14 \
-Wno-int-to-pointer-cast \
--sysroot=${SDKTARGETSYSROOT}
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 := -ladf_api_xrt -lxrt_coreutil \
-L$(SDKTARGETSYSROOT)/usr/lib \
-L${XILINX_VITIS}/aietools/lib/aarch64.o \
--sysroot=${SDKTARGETSYSROOT}
.ONESHELL:
.PHONY: clean all kernels aie xclbin host package run_emu
guard-%:
@#$(or ${$*}, $(error $* is not set. Run: environment-setup-cortexa72-cortexa53-xilinx-linux))
run: all
all: kernels aie xclbin host package
sd_card: kernels aie xclbin host package
######################################################
# This step compiles the HLS C kernels and creates an SDF Graph
# the %.xo is used as the output and creates from the %.cpp files
# The graph is generated by having the -target=hw-link
kernels: $(KERNEL_XO)
%.xo: pl_kernels/%.cpp
$(VPP) $(VPP_XO_FLAGS) -k $(basename $(notdir $<)) $< -o $@
polar_clip.xo:
vivado -mode batch -source polar_clip_rtl_kernel.tcl
cp ip_repo/polar_clip.xo .
aie: $(GRAPH_O)
$(GRAPH_O): $(GRAPH)
$(AIECC) $(AIE_FLAGS) $(GRAPH)
#####################################################
########################################################
# Once the kernels and graph are generated, you can build
# the new platform. This creates an XSA and the use of
# generetate-platform.sh to build the actual platform
xclbin: $(GRAPH_O) $(KERNEL_XO)
$(VPP) $(VPP_LINK_FLAGS) || (echo "task: [xclbin] failed error code: $$?"; exit 1)
########################################################
############################################################################################################################
# For hardware and hardware emulation, compile the PS code and generate the main.elf. This is needed for creating the PDI.
host: guard-SYSROOT guard-CXX
cd ./sw
$(XILINX_VITIS)/gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-g++ $(GCC_FLAGS) $(GCC_INCLUDES) -o aie_control_xrt.o ../Work/ps/c_rts/aie_control_xrt.cpp
$(XILINX_VITIS)/gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-g++ $(GCC_FLAGS) $(GCC_INCLUDES) -o host.o host.cpp
$(XILINX_VITIS)/gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-g++ *.o $(GCC_LIB) -std=c++14 -o host.exe
############################################################################################################################
##################################################################################################
# Depending on the TARGET, it'll either generate the PDI for hw_emu or hw.
package: guard-IMAGE guard-ROOTFS
cd ./sw
v++ -p -t ${TARGET} \
-f ${PLATFORM} \
--package.rootfs=${ROOTFS} \
--package.image_format=ext4 \
--package.boot_mode=sd \
--package.kernel_image=${IMAGE} \
--package.defer_aie_run \
--package.sd_file embedded_exec.sh \
--package.sd_file host.exe ../tutorial.xsa ../libadf.a
###################################################################################################
###########################################################################
# If the target is for HW_EMU, launch the emulator
# If the target is for HW, you'll have to follow the Confluence page for
# running on a board farm system.
run_emu:
ifeq (${TARGET},hw_emu)
cd ./sw
$(EMU_CMD)
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/*.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