-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
114 lines (89 loc) · 2.09 KB
/
Copy pathMakefile
File metadata and controls
114 lines (89 loc) · 2.09 KB
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
MEM_DIR=.
defmacro:=-D
incdir:=-I
# Default module
MEM_NAME ?=iob_ram_2p_asym
MODULE_DIR=$(shell find . -name $(MEM_NAME))
# list of asymmetric memories
IS_ASYM=$(shell echo $(MEM_NAME) | grep fifo)
IS_ASYM+=$(shell echo $(MEM_NAME) | grep 2p)
IS_ASYM+=$(shell echo $(MEM_NAME) | grep dp)
# Defines
DEFINE+=$(defmacro)ADDR_W=10
DEFINE+=$(defmacro)DATA_W=32
ifeq ($(VCD),1)
DEFINE+=$(defmacro)VCD
endif
# Includes
INCLUDE+=$(incdir)./submodules/LIB/hardware/include
# Sources
ifneq ($(MODULE_DIR),)
include $(MODULE_DIR)/hardware.mk
endif
# Submodules
ifneq ($(filter iob_ram_2p_asym, $(HW_MODULES)),)
include $(MEM_DIR)/hardware/ram/iob_ram_2p/hardware.mk
endif
# Testbench
VSRC+=$(wildcard $(MODULE_DIR)/$(MEM_NAME)_tb.v)
ALL_HW_MODULES=$(shell basename -a $(shell find . -name hardware.mk -not -path './submodules/*' | sed 's/\/hardware.mk//g' | tail -n +3))
# Rules
.PHONY: exists \
sim sim-sym sim-asym sim-all \
$(ALL_HW_MODULES) \
sim-test test \
clean \
debug
exists:
ifeq ($(MODULE_DIR),)
$(error "Module $(MEM_NAME) not found")
endif
@echo "\n\nSimulating module $(MEM_NAME)\n\n"
#
# Simulate
#
# Icarus Verilog simulator flags
VLOG=iverilog -W all -g2005-sv $(INCLUDE) $(DEFINE)
sim: exists $(VSRC) $(VHDR)
ifeq ($(IS_ASYM),)
make sim-sym
else
make sim-asym
endif
ifeq ($(VCD),1)
@if [ ! `pgrep gtkwave` ]; then gtkwave uut.vcd; fi &
endif
sim-sym:
$(VLOG) $(VSRC)
@./a.out $(TEST_LOG)
sim-asym: exists $(VSRC) $(VHDR)
$(VLOG) $(defmacro)W_DATA_W=32 $(defmacro)R_DATA_W=8 $(VSRC)
@./a.out $(TEST_LOG)
$(VLOG) $(defmacro)W_DATA_W=8 $(defmacro)R_DATA_W=32 $(VSRC)
@./a.out $(TEST_LOG)
$(VLOG) $(defmacro)W_DATA_W=8 $(defmacro)R_DATA_W=8 $(VSRC)
@./a.out $(TEST_LOG)
sim-all: $(ALL_HW_MODULES)
@echo "Listing all modules: $(ALL_HW_MODULES)"
$(ALL_HW_MODULES):
make sim MEM_NAME=$@
#
# Test
#
sim-test:
make sim-all VCD=0 TEST_LOG=">> test.log"
test: clean sim-test
@if [ `grep -c "ERROR" test.log` != 0 ]; then exit 1; fi
#
# Debug
#
debug:
@echo $(IS_ASYM)
@echo $(MODULE_DIR)
@echo $(VSRC)
@echo $(HW_MODULES)
#
# Clean
#
clean:
@rm -f *~ \#*\# a.out *.vcd *.drom *.png *.pyc *.log