Step 2: Initial Design and Makefile Exploration
- The vadd directory contains the Makefile file, which you will use to compile the design in both Hardware and Software Emulation, as well as generate a System Run.
- Open the Makefile in a text editor. View the content and become
familiar with how it is written. Makefiles are written in a bash style
syntax.Note: The file itself makes references to generic makefiles that are used by all the Github example designs.
- The first few lines contain
include
statements for other generic makefiles that are used by all the examples.COMMON_REPO:=../../../ include $(COMMON_REPO)/utility/boards.mk include $(COMMON_REPO)/libs/xcl2/xcl2.mk include $(COMMON_REPO)/libs/opencl/opencl.mk
- Open the ../../../utility/boards.mk. This makefile contains the flags and
command line compiler info needed to build the host and source code.
# By Default report is set to none, so report will be generated # 'estimate' for estimate report generation # 'system' for system report generation REPORT:=none # Default C++ Compiler Flags and xocc compiler flags CXXFLAGS:=-Wall -O0 -g CLFLAGS:= --xp "param:compiler.preserveHlsOutput=1" --xp "param:compiler.generateExtraRunData=true" -s ifneq ($(REPORT),none) CLFLAGS += --report $(REPORT) endif
REPORT
is an input flag (parameter) for themake
command in the terminal. Notice that theCLFLAGS
is building a long list ofxocc
command line flags to be used. - Scroll down to line 45 and you will
see:
# By default build for hardware can be set to # hw_emu for hardware emulation # sw_emu for software emulation # or a collection of all or none of these TARGETS:=hw # By default only have one device in the system NUM_DEVICES:=1
Here,
TARGETS
defines what default build to have (if not specified in the makefile command line), by default it is set tohw
(System build). You will be setting this value as desired when working on your own design. Lastly, you can define the number of devices the machine uses that contain the board you selected. Generally, one device is fine to start, but you can change this if your design requires more. - Close the boards.mk file and refocus on the Makefile. Looking at line 9 and beyond, notice that this file handles the majority of where the source code is located, and naming the kernel and application executables.
- Finally, open the ../../../utility/rules.mk file. This file is where all the setup
items from the previous makefiles are handled into creating the xocc and the xcpp (gcc) command line
arguments. Explore this file until you feel comfortable with what it does. Key
areas to focus are labeled with
define make_exe
(line 34) anddefine make_xclbin
(line 107).