Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
surangamh committed Aug 25, 2021
0 parents commit 45e31d7
Show file tree
Hide file tree
Showing 1,348 changed files with 2,511,882 additions and 0 deletions.
28 changes: 28 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2020, Xilinx, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.// Copyright (c) 2020 Xilinx, Inc.
148 changes: 148 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
SHELL := /bin/bash
.PHONY: help

help:
@echo "Makefile Usage:"
@echo " make all INTERFACE=<CMAC Interface (0 or 1)> JOBS=<number of jobs>"
@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 ""

SYSROOT :=
HOST_ARCH := x86
DEVICE ?= xilinx_u280_xdma_201920_3
INTERFACE ?= 0
JOBS ?= 8
XCLBIN_NAME ?= demo_if$(INTERFACE)

include ./utils.mk


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 := ./build_hw_if$(INTERFACE)
HOST_BUILD_DIR := ./host/build_sw_if$(INTERFACE)
BINARY_CONTAINERS = $(BUILD_DIR)/${XCLBIN_NAME}.xclbin

COMMON_REPO = ./
PWD = $(shell readlink -f .)
ABS_COMMON_REPO = $(shell readlink -f $(COMMON_REPO))

#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)
SENDER_HOST_SRCS += $(xcl2_SRCS)
RECEIVER_HOST_SRCS += $(xcl2_SRCS)
CXXFLAGS += $(opencl_CXXFLAGS) -Wall -O0 -g -std=gnu++14
CXXFLAGS += -DVITIS_PLATFORM=$(VITIS_PLATFORM)
LDFLAGS += $(opencl_LDFLAGS)
SENDER_HOST_SRCS += host/fileops.cpp
RECEIVER_HOST_SRCS += host/fileops.cpp
SENDER_HOST_SRCS += host/host_sender_if$(INTERFACE).cpp
RECEIVER_HOST_SRCS += host/host_receiver_if$(INTERFACE).cpp

# Host compiler global settings
CXXFLAGS += -fmessage-length=0
LDFLAGS += -lrt -lstdc++

ifneq ($(HOST_ARCH), x86)
LDFLAGS += --sysroot=$(SYSROOT)
endif

LDFLAGS+= -lOpenCL -luuid -lxrt_core -lxilinxopencl

SENDER_EXECUTABLE = $(HOST_BUILD_DIR)/host_sender_if$(INTERFACE)
RECEIVER_EXECUTABLE = $(HOST_BUILD_DIR)/host_receiver_if$(INTERFACE)
CMD_ARGS = $(BUILD_DIR)/${XCLBIN_NAME}.xclbin

NETLAYERDIR = ./networklayer/
CMACDIR = ./cmac/
USERKRNLDIR = ./user_krnl/


POSTSYSLINKTCL ?= $(shell readlink -f ./post_sys_link.tcl)

LIST_XO = $(NETLAYERDIR)networklayer.xo
CONFIGFLAGS := --config connectivity_if$(INTERFACE).tmp.ini

# Include cmac kernel depending on the interface

LIST_XO += $(CMACDIR)cmac_$(INTERFACE).xo


# Include application kernels depending on the design
LIST_XO += $(USERKRNLDIR)xofiles/txkrnl.xo
LIST_XO += $(USERKRNLDIR)xofiles/rxkrnl.xo

# Linker params
# Linker userPostSysLinkTcl param
HLS_IP_FOLDER = $(shell readlink -f ./$(NETLAYERDIR)synthesis_results_HMB)
LIST_REPOS := --user_ip_repo_paths $(HLS_IP_FOLDER)


.PHONY: all clean cleanall
all: check-devices check-vitis check-xrt create-conf-file $(SENDER_EXECUTABLE) $(RECEIVER_EXECUTABLE) $(BINARY_CONTAINERS)

# Cleaning stuff
clean:
rm -rf *v++* *.log *.jou *.str host/build*

cleanall: clean
rm -rf _x* .Xil .ipcache/ *.info *.link_summary *.ltx *.xclbin ./build* ./connectivity*


# Building kernel
$(BUILD_DIR)/${XCLBIN_NAME}.xclbin:
mkdir -p $(BUILD_DIR)
make -C $(USERKRNLDIR) all DEVICE=$(DEVICE)
export [email protected]
$(VPP) $(CLFLAGS) $(CONFIGFLAGS) --temp_dir $(BUILD_DIR) -l -o'$@' $(LIST_XO) $(LIST_REPOS) -j $(JOBS)

.PHONY: exe
exe: $(SENDER_EXECUTABLE) $(RECEIVER_EXECUTABLE)

# Building Host
.PHONY: compile
compile: $(SENDER_EXECUTABLE)
$(SENDER_EXECUTABLE): check-xrt $(SENDER_HOST_SRCS) $(HOST_HDRS)
mkdir -p $(HOST_BUILD_DIR)
$(CXX) $(CXXFLAGS) $(SENDER_HOST_SRCS) $(HOST_HDRS) -o '$@' $(LDFLAGS)

