This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
296 lines (237 loc) · 8.68 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
include ./hardware_config
CPU ?= ariane
ARCH ?= riscv
EXE_EXTENSION=
ifdef DO_CROSS_COMPILATION
CROSS_COMPILE ?= riscv64-unknown-linux-gnu-
TOOLCHAIN_PREFIX ?= $(RISCV_BIN_DIR)/riscv64-unknown-linux-gnu-
EXE_EXTENSION=-RV
endif
ifdef COMPILE_TO_ESP
$(info $$ESP_ROOT is [${ESP_ROOT}])
#ESP_ROOT ?= $(realpath ../../esp)
ESP_ROOT ?=
$(info $$ESP_ROOT is [${ESP_ROOT}])
ESP_DRIVERS ?= $(ESP_ROOT)/soft/common/drivers
ESP_DRV_LINUX = $(ESP_DRIVERS)/linux
endif
CC = gcc -std=c99
INCDIR ?=
INCDIR += -I./include
ifdef COMPILE_TO_ESP
INCDIR += -I$(ESP_DRIVERS)/common/include
INCDIR += -I$(ESP_DRIVERS)/linux/include
endif
CFLAGS ?= -O2 -g
CFLAGS += $(INCDIR)
CFLAGS += -DINT_TIME
ifdef COMPILE_TO_ESP
CFLAGS += -DCOMPILE_TO_ESP
endif
# -- ALWAYS use this one! -- ifdef CONFIG_ESP_INTERFACE
CFLAGS += -DUSE_ESP_INTERFACE
# endif
SW_STR = -SW
FA_STR =
VA_STR =
CONFIG_WHICH_FFT_TYPE ?= 2
ifdef CONFIG_FFT_EN
SW_STR = -HW
FA_STR = -F$(CONFIG_FFT_ACCEL_VER)
CFLAGS += -DHW_FFT -DUSE_FFT_ACCEL_TYPE=$(CONFIG_WHICH_FFT_TYPE)
CFLAGS += -DUSE_FFT_FX=$(CONFIG_FFT_FX)
CFLAGS += -DFFT_DEVICE_NUM=0
endif
ifdef CONFIG_FFT_BITREV
CFLAGS += -DHW_FFT_BITREV
endif
ifdef CONFIG_VITERBI_EN
SW_STR = -HW
VA_STR = -V
CFLAGS += -DHW_VIT
CFLAGS += -DVIT_DEVICE_NUM=0
endif
ifdef CONFIG_KERAS_CV_BYPASS
CA_STR = -Cbp
CFLAGS += -DBYPASS_KERAS_CV_CODE
endif
ifdef CONFIG_CV_CNN_EN
SW_STR = -HW
CA_STR = -C
CFLAGS += -DHW_CV -DENABLE_NVDLA
NVDLA_MODULE = hpvm-mod.nvdla
endif
ifdef CONFIG_VERBOSE
CFLAGS += -DVERBOSE
endif
ifdef CONFIG_GDB
CFLAGS += -g
endif
LDLIBS ?=
ifdef COMPILE_TO_ESP
LDLIBS += -L$(ESP_BUILD_DRIVERS)/contig_alloc
LDLIBS += -L$(ESP_BUILD_DRIVERS)/test
LDLIBS += -L$(ESP_BUILD_DRIVERS)/libesp
endif
LDLIBS += -L./
LDFLAGS ?=
LDFLAGS += -lm
LDFLAGS += -lpthread
ifdef COMPILE_TO_ESP
LDFLAGS += -lrt
LDFLAGS += -lesp
LDFLAGS += -ltest
LDFLAGS += -lcontig
endif
SRC = src/calculate_dist_from_fmcw.c \
src/descrambler_function.c \
src/fft.c \
src/getopt.c \
src/kernels_api.c \
src/main.c \
src/octave.c \
src/timer.c \
src/viterbi_flat.c \
src/viterbi_parms.c
SRC_T = $(SRC) src/read_trace.c
SRC_S = $(SRC) src/sim_environs.c
HDR = $(wildcard include/*.h)
OBJ_T = $(SRC_T:src/%.c=obj_t/%.o)
OBJ_S = $(SRC_S:src/%.c=obj_s/%.o)
VPATH = ./src
TARGET_T=mini-era$(EXE_EXTENSION)$(SW_STR)$(FA_STR)$(VA_STR)$(CA_STR).exe
TARGET_S=sim-$(TARGET_T)
ALL_OBJ_DIR=obj_t obj_s
all: esp-libs $(ALL_OBJ_DIR) $(TARGET_T) $(TARGET_S)
ESP_BUILD_DRIVERS = esp-build/drivers
esp-build:
@mkdir -p $(ESP_BUILD_DRIVERS)/contig_alloc
@mkdir -p $(ESP_BUILD_DRIVERS)/esp
@mkdir -p $(ESP_BUILD_DRIVERS)/esp_cache
@mkdir -p $(ESP_BUILD_DRIVERS)/libesp
@mkdir -p $(ESP_BUILD_DRIVERS)/probe
@mkdir -p $(ESP_BUILD_DRIVERS)/test
@mkdir -p $(ESP_BUILD_DRIVERS)/utils/baremetal
@mkdir -p $(ESP_BUILD_DRIVERS)/utils/linux
@ln -sf $(ESP_DRV_LINUX)/contig_alloc/* $(ESP_BUILD_DRIVERS)/contig_alloc
@ln -sf $(ESP_DRV_LINUX)/esp/* $(ESP_BUILD_DRIVERS)/esp
@ln -sf $(ESP_DRV_LINUX)/esp_cache/* $(ESP_BUILD_DRIVERS)/esp_cache
@ln -sf $(ESP_DRV_LINUX)/driver.mk $(ESP_BUILD_DRIVERS)
@ln -sf $(ESP_DRV_LINUX)/include $(ESP_BUILD_DRIVERS)
@ln -sf $(ESP_DRV_LINUX)/../common $(ESP_BUILD_DRIVERS)/../common
esp-build-clean:
esp-build-distclean: esp-build-clean
$(QUIET_CLEAN)$(RM) -rf esp-build
ifdef COMPILE_TO_ESP
esp-libs: esp-build
CROSS_COMPILE=$(CROSS_COMPILE) DRIVERS=$(ESP_DRV_LINUX) $(MAKE) -C $(ESP_BUILD_DRIVERS)/contig_alloc/ libcontig.a
cd $(ESP_BUILD_DRIVERS)/test; CROSS_COMPILE=$(CROSS_COMPILE) BUILD_PATH=$$PWD $(MAKE) -C $(ESP_DRV_LINUX)/test
cd $(ESP_BUILD_DRIVERS)/libesp; CROSS_COMPILE=$(CROSS_COMPILE) BUILD_PATH=$$PWD $(MAKE) -C $(ESP_DRV_LINUX)/libesp
cd $(ESP_BUILD_DRIVERS)/utils; CROSS_COMPILE=$(CROSS_COMPILE) BUILD_PATH=$$PWD $(MAKE) -C $(ESP_DRV_LINUX)/utils
else
esp-libs:
endif
.PHONY: esp-build-clean esp-build-distclean esp-libs
#------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------
CUR_DIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
$(info $$CUR_DIR is [${CUR_DIR}])
ROOT := $(CUR_DIR)/sw/umd
TOP := $(ROOT)
$(info $$ROOT is [${ROOT}])
ESP_NVDLA_DIR = esp_hardware/nvdla
#INCLUDES += -I$(SRC_DIR) -I$(ESP_NVDLA_DIR) -I$(TOP)/core/include
INC_DIR += -I$(ESP_NVDLA_DIR) -I$(ROOT)/core/include
NVDLA_RUNTIME_DIR = $(ROOT)
NVDLA_RUNTIME = $(NVDLA_RUNTIME_DIR)/out
$(info $$NVDLA_RUNTIME is [${NVDLA_RUNTIME}])
$(info $$NVDLA_RUNTIME_DIR is [${NVDLA_RUNTIME_DIR}])
ifdef CONFIG_CV_CNN_EN
MODULE := nvdla_runtime
include $(ROOT)/make/macros.mk
BUILDOUT ?= $(ROOT)/out/apps/runtime
BUILDDIR := $(BUILDOUT)/$(MODULE)
TEST_BIN := $(BUILDDIR)/$(MODULE)
MODULE_COMPILEFLAGS := -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function -Werror-implicit-function-declaration
MODULE_CFLAGS := --std=c99
MODULE_CPPFLAGS := --std=c++11 -fexceptions -fno-rtti
NVDLA_FLAGS := -pthread -L$(ROOT)/external/ -ljpeg -L$(ROOT)/out/core/src/runtime/libnvdla_runtime -lnvdla_runtime -Wl,-rpath=.
include esp_hardware/nvdla/rules.mk
$(info $$ALLMODULE_OBJS is [${ALLMODULE_OBJS}])
$(info $$MODULE_OBJS is [${MODULE_OBJS}])
endif
#-----------------------------------------------------------------------------------------------
$(NVDLA_RUNTIME):
@echo -e ${YEL}Compiling NVDLA Runtime Library${NC}
@cd $(NVDLA_RUNTIME_DIR) && make ROOT=$(ROOT) runtime
$(NVDLA_MODULE): $(NVDLA_RUNTIME)
#@echo -e ${YEL}Compiling HPVM Module for NVDLA${NC}
#@cd $(NVDLA_MAKE_DIR) && python gen_me_hpvm_mod.py && cp $(NVDLA_RES_DIR)/$(NVDLA_MODULE) $(CUR_DIR)
#-----------------------------------------------------------------------------------------------
obj_t/%.o: %.c
$(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -o $@
obj_s/%.o: %.c
$(CROSS_COMPILE)$(CC) $(CFLAGS) -DUSE_SIM_ENVIRON -c $< -o $@
$(TARGET_T): $(OBJ_T) $(NVDLA_MODULE) $(ALLMODULE_OBJS)
#$(CROSS_COMPILE)$(CC) -fPIC $< -c -o me_test.o
$(CROSS_COMPILE)$(LD) -r $(ALLMODULE_OBJS) $(OBJ_T) -o wnvdla_test.o
$(CROSS_COMPILE)$(CXX) $(LDLIBS) wnvdla_test.o -o $@ $(LDFLAGS) $(NVDLA_FLAGS)
#$(CROSS_COMPILE)$(CC) $(LDLIBS) $^ -o $@ $(LDFLAGS)
rm wnvdla_test.o
$(TARGET_S): $(OBJ_S) $(NVDLA_MODULE) $(ALLMODULE_OBJS)
#$(CROSS_COMPILE)$(CC) -fPIC $< -c -o me_test.o
$(CROSS_COMPILE)$(LD) -r $(ALLMODULE_OBJS) $(OBJ_S) -o wnvdla_test.o
$(CROSS_COMPILE)$(CXX) $(LDLIBS) wnvdla_test.o -o $@ $(LDFLAGS) $(NVDLA_FLAGS)
#$(CROSS_COMPILE)$(CC) $(LDLIBS) $^ -o $@ $(LDFLAGS)
rm wnvdla_test.o
clean:
$(RM) $(OBJ_T) $(OBJ_S)
$(RM) -r obj_t obj_s
if [ -f "$(NVDLA_MODULE)" ]; then rm $(NVDLA_MODULE); fi
if [ -d "$(NVDLA_RUNTIME)" ]; then rm -rf $(NVDLA_RUNTIME); fi
clobber: clean
$(RM) -rf esp-build
$(RM) $(TARGET) $(STARGET)
obj_t:
mkdir $@
obj_s:
mkdir $@
.PHONY: all clean
#depend:; makedepend -fMakefile -- $(CFLAGS) -- $(SRC_D)
# DO NOT DELETE THIS LINE -- make depend depends on it.
src/read_trace.o: ./include/kernels_api.h ./include/verbose.h
src/read_trace.o: ./include/base_types.h ./include/calc_fmcw_dist.h
src/read_trace.o: ./include/utils.h
src/read_trace.o: ./include/sim_environs.h
src/getopt.o: ./include/getopt.h
src/descrambler_function.o: ./include/base.h ./include/utils.h
src/descrambler_function.o: ./include/viterbi_standalone.h
src/viterbi_flat.o: ./include/base.h ./include/utils.h
src/viterbi_flat.o: ./include/viterbi_flat.h ./include/verbose.h
src/viterbi_flat.o: ./include/viterbi_standalone.h
src/viterbi_flat.o: ./include/base_types.h
src/sim_environs.o: ./include/kernels_api.h ./include/verbose.h
src/sim_environs.o: ./include/base_types.h ./include/calc_fmcw_dist.h
src/sim_environs.o: ./include/utils.h
src/sim_environs.o: ./include/sim_environs.h
src/cpu_vit_accel.o: ./include/base.h ./include/utils.h
src/cpu_vit_accel.o: ./include/viterbi_flat.h ./include/verbose.h
src/cpu_vit_accel.o: ./include/viterbi_standalone.h
src/viterbi_standalone.o: ./include/base.h ./include/utils.h
src/viterbi_standalone.o: ./include/viterbi_flat.h
src/viterbi_standalone.o: ./include/verbose.h
src/main.o: ./include/getopt.h ./include/verbose.h
src/main.o: ./include/base_types.h
src/main.o: ./include/kernels_api.h ./include/calc_fmcw_dist.h
src/main.o: ./include/utils.h ./include/sim_environs.h
src/calculate_dist_from_fmcw.o: ./include/fft-1d.h
src/calculate_dist_from_fmcw.o: ./include/calc_fmcw_dist.h
src/calculate_dist_from_fmcw.o: ./include/base_types.h
src/cpu_fft_accel.o: ./include/base_types.h ./include/fft-1d.h
src/cpu_fft_accel.o: ./include/calc_fmcw_dist.h
src/timer.o: ./include/timer.h
src/kernels_api.o: ./include/kernels_api.h
src/kernels_api.o: ./include/verbose.h ./include/base_types.h
src/kernels_api.o: ./include/calc_fmcw_dist.h
src/kernels_api.o: ./include/utils.h ./include/read_trace.h
src/kernels_api.o: ./include/viterbi_flat.h ./include/base.h