-
Notifications
You must be signed in to change notification settings - Fork 43
/
Makefile
executable file
·183 lines (148 loc) · 6.62 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
SHELL=/bin/bash
.PHONY: help
help:
@echo "Makefile Usage:"
@echo " make all DEVICE=<FPGA platform> INTERFACE=<CMAC Interface> DESIGN=<design name>"
@echo " Command to generate the xo for specified device and Interface."
@echo " By default, DEVICE=xilinx_u280_xdma_201920_3, INTERFACE=0 DESIGN=benchmark"
@echo " DESIGN also supports the string basic"
@echo ""
@echo " make clean "
@echo " Command to remove the generated non-hardware files."
@echo ""
@echo " make distclean"
@echo " Command to remove all the generated files in the current directory"
@echo ""
@echo " make distcleanall"
@echo " Command to remove all the generated in the current directory and one level down"
@echo ""
DEVICE ?= xilinx_u280_xdma_201920_3
INTERFACE ?= 0
DESIGN ?= benchmark
XCLBIN_NAME ?= vnx_$(DESIGN)_if$(INTERFACE)
MAX_SOCKETS ?= 16
ifeq ($(shell test $(MAX_SOCKETS) -gt 63; echo $$?),0)
$(error Error: maximum number of sockets is 63)
endif
UDP_THEIR_IP_OFFSET = 0x820
UDP_THEIR_PORT_OFFSET = $(shell printf "0x%04X\n" $$(($(UDP_THEIR_IP_OFFSET) + 8*$(MAX_SOCKETS))))
UDP_MY_PORT_OFFSET = $(shell printf "0x%04X\n" $$(($(UDP_THEIR_PORT_OFFSET) + 8*$(MAX_SOCKETS))))
UDP_VALID_OFFSET = $(shell printf "0x%04X\n" $$(($(UDP_MY_PORT_OFFSET) + 8*$(MAX_SOCKETS))))
XSA := $(strip $(patsubst %.xpfm, % , $(shell basename $(DEVICE))))
TEMP_DIR := _x.$(XSA)
VPP := $(XILINX_VITIS)/bin/v++
CLFLAGS += -t hw --platform $(DEVICE) --save-temps
BUILD_DIR := ./$(DESIGN).intf$(INTERFACE).$(XSA)
BINARY_CONTAINERS = $(BUILD_DIR)/${XCLBIN_NAME}.xclbin
NETLAYERDIR = NetLayers/
CMACDIR = Ethernet/
BASICDIR = Basic_kernels/
BENCHMARDIR = Benchmark_kernel/
NETLAYERHLS = 100G-fpga-network-stack-core
POSTSYSLINKTCL ?= $(shell readlink -f ./Ethernet/post_sys_link.tcl)
SWITCH_IP_FOLDER ?= $(shell readlink -f ./$(BENCHMARDIR)/packaged_kernel_switch_wrapper_$(XSA))
LIST_XO = $(NETLAYERDIR)$(TEMP_DIR)/networklayer.xo
CONFIGFLAGS = --config configuration_$(DESIGN)_if$(INTERFACE).tmp.ini
#CONFIGFLAGS += --kernel_frequency 280
# Include cmac kernel depending on the interface
ifeq (3,$(INTERFACE))
LIST_XO += $(CMACDIR)$(TEMP_DIR)/cmac_0.xo
LIST_XO += $(CMACDIR)$(TEMP_DIR)/cmac_1.xo
else
LIST_XO += $(CMACDIR)$(TEMP_DIR)/cmac_$(INTERFACE).xo
endif
LIST_REPOS =
# Include application kernels depending on the design
ifeq (benchmark,$(DESIGN))
LIST_XO += $(BENCHMARDIR)$(TEMP_DIR)/traffic_generator.xo
LIST_XO += $(BENCHMARDIR)$(TEMP_DIR)/collector.xo
LIST_XO += $(BENCHMARDIR)$(TEMP_DIR)/switch_wrapper.xo
LIST_REPOS += --user_ip_repo_paths $(SWITCH_IP_FOLDER)
else
LIST_XO += $(BASICDIR)$(TEMP_DIR)/krnl_mm2s.xo
LIST_XO += $(BASICDIR)$(TEMP_DIR)/krnl_s2mm.xo
endif
# Linker parameters
# Linker userPostSysLinkTcl param
ifeq (u5,$(findstring u5, $(DEVICE)))
HLS_IP_FOLDER = $(shell readlink -f ./$(NETLAYERDIR)$(NETLAYERHLS)/synthesis_results_HBM)
else ifeq (u280,$(findstring u280, $(DEVICE)))
HLS_IP_FOLDER = $(shell readlink -f ./$(NETLAYERDIR)$(NETLAYERHLS)/synthesis_results_HBM)
else ifeq (u2,$(findstring u2, $(DEVICE)))
HLS_IP_FOLDER = $(shell readlink -f ./$(NETLAYERDIR)$(NETLAYERHLS)/synthesis_results_noHBM)
endif
LIST_REPOS += --user_ip_repo_paths $(HLS_IP_FOLDER)
.PHONY: all clean distclean distcleanall
all: check-devices check-vitis check-xrt check-design check-interface create-conf-file $(BINARY_CONTAINERS)
# Cleaning stuff
clean:
rm -rf *v++* *.log *.jou *.str
distclean: clean
rm -rf _x* *.tmp.ini .Xil benchmark*/ basic*/ .ipcache/
distcleanall: distclean
make -C $(NETLAYERDIR) distcleanall
make -C $(CMACDIR) distclean
make -C $(BASICDIR) distclean
make -C $(BENCHMARDIR) distclean
# Building xclbin
$(BUILD_DIR)/${XCLBIN_NAME}.xclbin: $(LIST_XO)
mkdir -p $(BUILD_DIR)
$(VPP) $(CLFLAGS) $(CONFIGFLAGS) --temp_dir $(BUILD_DIR) -l -o'$@' $^ $(LIST_REPOS) -j 8
$(BASICDIR)$(TEMP_DIR)/%.xo: $(BASICDIR)src/*.cpp
make -C $(BASICDIR) all DEVICE=$(DEVICE) -j3
$(BENCHMARDIR)$(TEMP_DIR)/%.xo: $(BENCHMARDIR)src/*
make -C $(BENCHMARDIR) all DEVICE=$(DEVICE) -j3
$(CMACDIR)$(TEMP_DIR)/%.xo:
make -C $(CMACDIR) all DEVICE=$(DEVICE) INTERFACE=$(INTERFACE)
$(NETLAYERDIR)$(TEMP_DIR)/%.xo:
cd ./$(NETLAYERDIR)$(NETLAYERHLS) && git checkout -- .
sed -i 's/define NUMBER_SOCKETS 16/define NUMBER_SOCKETS $(MAX_SOCKETS)/' ./$(NETLAYERDIR)$(NETLAYERHLS)/hls/UDP/udp.hpp
sed -i 's/port=numberSockets/port=numberSockets offset=0x10/' ./$(NETLAYERDIR)$(NETLAYERHLS)/hls/UDP/udp.cpp
cat ./$(NETLAYERDIR)/template.xml | sed 's/UDP_TP_PLACEHOLDER/$(UDP_THEIR_PORT_OFFSET)/' \
| sed 's/UDP_MP_PLACEHOLDER/$(UDP_MY_PORT_OFFSET)/' \
| sed 's/UDP_VL_PLACEHOLDER/$(UDP_VALID_OFFSET)/' > ./$(NETLAYERDIR)/kernel.xml
make -C $(NETLAYERDIR) all DEVICE=$(DEVICE)
check-devices:
ifndef DEVICE
$(error DEVICE not set. Please set the DEVICE properly and rerun. Run "make help" for more details.)
endif
#Checks for XILINX_VITIS
check-vitis:
ifndef XILINX_VITIS
$(error XILINX_VITIS variable is not set, please set correctly and rerun)
endif
#Checks for XILINX_XRT
check-xrt:
ifndef XILINX_XRT
$(error XILINX_XRT variable is not set, please set correctly and rerun)
endif
#Check if the design name is supported
check-design:
@if [[ ($(DESIGN) != "benchmark") && ($(DESIGN) != "basic") ]]; then\
echo "DESIGN=$(DESIGN) is not supported!";\
exit 1;\
fi
check-interface:
@if [[ ($(XSA) =~ "u50") && ($(INTERFACE) != 0) ]]; then\
echo "Platform $(XSA) only has INTERFACE=0!";\
exit 1;\
fi
@if [[ ($(INTERFACE) != 0) && ($(INTERFACE) != 1) && ($(INTERFACE) != 3) ]]; then\
echo "Interface $(INTERFACE) is not supported in platform $(XSA)!";\
exit 1;\
fi
#Create configuration file for current design and settings
create-conf-file:
cp config_files/connectivity_$(DESIGN)_if$(INTERFACE).ini configuration_$(DESIGN)_if$(INTERFACE).tmp.ini
echo "" >> configuration_$(DESIGN)_if$(INTERFACE).tmp.ini
echo "" >> configuration_$(DESIGN)_if$(INTERFACE).tmp.ini
echo "[advanced]" >> configuration_$(DESIGN)_if$(INTERFACE).tmp.ini
echo "param=compiler.userPostSysLinkOverlayTcl=$(POSTSYSLINKTCL)" >> configuration_$(DESIGN)_if$(INTERFACE).tmp.ini
echo "#param=compiler.worstNegativeSlack=-2" >> configuration_$(DESIGN)_if$(INTERFACE).tmp.ini
echo "#param=compiler.errorOnHoldViolation=false" >> configuration_$(DESIGN)_if$(INTERFACE).tmp.ini
echo "[vivado]" >> configuration_$(DESIGN)_if$(INTERFACE).tmp.ini
echo "prop=run.impl_1.strategy=Performance_NetDelay_low" >> configuration_$(DESIGN)_if$(INTERFACE).tmp.ini
@if [[ $(DEVICE) = *"u5"* ]]; then\
sed -i 's/SLR2/SLR1/g' configuration_$(DESIGN)_if$(INTERFACE).tmp.ini;\
sed -i 's/DDR\[1\]/HBM\[0\]/g' configuration_$(DESIGN)_if$(INTERFACE).tmp.ini;\
fi