forked from fpgasystems/Vitis_with_100Gbps_TCP-IP
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhe
committed
Nov 11, 2020
0 parents
commit fda50cf
Showing
409 changed files
with
239,187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(vitis-network) | ||
|
||
# | ||
# Vivado | ||
# | ||
|
||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) | ||
|
||
set(IPREPO_DIR ${CMAKE_BINARY_DIR}/fpga-network-stack/iprepo) | ||
file(MAKE_DIRECTORY ${IPREPO_DIR}) | ||
|
||
# Device | ||
if(FDEV_NAME STREQUAL "u280") | ||
set(FPGA_PART "xcu280-fsvh2892-2L-e" CACHE STRING "FPGA device") | ||
set(NETWORK_BANDWIDTH 100 CACHE STRING "Network bandwidth") | ||
set(NETWORK_INTERFACE 100 CACHE STRING "Network bandwidth") | ||
set(DATA_WIDTH 64 CACHE STRING "Width of data path in bytes") | ||
set(CLOCK_PERIOD 3.2 CACHE STRING "Target clock period in nanoseconds") | ||
set(DEVICE "/opt/xilinx/platforms/xilinx_u280_xdma_201920_3/xilinx_u280_xdma_201920_3.xpfm") | ||
else() | ||
message(FATAL_ERROR "Target device not supported.") | ||
endif() | ||
|
||
# Config | ||
set(TCP_STACK_EN 0 CACHE BOOL "Enable TCP/IP stack") | ||
set(UDP_STACK_EN 1 CACHE BOOL "Enable UDP/IP stack") | ||
set(TCP_STACK_RX_DDR_BYPASS_EN 1 CACHE BOOL "Enabling DDR bypass on the RX path") | ||
|
||
|
||
|
||
|
||
# QSFP port | ||
set(QSFP_PORT 1 CACHE STRING "Network traffic route.") | ||
|
||
# | ||
# Network stack | ||
# | ||
|
||
add_subdirectory(fpga-network-stack) | ||
|
||
|
||
#User kernel IPs | ||
add_subdirectory(kernel/user_krnl/scatter_krnl/src/hls) | ||
add_subdirectory(kernel/user_krnl/iperf_krnl/src/hls) | ||
|
||
# | ||
# Find Vivado | ||
# | ||
|
||
find_package(Vivado REQUIRED) | ||
if (NOT VIVADO_FOUND) | ||
message(FATAL_ERROR "Vivado not found.") | ||
endif() | ||
|
||
#configure_file(${CMAKE_SOURCE_DIR}/scripts/package_network_krnl.tcl.in ${CMAKE_SOURCE_DIR}/scripts/package_network_krnl.tcl) | ||
#configure_file(${CMAKE_SOURCE_DIR}/scripts/package_cmac_krnl.tcl.in ${CMAKE_SOURCE_DIR}/scripts/package_cmac_krnl.tcl) | ||
#configure_file(${CMAKE_SOURCE_DIR}/scripts/package_scatter_krnl.tcl.in ${CMAKE_SOURCE_DIR}/scripts/package_scatter_krnl.tcl) | ||
#configure_file(${CMAKE_SOURCE_DIR}/scripts/package_iperf_krnl.tcl.in ${CMAKE_SOURCE_DIR}/scripts/package_iperf_krnl.tcl) | ||
|
||
configure_file(${CMAKE_SOURCE_DIR}/scripts/post_sys_link.tcl.in ${CMAKE_SOURCE_DIR}/scripts/post_sys_link.tcl) | ||
configure_file(${CMAKE_SOURCE_DIR}/kernel/common/types/network_types.svh.in ${CMAKE_SOURCE_DIR}/kernel/common/types/network_types.svh) | ||
|
||
#add_custom_target(shell COMMAND ${VIVADO_BINARY} -mode tcl -source ${CMAKE_BINARY_DIR}/shell.tcl) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
.PHONY: help | ||
|
||
help:: | ||
$(ECHO) "Makefile Usage:" | ||
$(ECHO) " make all TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> SYSROOT=<sysroot_path> USER_KRNL=<user_krnl_name> USER_KRNL_MODE=<rtl/hls>" | ||
$(ECHO) " Command to generate the design for specified Target and Shell." | ||
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and SYSROOT is required for SoC shells" | ||
$(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) "" | ||
$(ECHO) " make sd_card TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> SYSROOT=<sysroot_path>" | ||
$(ECHO) " Command to prepare sd_card files." | ||
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and SYSROOT is required for SoC shells" | ||
$(ECHO) "" | ||
$(ECHO) " make check TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> SYSROOT=<sysroot_path>" | ||
$(ECHO) " Command to run application in emulation." | ||
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and SYSROOT is required for SoC shells" | ||
$(ECHO) "" | ||
$(ECHO) " make build TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform> HOST_ARCH=<aarch32/aarch64/x86> SYSROOT=<sysroot_path>" | ||
$(ECHO) " Command to build xclbin application." | ||
$(ECHO) " By default, HOST_ARCH=x86. HOST_ARCH and SYSROOT is required for SoC shells" | ||
$(ECHO) "" | ||
|
||
# Points to top directory of Git repository | ||
COMMON_REPO = ./ | ||
PWD = $(shell readlink -f .) | ||
ABS_COMMON_REPO = $(shell readlink -f $(COMMON_REPO)) | ||
|
||
TARGET := hw | ||
HOST_ARCH := x86 | ||
SYSROOT := | ||
DEVICE ?= xilinx_u280_xdma_201920_3 | ||
VITIS_PLATFORM := ${DEVICE} | ||
|
||
|
||
XCLBIN_NAME = network | ||
KRNL_1 := network_krnl | ||
KRNL_2 := ${USER_KRNL} | ||
KRNL_3 := cmac_krnl | ||
|
||
USER_KRNL_MODE ?= rtl | ||
|
||
include ./utils.mk | ||
POSTSYSLINKTCL ?= $(shell readlink -f ./scripts/post_sys_link.tcl) | ||
CONFIGLINKTCL ?= $(shell readlink -f ./scripts/compile.cfg) | ||
|
||
IPREPOPATH ?= ./build/fpga-network-stack/iprepo | ||
|
||
XSA := $(call device2xsa, $(DEVICE)) | ||
TEMP_DIR := ./_x.$(TARGET).$(XSA) | ||
BUILD_DIR := ./build_dir.$(TARGET).$(XSA) | ||
|
||
VPP := $(XILINX_VITIS)/bin/v++ | ||
SDCARD := sd_card | ||
|
||
#Include Libraries | ||
include $(ABS_COMMON_REPO)/common/includes/opencl/opencl.mk | ||
include $(ABS_COMMON_REPO)/common/includes/xcl2/xcl2.mk | ||
CXXFLAGS += $(xcl2_CXXFLAGS) | ||
LDFLAGS += $(xcl2_LDFLAGS) | ||
HOST_SRCS += $(xcl2_SRCS) | ||
include config_$(USER_KRNL_MODE).mk | ||
|
||
CXXFLAGS += $(opencl_CXXFLAGS) -Wall -O0 -g -std=gnu++14 | ||
CXXFLAGS += -DVITIS_PLATFORM=$(VITIS_PLATFORM) | ||
LDFLAGS += $(opencl_LDFLAGS) | ||
|
||
HOST_SRCS += host/${USER_KRNL}/host.cpp | ||
# Host compiler global settings | ||
CXXFLAGS += -fmessage-length=0 | ||
LDFLAGS += -lrt -lstdc++ | ||
|
||
ifneq ($(HOST_ARCH), x86) | ||
LDFLAGS += --sysroot=$(SYSROOT) | ||
endif | ||
|
||
# Kernel compiler global settings | ||
CLFLAGS += -t $(TARGET) --platform $(DEVICE) --save-temps #--config $(CONFIGLINKTCL) | ||
CLFLAGS += --kernel_frequency 250 | ||
ifneq ($(TARGET), hw) | ||
CLFLAGS += -g | ||
endif | ||
|
||
# Linker params | ||
# Linker userPostSysLinkTcl param | ||
#ifeq ($(DEVICE),$(findstring $(DEVICE), u280)) | ||
$(info $$DEVICE is [${DEVICE}]) | ||
$(info $$POSTSYSLINKTCL is [${POSTSYSLINKTCL}]) | ||
CLFLAGS += --advanced.param compiler.userPostSysLinkTcl=$(POSTSYSLINKTCL) #--xp param:compiler.userPostSysLinkTcl=$(POSTSYSLINKTCL) | ||
#CLFLAGS += --dk chipscope:network_krnl_1:m_axis_tcp_open_status --dk chipscope:network_krnl_1:s_axis_tcp_tx_meta --dk chipscope:network_krnl_1:s_axis_tcp_open_connection | ||
CLFLAGS += --config ./kernel/user_krnl/${USER_KRNL}/config_sp_${USER_KRNL}.txt | ||
# CLFLAGS += --profile_kernel stall:${USER_KRNL}:all:all | ||
#endif | ||
|
||
# LDCLFLAGS += --kernel_frequency "0:250|1:250" | ||
# LDCLFLAGS += --profile_kernel stall:${USER_KRNL}:all:all | ||
|
||
EXECUTABLE = ./host/host | ||
CMD_ARGS = $(BUILD_DIR)/${XCLBIN_NAME}.xclbin | ||
EMCONFIG_DIR = $(TEMP_DIR) | ||
EMU_DIR = $(SDCARD)/data/emulation | ||
|
||
BINARY_CONTAINERS += $(BUILD_DIR)/${XCLBIN_NAME}.xclbin | ||
BINARY_CONTAINER_OBJS += $(TEMP_DIR)/${KRNL_1}.xo $(TEMP_DIR)/${KRNL_2}.xo $(TEMP_DIR)/${KRNL_3}.xo | ||
|
||
CP = cp -rf | ||
|
||
.PHONY: all clean cleanall docs emconfig | ||
all: check-devices $(EXECUTABLE) $(BINARY_CONTAINERS) emconfig sd_card | ||
|
||
.PHONY: exe | ||
exe: $(EXECUTABLE) | ||
|
||
.PHONY: build | ||
build: $(BINARY_CONTAINERS) | ||
|
||
# Building kernel | ||
$(BUILD_DIR)/${XCLBIN_NAME}.xclbin: $(BINARY_CONTAINER_OBJS) | ||
mkdir -p $(BUILD_DIR) | ||
$(VPP) $(CLFLAGS) --temp_dir $(BUILD_DIR) -l $(LDCLFLAGS) -o'$@' $(+) | ||
|
||
# Building Host | ||
.PHONY: compile | ||
compile: $(EXECUTABLE) | ||
$(EXECUTABLE): check-xrt $(HOST_SRCS) $(HOST_HDRS) | ||
$(CXX) $(CXXFLAGS) $(HOST_SRCS) $(HOST_HDRS) -o '$@' $(LDFLAGS) | ||
|
||
emconfig:$(EMCONFIG_DIR)/emconfig.json | ||
$(EMCONFIG_DIR)/emconfig.json: | ||
emconfigutil --platform $(DEVICE) --od $(EMCONFIG_DIR) | ||
|
||
check: all | ||
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu)) | ||
ifeq ($(HOST_ARCH), x86) | ||
$(CP) $(EMCONFIG_DIR)/emconfig.json . | ||
XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(BUILD_DIR)/${XCLBIN_NAME}.xclbin | ||
else | ||
mkdir -p $(EMU_DIR) | ||
$(CP) $(XILINX_VITIS)/data/emulation/unified $(EMU_DIR) | ||
mkfatimg $(SDCARD) $(SDCARD).img 500000 | ||
launch_emulator -no-reboot -runtime ocl -t $(TARGET) -sd-card-image $(SDCARD).img -device-family $(DEV_FAM) | ||
endif | ||
else | ||
ifeq ($(HOST_ARCH), x86) | ||
./$(EXECUTABLE) $(BUILD_DIR)/${XCLBIN_NAME}.xclbin | ||
endif | ||
endif | ||
ifneq ($(TARGET),$(findstring $(TARGET), hw hw_emu)) | ||
$(warning WARNING:Application supports only hw hw_emu TARGET. Please use the target for running the application) | ||
endif | ||
|
||
|
||
ifeq ($(HOST_ARCH), x86) | ||
perf_analyze profile -i profile_summary.csv -f html | ||
endif | ||
|
||
sd_card: $(EXECUTABLE) $(BINARY_CONTAINERS) emconfig | ||
ifneq ($(HOST_ARCH), x86) | ||
mkdir -p $(SDCARD)/$(BUILD_DIR) | ||
$(CP) $(B_NAME)/sw/$(XSA)/boot/generic.readme $(B_NAME)/sw/$(XSA)/xrt/image/* xrt.ini $(EXECUTABLE) $(SDCARD) | ||
$(CP) $(BUILD_DIR)/*.xclbin $(SDCARD)/$(BUILD_DIR)/ | ||
ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu)) | ||
$(ECHO) 'cd /mnt/' >> $(SDCARD)/init.sh | ||
$(ECHO) 'export XILINX_VITIS=$$PWD' >> $(SDCARD)/init.sh | ||
$(ECHO) 'export XCL_EMULATION_MODE=$(TARGET)' >> $(SDCARD)/init.sh | ||
$(ECHO) './$(EXECUTABLE) $(CMD_ARGS)' >> $(SDCARD)/init.sh | ||
$(ECHO) 'reboot' >> $(SDCARD)/init.sh | ||
else | ||
[ -f $(SDCARD)/BOOT.BIN ] && echo "INFO: BOOT.BIN already exists" || $(CP) $(BUILD_DIR)/sd_card/BOOT.BIN $(SDCARD)/ | ||
$(ECHO) './$(EXECUTABLE) $(CMD_ARGS)' >> $(SDCARD)/init.sh | ||
endif | ||
endif | ||
|
||
# Cleaning stuff | ||
clean: | ||
-$(RMDIR) $(EXECUTABLE) $(XCLBIN)/{*sw_emu*,*hw_emu*} | ||
-$(RMDIR) profile_* TempConfig system_estimate.xtxt *.rpt *.csv .run | ||
-$(RMDIR) src/*.ll *v++* .Xil emconfig.json dltmp* xmltmp* *.log *.jou *.wcfg *.wdb | ||
|
||
cleanall: clean | ||
-$(RMDIR) build_dir* sd_card* | ||
-$(RMDIR) _x.* *xclbin.run_summary qemu-memory-_* emulation/ _vimage/ pl* start_simulation.sh *.xclbin | ||
-$(RMDIR) ./tmp_kernel_pack* ./packaged_kernel* | ||
|
||
|
Oops, something went wrong.