compile: $(RECEIVER_EXECUTABLE)
$(RECEIVER_EXECUTABLE): check-xrt $(RECEIVER_HOST_SRCS) $(HOST_HDRS)
$(CXX) $(CXXFLAGS) $(RECEIVER_HOST_SRCS) $(HOST_HDRS) -o '$@' $(LDFLAGS)


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

create-conf-file:
cp config_files/connectivity_if$(INTERFACE).ini connectivity_if$(INTERFACE).tmp.ini
echo "" >> connectivity_if$(INTERFACE).tmp.ini
echo "" >> connectivity_if$(INTERFACE).tmp.ini
echo "[advanced]" >> connectivity_if$(INTERFACE).tmp.ini
echo "param=compiler.userPostSysLinkOverlayTcl=$(POSTSYSLINKTCL)" >> connectivity_if$(INTERFACE).tmp.ini
echo "#param=compiler.worstNegativeSlack=-2" >> connectivity_if$(INTERFACE).tmp.ini

Binary file added cmac/cmac_0.xo
Binary file not shown.
Binary file added cmac/cmac_1.xo
Binary file not shown.
124 changes: 124 additions & 0 deletions common/includes/bitmap/bitmap.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/**********
Copyright (c) 2019, Xilinx, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********/
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include <iostream>

#include "bitmap.h"

BitmapInterface::BitmapInterface(const char *f) : filename(f) {
core = NULL;
dib = NULL;
image = NULL;

magicNumber = 0;
fileSize = 0;
offsetOfImage = 0;

sizeOfDIB = 0;
sizeOfImage = 0;

height = -1;
width = -1;
}

BitmapInterface::~BitmapInterface() {
if (core != NULL)
delete[] core;
if (dib != NULL)
delete[] dib;
if (image != NULL)
delete[] image;
}

bool BitmapInterface::readBitmapFile() {
// First, open the bitmap file
int fd;
unsigned int fileSize;

fd = open(filename, O_RDONLY);
if (fd < 0) {
std::cerr << "Cannot read image file " << filename << std::endl;
return false;
}

core = new char[14];
read(fd, core, 14);
magicNumber = (*(unsigned short *)(&(core[0])));
fileSize = (*(unsigned int *)(&(core[2])));
offsetOfImage = (*(unsigned int *)(&(core[10])));

// Just read in the DIB, but don't process it
sizeOfDIB = offsetOfImage - 14;
dib = new char[sizeOfDIB];
read(fd, dib, sizeOfDIB);

width = (*(int *)(&(dib[4])));
height = (*(int *)(&(dib[8])));

sizeOfImage = fileSize - 14 - sizeOfDIB;
int numPixels = sizeOfImage / 3; // RGB

image = new int[numPixels];

for (int i = 0; i < numPixels; ++i) {
// Use an integer for every pixel even though we might not need that
// much space (padding 0 bits in the rest of the integer)
image[i] = 0;
read(fd, &(image[i]), 3);
}

return true;
}

bool BitmapInterface::writeBitmapFile(int *otherImage) {
int fd;
fd = open("output.bmp", O_WRONLY | O_CREAT, 0644);

if (fd < 0) {
std::cerr << "Cannot open output.bmp for writing!" << std::endl;
return false;
}

write(fd, core, 14);
write(fd, dib, sizeOfDIB);

int numPixels = sizeOfImage / 3;

int *outputImage = otherImage != NULL ? otherImage : image;

for (int i = 0; i < numPixels; ++i) {
write(fd, &(outputImage[i]), 3);
}

return true;
}
68 changes: 68 additions & 0 deletions common/includes/bitmap/bitmap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**********
Copyright (c) 2019, Xilinx, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********/
#ifndef BITMAP_DOT_H
#define BITMAP_DOT_H

#include <stdlib.h>

class BitmapInterface
{
private:
char* core ;
char* dib ;
const char* filename ;
int* image ;

// Core header information
unsigned short magicNumber ;
unsigned int fileSize ;
unsigned int offsetOfImage ;

// DIB information
int sizeOfDIB ;
int sizeOfImage ;
int height ;
int width ;

public:
BitmapInterface(const char* f) ;
~BitmapInterface() ;

bool readBitmapFile() ;
bool writeBitmapFile(int* otherImage = NULL);

inline int* bitmap() { return image ; }
unsigned int numPixels() { return sizeOfImage/3 ; }

inline int getHeight() { return height ; }
inline int getWidth() { return width ; }

} ;

#endif
3 changes: 3 additions & 0 deletions common/includes/bitmap/bitmap.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bitmap_SRCS:=${COMMON_REPO}/common/includes/bitmap/bitmap.cpp
bitmap_HDRS:=${COMMON_REPO}/common/includes/bitmap/bitmap.h
bitmap_CXXFLAGS:=-I${COMMON_REPO}/common/includes/bitmap
Loading

0 comments on commit 45e31d7

Please sign in to comment.