-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile_versal_alveo.mk
140 lines (115 loc) · 4.94 KB
/
makefile_versal_alveo.mk
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
#
# Copyright 2019-2021 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.
# makefile-generator v1.0.3
#
############################## Help Section ##############################
ifneq ($(findstring Makefile, $(MAKEFILE_LIST)), Makefile)
help:
$(ECHO) "Makefile Usage:"
$(ECHO) " make all TARGET=<sw_emu/hw_emu/hw> PLATFORM=<FPGA platform>"
$(ECHO) " Command to generate the design for specified Target and Shell."
$(ECHO) ""
$(ECHO) " make run TARGET=<sw_emu/hw_emu/hw> PLATFORM=<FPGA platform>"
$(ECHO) " Command to run application in emulation."
$(ECHO) ""
$(ECHO) " make build TARGET=<sw_emu/hw_emu/hw> PLATFORM=<FPGA platform>"
$(ECHO) " Command to build xclbin application."
$(ECHO) ""
$(ECHO) " make host"
$(ECHO) " Command to build host application."
$(ECHO) ""
$(ECHO) " make clean "
$(ECHO) " Command to remove the generated non-hardware files."
$(ECHO) ""
$(ECHO) " make cleanall"
$(ECHO) " Command to remove all the generated files."
$(ECHO) ""
endif
############################## Setting up Project Variables ##############################
TARGET := hw
VPP_LDFLAGS :=
include ./utils.mk
TEMP_DIR := ./_x.$(TARGET).$(XSA)
BUILD_DIR := ./build_dir.$(TARGET).$(XSA)
LINK_OUTPUT := $(BUILD_DIR)/vadd.link.xsa
PACKAGE_OUT = ./package.$(TARGET)
VPP_PFLAGS :=
CMD_ARGS = -x $(BUILD_DIR)/vadd.xclbin
CXXFLAGS += -I$(XILINX_XRT)/include -I$(XILINX_VIVADO)/include -Wall -O0 -g -std=c++1y
LDFLAGS += -L$(XILINX_XRT)/lib -pthread -lOpenCL
########################## Checking if PLATFORM in allowlist #######################
PLATFORM_BLOCKLIST += nodma
############################## Setting up Host Variables ##############################
#Include Required Host Source Files
CXXFLAGS += -I$(XF_PROJ_ROOT)/common/includes/cmdparser
CXXFLAGS += -I$(XF_PROJ_ROOT)/common/includes/logger
HOST_SRCS += $(XF_PROJ_ROOT)/common/includes/cmdparser/cmdlineparser.cpp $(XF_PROJ_ROOT)/common/includes/logger/logger.cpp ./src/host.cpp
# Host compiler global settings
CXXFLAGS += -fmessage-length=0
LDFLAGS += -lrt -lstdc++
LDFLAGS += -luuid -lxrt_coreutil
############################## Setting up Kernel Variables ##############################
# Kernel compiler global settings
VPP_FLAGS += --save-temps
EXECUTABLE = ./test_main_master
EMCONFIG_DIR = $(TEMP_DIR)
############################## Setting Targets ##############################
.PHONY: all clean cleanall docs emconfig
all: check-platform check-device check-vitis $(EXECUTABLE) $(BUILD_DIR)/vadd.xclbin emconfig
.PHONY: host
host: $(EXECUTABLE)
.PHONY: build
build: check-vitis check-device $(BUILD_DIR)/vadd.xclbin
.PHONY: xclbin
xclbin: build
############################## Setting Rules for Binary Containers (Building Kernels) ##############################
$(TEMP_DIR)/vadd.xo: src/vadd.cpp
mkdir -p $(TEMP_DIR)
v++ -c $(VPP_FLAGS) -t $(TARGET) --platform $(PLATFORM) -k vadd --temp_dir $(TEMP_DIR) -I'$(<D)' -o'$@' '$<'
$(BUILD_DIR)/vadd.xclbin: $(TEMP_DIR)/vadd.xo
mkdir -p $(BUILD_DIR)
v++ -l $(VPP_FLAGS) $(VPP_LDFLAGS) -t $(TARGET) --platform $(PLATFORM) --temp_dir $(TEMP_DIR) -o'$(LINK_OUTPUT)' $(+)
v++ -p $(LINK_OUTPUT) $(VPP_FLAGS) -t $(TARGET) --platform $(PLATFORM) --package.out_dir $(PACKAGE_OUT) -o $(BUILD_DIR)/vadd.xclbin
############################## Setting Rules for Host (Building Host Executable) ##############################
$(EXECUTABLE): $(HOST_SRCS) | check-xrt
g++ -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
emconfig:$(EMCONFIG_DIR)/emconfig.json
$(EMCONFIG_DIR)/emconfig.json:
emconfigutil --platform $(PLATFORM) --od $(EMCONFIG_DIR)
############################## Setting Essential Checks and Running Rules ##############################
run: all
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
cp -rf $(EMCONFIG_DIR)/emconfig.json .
XCL_EMULATION_MODE=$(TARGET) $(EXECUTABLE) $(CMD_ARGS)
else
$(EXECUTABLE) $(CMD_ARGS)
endif
.PHONY: test
test: $(EXECUTABLE)
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
XCL_EMULATION_MODE=$(TARGET) $(EXECUTABLE) $(CMD_ARGS)
else
$(EXECUTABLE) $(CMD_ARGS)
endif
############################## Cleaning Rules ##############################
# Cleaning stuff
clean:
-$(RMDIR) $(EXECUTABLE) $(XCLBIN)/{*sw_emu*,*hw_emu*}
-$(RMDIR) profile_* TempConfig system_estimate.xtxt *.rpt *.csv
-$(RMDIR) src/*.ll *v++* .Xil emconfig.json dltmp* xmltmp* *.log *.jou *.wcfg *.wdb
cleanall: clean
-$(RMDIR) build_dir*
-$(RMDIR) package.*
-$(RMDIR) _x* *xclbin.run_summary qemu-memory-_* emulation _vimage pl* start_simulation.sh *.xclbin