-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
146 lines (115 loc) · 5.82 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
# *****************************************************************************
# * cloudFPGA
# * Copyright 2016 -- 2022 IBM Corporation
# * Licensed under the Apache License, Version 2.0 (the "License");
# * you may not use this file except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *----------------------------------------------------------------------------
# * Created : Apr 2020
# * Authors : Dionysios Diamantopoulos
# *
# * Description : A makefile that synthesizes and packages the current HLS core
# * as an IP.
# *
# * Synopsis:
# * make clean : Cleanup of the current directory.
# * make : Runs the default build for this core.
# *
# ******************************************************************************
# Name of the HLS core to build
ipName =sobel
DEPS := $(shell find ./src/ -type f)
.PHONY: all csim cosim_view
all: ${ipName}_prj/solution1/impl/ip
# assert ENVIRONMENT
assert_env:
@echo "This HLS IP Core needs the cFp environment activated....checking..."
@#We need to match the case with and without PR
@( [ -f ../../../../cFDK/SRA/LIB/bash/assert_envs.sh ] && ../../../../cFDK/SRA/LIB/bash/assert_envs.sh ) || ../../../cFDK/SRA/LIB/bash/assert_envs.sh
## Either vivado_hls or vitis_hls
hlstool=vivado_hls
HLS_VERSION := $(shell echo `$(hlstool) -version | head -n 1 | awk '{ print $$11}' | tr -d 'v' | tr -d '.'` | cut -c1-5)
${ipName}_prj/solution1/impl/ip: $(DEPS)
@#rm -rf $@
rm -rf ${ipName}_prj
export hlsSim=0; export hlsCoSim=0; export hlsSyn=1; export hlsVersion=$(HLS_VERSION); $(hlstool) -f run_hls.tcl
@#touch ${ipName}_prj
@touch $@
@touch ../../.ip_guard
CHECK_VIVADO := $(shell command -v vivado 2> /dev/null)
VIVADOBINDIR := `dirname ${CHECK_VIVADO}`
CHECK_VITIS := $(shell command -v vitis 2> /dev/null)
VITISBINDIR := `dirname ${CHECK_VITIS}`
#INPUT_IMAGE = ./test/128x128.png
INPUT_IMAGE ?= ./test/8x8.png
src = ./src/${ipName}.cpp \
./src/xf_sobel_accel.cpp \
./test/test_${ipName}.cpp
obj = $(src:.cpp=.o)
CXXFLAGS = -g -Wall -fstack-check -Wno-reorder -Wno-unknown-pragmas -Wno-attributes \
-D__SDSVHLS__ -std=c++0x -std=c++11 \
-DHLS_VERSION=${HLS_VERSION} \
`pkg-config --libs opencv` `xml2-config --cflags --libs` \
-I$(VIVADOBINDIR)/../include -I$(cFpRootDir)cFDK/SRA/LIB/hls \
-I$(cFpRootDir)Vitis_Libraries/vision/L1/include
LDFLAGS = -lpthread
## Runs fast HLS C simulation using g++ toolchain
fcompile: $(obj)
ifdef CHECK_VIVADO
@echo "Found vivado in $(CHECK_VIVADO)"
@echo "Found hls version $(HLS_VERSION)"
else
@echo Vivado was not found in PATH
endif
ifdef CHECK_VITIS
@echo "Found vitis in $(CHECK_VITIS)"
@echo "Found hls version $(HLS_VERSION)"
else
@echo Vitis was not found in PATH
endif
mkdir -p ./${ipName}_prj
mkdir -p ./${ipName}_prj/solution1
mkdir -p ./${ipName}_prj/solution1/fcsim/
mkdir -p ./${ipName}_prj/solution1/fcsim/build
$(CXX) -o ./${ipName}_prj/solution1/fcsim/build/fcsim $^ $(CXXFLAGS) $(LDFLAGS)
fcsim: fcompile
@make logo
cd ./${ipName}_prj/solution1/fcsim/build && ./$@ ../../../../$(INPUT_IMAGE)
memchecksim: fcompile
cd ./${ipName}_prj/solution1/fcsim/build; valgrind --tool=memcheck --leak-check=full --track-origins=yes ./fcsim ../../../../$(INPUT_IMAGE)
callgraph: fcsim
cd ./${ipName}_prj/solution1/fcsim/build; valgrind --tool=callgrind ./fcsim ../../../../$(INPUT_IMAGE)
kcachegrind: callgraph
kcachegrind ./${ipName}_prj/solution1/fcsim/build/callgrind.out.* &
csynth: assert_env
export hlsSim=0; export hlsCoSim=0; export hlsSyn=1; export hlsVersion=$(HLS_VERSION); $(hlstool) -f run_hls.tcl
csim: assert_env
export hlsSim=1; export hlsCoSim=0; export hlsSyn=0; export hlsVersion=$(HLS_VERSION); export SimFile=../../../../$(INPUT_IMAGE); $(hlstool) -f run_hls.tcl
cosim: assert_env
export hlsSim=0; export hlsCoSim=1; export hlsSyn=0; export hlsVersion=$(HLS_VERSION); export SimFile=../../../../$(INPUT_IMAGE); $(hlstool) -f run_hls.tcl
#@#rm -rf ${ipName}_prj
cosim_view:
@/bin/echo -e "current_fileset\nopen_wave_database $(ipName).wdb\n" > ./$(ipName)_prj/solution1/sim/verilog/open_wave.tcl
cd ./$(ipName)_prj/solution1/sim/verilog/; vivado -source open_wave.tcl
clean:
rm -rf ${ipName}_prj $(obj)
rm -f vivado*.log vivado_pid*.str hs_err_pid*.log csim.log fcsim.log
logo:
@echo " ";
@echo "...build with: ";
@echo " ██████╗███████╗██████╗ ███████╗ ██████╗ ██████╗ ";
@echo "██╔════╝██╔════╝██╔══██╗ ╚══███╔╝██╔═══██╗██╔═══██╗ ";
@echo "██║ █████╗ ██████╔╝ ███╔╝ ██║ ██║██║ ██║ ";
@echo "██║ ██╔══╝ ██╔═══╝ ███╔╝ ██║ ██║██║ ██║ ";
@echo "╚██████╗██║ ██║███████╗███████╗╚██████╔╝╚██████╔╝ ";
@echo " ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝ ╚═════╝ ";
@echo " v1.0 ";
@echo " ";