forked from IObundle/iob-soc-pong
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
219 lines (158 loc) · 4.18 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
SHELL = bash
export
#run on external memory implies DDR use
ifeq ($(RUN_EXTMEM),1)
USE_DDR=1
endif
#
# BUILD EMBEDDED SOFTWARE
#
SW_DIR:=./software
FIRM_DIR:=$(SW_DIR)/firmware
#default baud and frequency if not given
BAUD ?=$(SIM_BAUD)
FREQ ?=$(SIM_FREQ)
fw-build:
make -C $(FIRM_DIR) build-all
fw-clean:
make -C $(FIRM_DIR) clean-all
fw-debug:
make -C $(FIRM_DIR) debug
#####################################################
# This here is for CLion to recognize the project and provide code checks and insight.
# It is not used for building the project - don't use this.
#compiler settings
TEMP_TOOLCHAIN_PREFIX:=riscv64-unknown-elf-
TEMP_CFLAGS=-Os -nostdlib -march=$(MFLAGS) -mabi=ilp32 --specs=nano.specs -Wcast-align=strict -Wall -Werror -Wextra
TEMP_LFLAGS+= -Wl,-Bstatic,-T,../template.lds,--strip-debug
TEMP_LLIBS=-lgcc -lc -lnosys
TEMP_MFLAGS=$(MFLAGS_BASE)$(MFLAG_M)$(MFLAG_C)
TEMP_MFLAGS_BASE:=rv32i
TEMP_SRC= firmware.S firmware.c ../../submodules/UART/software/printf.c CtrlUtils.c GameUtils.c Utils.c
all:
cd software/firmware && $(TEMP_TOOLCHAIN_PREFIX)gcc -o $@ $(TEMP_CFLAGS) $(TEMP_LFLAGS) $(TEMP_DEFINE) $(TEMP_INCLUDE) $(TEMP_SRCTEMP) $(TEMP_LLIBS)
#####################################################
#
# EMULATE ON PC
#
PC_DIR:=$(SW_DIR)/pc-emul
pc-emul-build:
make fw-build
make -C $(PC_DIR)
pc-emul-run: pc-emul-build
make -C $(PC_DIR) run
pc-emul-clean: fw-clean
make -C $(PC_DIR) clean
pc-emul-test: pc-emul-clean
make -C $(PC_DIR) test
HW_DIR=./hardware
#
# SIMULATE RTL
#
#default simulator running locally or remotely
SIMULATOR ?=icarus
SIM_DIR=$(HW_DIR)/simulation/$(SIMULATOR)
#default baud and system clock frequency
SIM_BAUD = 3000000
SIM_FREQ =50000000
sim-build:
make fw-build
make -C $(SIM_DIR) build
sim-run: sim-build
make -C $(SIM_DIR) run
sim-clean-run: sim-clean sim-run
sim-waves:
make -C $(SIM_DIR) waves
sim-clean: fw-clean
make -C $(SIM_DIR) clean
sim-test:
make -C $(SIM_DIR) test
sim-debug:
make -C $(SIM_DIR) debug
#
# BUILD, LOAD AND RUN ON FPGA BOARD
#
#default board running locally or remotely
BOARD ?=CYCLONEV-GT-DK
BOARD_DIR =$(shell find hardware -name $(BOARD))
#default baud and system clock freq for boards
BOARD_BAUD = 115200
#default board frequency
BOARD_FREQ ?=100000000
ifeq ($(BOARD), CYCLONEV-GT-DK)
BOARD_FREQ =50000000
endif
fpga-build:
make fw-build BAUD=$(BOARD_BAUD) FREQ=$(BOARD_FREQ)
make -C $(BOARD_DIR) build
fpga-run: fpga-build
make -C $(BOARD_DIR) run TEST_LOG="$(TEST_LOG)"
fpga-clean: fw-clean
make -C $(BOARD_DIR) clean
fpga-clean-run: fpga-clean fpga-run
fpga-clean-build: fpga-clean fpga-build
fpga-veryclean:
make -C $(BOARD_DIR) veryclean
fpga-debug:
make -C $(BOARD_DIR) debug
fpga-test:
make -C $(BOARD_DIR) test
#
# COMPILE DOCUMENTS
#
DOC ?= pb
DOC_DIR=document/$(DOC)
doc-build:
make -C $(DOC_DIR) $(DOC).pdf
doc-clean:
make -C $(DOC_DIR) clean
doc-test:
make -C $(DOC_DIR) test
#
# CLEAN
#
clean: pc-emul-clean sim-clean fpga-clean doc-clean
#
# TEST ALL PLATFORMS
#
test-pc-emul: pc-emul-test
test-pc-emul-clean: pc-emul-clean
test-sim:
make sim-test SIMULATOR=verilator
make sim-test SIMULATOR=icarus
test-sim-clean:
make sim-clean SIMULATOR=verilator
make sim-clean SIMULATOR=icarus
test-fpga:
make fpga-test BOARD=CYCLONEV-GT-DK
make fpga-test BOARD=AES-KU040-DB-G
test-fpga-clean:
make fpga-clean BOARD=CYCLONEV-GT-DK
make fpga-clean BOARD=AES-KU040-DB-G
test-doc:
make fpga-clean BOARD=CYCLONEV-GT-DK
make fpga-clean BOARD=AES-KU040-DB-G
make fpga-build BOARD=CYCLONEV-GT-DK
make fpga-build BOARD=AES-KU040-DB-G
make doc-test DOC=pb
make doc-test DOC=presentation
test-doc-clean:
make doc-clean DOC=pb
make doc-clean DOC=presentation
test: test-clean test-pc-emul test-sim test-fpga test-doc
test-clean: test-pc-emul-clean test-sim-clean test-fpga-clean test-doc-clean
debug:
@echo $(UART_DIR)
@echo $(CACHE_DIR)
.PHONY: fw-build fw-clean fw-debug\
pc-emul-build pc-emul-run pc-emul-clean pc-emul-test \
sim-build sim-run sim-clean sim-test \
fpga-build fpga-run fpga-clean fpga-test \
doc-build doc-clean doc-test \
clean \
test-pc-emul test-pc-emul-clean \
test-sim test-sim-clean \
test-fpga test-fpga-clean \
test-doc test-doc-clean \
test test-clean \
debug