-
Notifications
You must be signed in to change notification settings - Fork 9
/
makefile
72 lines (57 loc) · 1.65 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
# author: Furkan Cayci, 2021
# description:
# run make to check syntax of all files
# run make simulate MODULE=tb_xxx to run the given testbench.
# run make display MODULE=tb_xxx to create a dump file and
# open the waveform using gtkwave
QUIET = @
CC = iverilog
SIM = vvp
VIEW = gtkwave
# temporary macos hack
ifeq ($(shell uname -m), arm64)
VIEW = open -a gtkwave
endif
MODULE?= tb_adder_str
VERILOG_SOURCES = $(wildcard rtl/*.sv)
VERILOG_SOURCES += $(wildcard tb/tb_*.sv)
CFLAGS += -Wall # enable all warnings
CFLAGS += -Winfloop
CFLAGS += -Wno-timescale
CFLAGS += -gassertions
CFLAGS += -g2012 # enable system verilog
.PHONY: all
all: check
@echo ">>> Completed..."
.PHONY: check
check:
@echo ">>> Checking syntax on all designs..."
$(QUIET)$(CC) $(CFLAGS) -o /dev/null $(VERILOG_SOURCES)
.PHONY: simulate
simulate: clean
@echo ">>> Simulating design " $(MODULE)
$(QUIET)$(CC) $(CFLAGS) -o $(MODULE).vvp -s $(MODULE) $(VERILOG_SOURCES)
$(QUIET)$(SIM) -n $(MODULE).vvp
@echo ">>> Done"
.PHONY: display
display: clean dumpy.sv
@echo ">>> Displaying design " $(MODULE)
$(QUIET)$(CC) $(CFLAGS) -o $(MODULE).vvp -s dumpy $(VERILOG_SOURCES) dumpy.sv
$(QUIET)$(SIM) -n $(MODULE).vvp -lxt2
$(QUIET)$(VIEW) $(MODULE).lx2
dumpy.sv:
@echo '>>> Creating top module for dumping waveform'
@echo 'module dumpy();' > $@
@echo '$(MODULE) test();' >> $@
@echo 'initial' >> $@
@echo 'begin' >> $@
@echo ' $$dumpfile("$(MODULE).lx2");' >> $@
@echo ' $$dumpvars(0, dumpy);' >> $@
@echo 'end' >> $@
@echo 'endmodule' >> $@
.PHONY: clean
clean:
@echo "cleaning design..."
$(QUIET)rm -rf dumpy.sv
$(QUIET)rm -rf $(MODULE).vvp
$(QUIET)rm -rf $(MODULE).lx2