-
Notifications
You must be signed in to change notification settings - Fork 2
/
makefile_us_alveo.mk
137 lines (112 loc) · 5.34 KB
/
makefile_us_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
############################## 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 ##############################
KERNEL_NAME :=QUEKUF
KERNEL_FUNCTION := decoderTop
TARGET := sw_emu
JOBS := 8
VPP_LDFLAGS :=
include ./utils.mk
TEMP_DIR := ./_x.$(TARGET).$(XSA)
BUILD_DIR := ./build_dir.$(TARGET).$(XSA)
LINK_OUTPUT := $(BUILD_DIR)/$(KERNEL_NAME).link.xclbin
PACKAGE_OUT = ./package.$(TARGET)
VPP_PFLAGS :=
VPP_CFLAGS :=
CMD_ARGS = $(BUILD_DIR)/$(KERNEL_NAME).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)/Hostcode/common/xcl2
HOST_SRCS += HostCode/common/xcl2.cpp HostCode/host.cpp HostCode/host.h
# Host compiler global settings
CXXFLAGS += -fmessage-length=0
LDFLAGS += -lrt -lstdc++
############################## Setting up Kernel Variables ##############################
# Kernel compiler global settings
VPP_FLAGS += --save-temps --vivado.synth.jobs $(JOBS) --vivado.impl.jobs $(JOBS) --hls.jobs $(JOBS)
KERN_SRCS += Design/DecoderMain.cpp Design/DecoderMain.h Design/ClusterUnit.cpp Design/ClusterUnit.h Design/Controller.cpp Design/Controller.h Design/Defines.h Design/SurfaceCode.cpp Design/SurfaceCode.h Design/Vector.h
EXECUTABLE = ./$(KERNEL_NAME)
EMCONFIG_DIR = $(TEMP_DIR)
VPP_CFLAGS += --hls.clock $(HLS_HZ):$(KERNEL_FUNCTION)
VPP_LDFLAGS += --kernel_frequency $(FREQ_MHZ)
############################## Setting Targets ##############################
.PHONY: all clean cleanall docs emconfig
all: check-platform check-device check-vitis $(EXECUTABLE) $(BUILD_DIR)/$(KERNEL_NAME).xclbin emconfig
.PHONY: host
host: $(EXECUTABLE)
.PHONY: build
build: check-vitis check-device $(BUILD_DIR)/$(KERNEL_NAME).xclbin
.PHONY: xclbin
xclbin: build
############################## Setting Rules for Binary Containers (Building Kernels) ##############################
$(TEMP_DIR)/$(KERNEL_NAME).xo: Design/DecoderMain.cpp
mkdir -p $(TEMP_DIR)
v++ -c $(VPP_FLAGS) $(VPP_CFLAGS) -t $(TARGET) --platform $(PLATFORM) -k $(KERNEL_FUNCTION) --temp_dir $(TEMP_DIR) -I'$(<D)' -o'$@' $(KERN_SRCS)
$(BUILD_DIR)/$(KERNEL_NAME).xclbin: $(TEMP_DIR)/$(KERNEL_NAME).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)/$(KERNEL_NAME).xclbin
##########################################
#FOR TESTING MAKEFILE VARIABLES ONLY
#REMEMBER TO DELETE ME
##########################################
testVARS:
@echo v++ -c $(VPP_FLAGS) $(VPP_CFLAGS) -t $(TARGET) --platform $(PLATFORM) -k decoderTop --temp_dir $(TEMP_DIR) -I'$(<D)' -o'$@' $(KERN_SRCS)
@echo v++ -l $(VPP_FLAGS) $(VPP_LDFLAGS) -t $(TARGET) --platform $(PLATFORM) --temp_dir $(TEMP_DIR) -o'$(LINK_OUTPUT)' $(+)
@echo v++ -p $(LINK_OUTPUT) $(VPP_FLAGS) -t $(TARGET) --platform $(PLATFORM) --package.out_dir $(PACKAGE_OUT) -o $(BUILD_DIR)/$(KERNEL_NAME).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