|
| 1 | +############################## Help Section ############################## |
| 2 | +.PHONY: help |
| 3 | + |
| 4 | +help:: |
| 5 | + $(ECHO) "Makefile Usage:" |
| 6 | + $(ECHO) " make all TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> EDGE_COMMON_SW=<rootfs and kernel image path>" |
| 7 | + $(ECHO) " Command to generate the design for specified Target and Shell." |
| 8 | + $(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and EDGE_COMMON_SW is required for SoC shells" |
| 9 | + $(ECHO) "" |
| 10 | + $(ECHO) " make clean " |
| 11 | + $(ECHO) " Command to remove the generated non-hardware files." |
| 12 | + $(ECHO) "" |
| 13 | + $(ECHO) " make cleanall" |
| 14 | + $(ECHO) " Command to remove all the generated files." |
| 15 | + $(ECHO) "" |
| 16 | + $(ECHO) " make test DEVICE=<FPGA platform>" |
| 17 | + $(ECHO) " Command to run the application. This is same as 'check' target but does not have any makefile dependency." |
| 18 | + $(ECHO) "" |
| 19 | + $(ECHO) " make sd_card TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> EDGE_COMMON_SW=<rootfs and kernel image path>" |
| 20 | + $(ECHO) " Command to prepare sd_card files." |
| 21 | + $(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and EDGE_COMMON_SW is required for SoC shells" |
| 22 | + $(ECHO) "" |
| 23 | + $(ECHO) " make check TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> EDGE_COMMON_SW=<rootfs and kernel image path>" |
| 24 | + $(ECHO) " Command to run application in emulation." |
| 25 | + $(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and EDGE_COMMON_SW is required for SoC shells" |
| 26 | + $(ECHO) "" |
| 27 | + $(ECHO) " make build TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> EDGE_COMMON_SW=<rootfs and kernel image path>" |
| 28 | + $(ECHO) " Command to build xclbin application." |
| 29 | + $(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and EDGE_COMMON_SW is required for SoC shells" |
| 30 | + $(ECHO) "" |
| 31 | + |
| 32 | +############################## Setting up Project Variables ############################## |
| 33 | +# Points to top directory of Git repository |
| 34 | +COMMON_REPO = ../../ |
| 35 | +PWD = $(shell readlink -f .) |
| 36 | +ABS_COMMON_REPO = $(shell readlink -f $(COMMON_REPO)) |
| 37 | + |
| 38 | +TARGET := hw |
| 39 | +HOST_ARCH := x86 |
| 40 | +SYSROOT := |
| 41 | + |
| 42 | +include ./utils.mk |
| 43 | + |
| 44 | +XSA := $(call device2xsa, $(DEVICE)) |
| 45 | +TEMP_DIR := ./_x.$(TARGET).$(XSA) |
| 46 | +BUILD_DIR := ./build_dir.$(TARGET).$(XSA) |
| 47 | + |
| 48 | +# SoC variables |
| 49 | +RUN_APP_SCRIPT = run_app.sh |
| 50 | +PACKAGE_OUT = package.$(TARGET) |
| 51 | + |
| 52 | +LAUNCH_EMULATOR = $(PACKAGE_OUT)/launch_$(TARGET).sh |
| 53 | +RESULT_STRING = TEST PASSED |
| 54 | + |
| 55 | +VPP := v++ |
| 56 | +SDCARD := sd_card |
| 57 | + |
| 58 | +#Include Libraries |
| 59 | +include $(ABS_COMMON_REPO)/common/includes/opencl/opencl.mk |
| 60 | +include $(ABS_COMMON_REPO)/common/includes/xcl2/xcl2.mk |
| 61 | +CXXFLAGS += $(xcl2_CXXFLAGS) |
| 62 | +LDFLAGS += $(xcl2_LDFLAGS) |
| 63 | +HOST_SRCS += $(xcl2_SRCS) |
| 64 | +CXXFLAGS += $(opencl_CXXFLAGS) -Wall -O0 -g -std=c++11 |
| 65 | +LDFLAGS += $(opencl_LDFLAGS) |
| 66 | + |
| 67 | +############################## Setting up Host Variables ############################## |
| 68 | +#Include Required Host Source Files |
| 69 | +HOST_SRCS += src/host.cpp |
| 70 | + |
| 71 | +# Host compiler global settings |
| 72 | +CXXFLAGS += -fmessage-length=0 |
| 73 | +LDFLAGS += -lrt -lstdc++ |
| 74 | + |
| 75 | +ifneq ($(HOST_ARCH), x86) |
| 76 | + LDFLAGS += --sysroot=$(SYSROOT) |
| 77 | +endif |
| 78 | + |
| 79 | +############################## Setting up Kernel Variables ############################## |
| 80 | +# Kernel compiler global settings |
| 81 | +CLFLAGS += -t $(TARGET) --platform $(DEVICE) --save-temps |
| 82 | +ifneq ($(TARGET), hw) |
| 83 | + CLFLAGS += -g |
| 84 | +endif |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | +# Adding config files to linker |
| 89 | +LDCLFLAGS_krnl_vaddmul += --config krnl_vaddmul.ini |
| 90 | +EXECUTABLE = host |
| 91 | +CMD_ARGS = $(BUILD_DIR)/krnl_vaddmul.xclbin |
| 92 | +EMCONFIG_DIR = $(TEMP_DIR) |
| 93 | +EMU_DIR = $(SDCARD)/data/emulation |
| 94 | + |
| 95 | +############################## Declaring Binary Containers ############################## |
| 96 | +BINARY_CONTAINERS += $(BUILD_DIR)/krnl_vaddmul.xclbin |
| 97 | +BINARY_CONTAINER_krnl_vaddmul_OBJS += $(TEMP_DIR)/krnl_vaddmul.xo |
| 98 | + |
| 99 | +############################## Setting Targets ############################## |
| 100 | +CP = cp -rf |
| 101 | + |
| 102 | +.PHONY: all clean cleanall docs emconfig |
| 103 | +all: check-devices $(EXECUTABLE) $(BINARY_CONTAINERS) emconfig sd_card |
| 104 | + |
| 105 | +.PHONY: exe |
| 106 | +exe: $(EXECUTABLE) |
| 107 | + |
| 108 | +.PHONY: build |
| 109 | +build: check-vitis $(BINARY_CONTAINERS) |
| 110 | + |
| 111 | +############################## Setting Rules for Binary Containers (Building Kernels) ############################## |
| 112 | +$(TEMP_DIR)/krnl_vaddmul.xo: src/krnl_vaddmul.cpp |
| 113 | + mkdir -p $(TEMP_DIR) |
| 114 | + $(VPP) $(CLFLAGS) --temp_dir $(TEMP_DIR) -c -k krnl_vaddmul -I'$(<D)' -o'$@' '$<' |
| 115 | +$(BUILD_DIR)/krnl_vaddmul.xclbin: $(BINARY_CONTAINER_krnl_vaddmul_OBJS) |
| 116 | + mkdir -p $(BUILD_DIR) |
| 117 | + $(VPP) $(CLFLAGS) --temp_dir $(BUILD_DIR) -l $(LDCLFLAGS) $(LDCLFLAGS_krnl_vaddmul) -o'$@' $(+) |
| 118 | + |
| 119 | +############################## Setting Rules for Host (Building Host Executable) ############################## |
| 120 | +$(EXECUTABLE): check-xrt $(HOST_SRCS) $(HOST_HDRS) |
| 121 | + $(CXX) $(CXXFLAGS) $(HOST_SRCS) $(HOST_HDRS) -o '$@' $(LDFLAGS) |
| 122 | + |
| 123 | +emconfig:$(EMCONFIG_DIR)/emconfig.json |
| 124 | +$(EMCONFIG_DIR)/emconfig.json: |
| 125 | + emconfigutil --platform $(DEVICE) --od $(EMCONFIG_DIR) |
| 126 | + |
| 127 | +############################## Setting Essential Checks and Running Rules ############################## |
| 128 | +check: all |
| 129 | +ifeq ($(findstring u200, $(DEVICE)), u200) |
| 130 | +$(error This example is not supported for $(DEVICE)) |
| 131 | +endif |
| 132 | +ifeq ($(findstring zc, $(DEVICE)), zc) |
| 133 | +$(error This example is not supported for $(DEVICE)) |
| 134 | +endif |
| 135 | +ifeq ($(findstring vck, $(DEVICE)), vck) |
| 136 | +$(error This example is not supported for $(DEVICE)) |
| 137 | +endif |
| 138 | +ifeq ($(findstring u250, $(DEVICE)), u250) |
| 139 | +$(error This example is not supported for $(DEVICE)) |
| 140 | +endif |
| 141 | +ifeq ($(findstring aws, $(DEVICE)), aws) |
| 142 | +$(error This example is not supported for $(DEVICE)) |
| 143 | +endif |
| 144 | +ifeq ($(findstring samsung, $(DEVICE)), samsung) |
| 145 | +$(error This example is not supported for $(DEVICE)) |
| 146 | +endif |
| 147 | + |
| 148 | +ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu)) |
| 149 | +ifeq ($(HOST_ARCH), x86) |
| 150 | + $(CP) $(EMCONFIG_DIR)/emconfig.json . |
| 151 | + XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(BUILD_DIR)/krnl_vaddmul.xclbin |
| 152 | +else |
| 153 | + $(ABS_COMMON_REPO)/common/utility/run_emulation.pl "./${LAUNCH_EMULATOR} | tee run_app.log" "./${RUN_APP_SCRIPT} $(TARGET)" "${RESULT_STRING}" "7" |
| 154 | +endif |
| 155 | +else |
| 156 | +ifeq ($(HOST_ARCH), x86) |
| 157 | + ./$(EXECUTABLE) $(BUILD_DIR)/krnl_vaddmul.xclbin |
| 158 | +endif |
| 159 | +endif |
| 160 | + |
| 161 | + |
| 162 | +############################## Setting Essential Checks and Running Rules ############################## |
| 163 | +run: all |
| 164 | +ifeq ($(findstring u200, $(DEVICE)), u200) |
| 165 | +$(error This example is not supported for $(DEVICE)) |
| 166 | +endif |
| 167 | +ifeq ($(findstring zc, $(DEVICE)), zc) |
| 168 | +$(error This example is not supported for $(DEVICE)) |
| 169 | +endif |
| 170 | +ifeq ($(findstring vck, $(DEVICE)), vck) |
| 171 | +$(error This example is not supported for $(DEVICE)) |
| 172 | +endif |
| 173 | +ifeq ($(findstring u250, $(DEVICE)), u250) |
| 174 | +$(error This example is not supported for $(DEVICE)) |
| 175 | +endif |
| 176 | +ifeq ($(findstring aws, $(DEVICE)), aws) |
| 177 | +$(error This example is not supported for $(DEVICE)) |
| 178 | +endif |
| 179 | +ifeq ($(findstring samsung, $(DEVICE)), samsung) |
| 180 | +$(error This example is not supported for $(DEVICE)) |
| 181 | +endif |
| 182 | + |
| 183 | +ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu)) |
| 184 | +ifeq ($(HOST_ARCH), x86) |
| 185 | + $(CP) $(EMCONFIG_DIR)/emconfig.json . |
| 186 | + XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(BUILD_DIR)/krnl_vaddmul.xclbin |
| 187 | +else |
| 188 | + $(ABS_COMMON_REPO)/common/utility/run_emulation.pl "./${LAUNCH_EMULATOR} | tee run_app.log" "./${RUN_APP_SCRIPT} $(TARGET)" "${RESULT_STRING}" "7" |
| 189 | +endif |
| 190 | +else |
| 191 | +ifeq ($(HOST_ARCH), x86) |
| 192 | + ./$(EXECUTABLE) $(BUILD_DIR)/krnl_vaddmul.xclbin |
| 193 | +endif |
| 194 | +endif |
| 195 | + |
| 196 | +.PHONY: test |
| 197 | +test: $(EXECUTABLE) |
| 198 | +ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu)) |
| 199 | +ifeq ($(HOST_ARCH), x86) |
| 200 | + XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(BUILD_DIR)/krnl_vaddmul.xclbin |
| 201 | +else |
| 202 | + $(ABS_COMMON_REPO)/common/utility/run_emulation.pl "./${LAUNCH_EMULATOR} | tee embedded_run.log" "./${RUN_APP_SCRIPT} $(TARGET)" "${RESULT_STRING}" "7" |
| 203 | +endif |
| 204 | +else |
| 205 | +ifeq ($(HOST_ARCH), x86) |
| 206 | + ./$(EXECUTABLE) $(BUILD_DIR)/krnl_vaddmul.xclbin |
| 207 | +else |
| 208 | + $(ECHO) "Please copy the content of sd_card folder and data to an SD Card and run on the board" |
| 209 | +endif |
| 210 | +endif |
| 211 | + |
| 212 | + |
| 213 | +############################## Preparing sdcard ############################## |
| 214 | +sd_card: gen_run_app |
| 215 | +ifneq ($(HOST_ARCH), x86) |
| 216 | + $(VPP) -t $(TARGET) --platform $(DEVICE) -p $(BUILD_DIR)/krnl_vaddmul.xclbin --package.out_dir $(PACKAGE_OUT) --package.rootfs $(EDGE_COMMON_SW)/rootfs.ext4 --package.sd_file $(SD_IMAGE_FILE) --package.sd_file xrt.ini --package.sd_file $(RUN_APP_SCRIPT) --package.sd_file $(EXECUTABLE) -o krnl_vaddmul.xclbin |
| 217 | +endif |
| 218 | + |
| 219 | +############################## Cleaning Rules ############################## |
| 220 | +# Cleaning stuff |
| 221 | +clean: |
| 222 | + -$(RMDIR) $(EXECUTABLE) $(XCLBIN)/{*sw_emu*,*hw_emu*} |
| 223 | + -$(RMDIR) profile_* TempConfig system_estimate.xtxt *.rpt *.csv |
| 224 | + -$(RMDIR) src/*.ll *v++* .Xil emconfig.json dltmp* xmltmp* *.log *.jou *.wcfg *.wdb |
| 225 | + |
| 226 | +cleanall: clean |
| 227 | + -$(RMDIR) build_dir* sd_card* |
| 228 | + -$(RMDIR) package.* |
| 229 | + -$(RMDIR) _x* *xclbin.run_summary qemu-memory-_* emulation/ _vimage/ pl* start_simulation.sh *.xclbin |
0 commit comments