-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathMakefile
132 lines (108 loc) · 3.81 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
ifndef CROSS_COMPILE
export CROSS_COMPILE = riscv64-unknown-elf-
endif
dirs = $(dir $(wildcard sw/[^_]*/))
SUBDIRS = $(subst /,,$(subst sw/,,$(subst common,,$(dirs))))
verilator ?= 1
top ?= 0
coverage ?= 0
debug ?= 0
memsize ?= 256
# set 1 for compliance test v1, 2 for v2
test_v ?= 3
# set 1 to enable rv32c
rv32c ?= 0
# set 1 to enable rv32e
rv32e ?= 0
# set 1 to enable rv32b
rv32b ?= 0
ifeq ($(verilator), 1)
_verilator := 1
endif
ifeq ($(top), 1)
_top := 1
endif
ifeq ($(coverage), 1)
_coverage := 1
endif
MAKE_FLAGS = rv32c=$(rv32c) rv32e=$(rv32e) rv32b=$(rv32b)
.PHONY: $(SUBDIRS) tools tests coverage
help:
@echo "make all build all diags and run the RTL sim"
@echo "make all-sw build all diags and run the ISS sim"
@echo "make tests-all run all diags and compliance test"
@echo "make coverage generate code coverage report"
@echo "make build build all diags and the RTL"
@echo "make dhrystone build Dhrystone diag and run the RTL sim"
@echo "make coremark build Coremark diag and run the RTL sim"
@echo "make clean clean"
@echo "make distclean clean all"
@echo ""
@echo "rv32c=1 enable RV32C (default off)"
@echo "rv32e=1 enable RV32E (default off)"
@echo "rv32b=1 enable RV32B (default off)"
@echo "debug=1 enable waveform dump (default off)"
@echo "coverage=1 enable coverage test (default off)"
@echo "test_v=[2|3] run test compliance v2 or v3 (default)"
@echo ""
@echo "For example"
@echo ""
@echo "$ make tests-all run all tests with test compliance (default v3)"
@echo "$ make test_v=2 tests-all run all tests with test compliance v2"
@echo "$ make coverage=1 tests-all run all tests with code coverage report"
@echo "$ make debug=1 hello run hello with waveform dump"
@echo "$ make rv32e=1 dhrystone run dhrystone for RV32E config"
@echo ""
tests-all: tests-sw tests all all-sw
all:
$(MAKE) clean
for i in $(SUBDIRS); do \
$(MAKE) $(MAKE_FLAGS) memsize=$(memsize) $$i || exit 1; \
done
all-sw:
for i in $(SUBDIRS); do \
$(MAKE) $(MAKE_FLAGS) memsize=$(memsize) -C tools $$i.elf; \
done
# Architectural test: it needs 1716MB
tests:
$(MAKE) coverage=$(coverage) clean
$(MAKE) $(MAKE_FLAGS) memsize=1716 test_v=$(test_v) -C tests tests
tests-sw:
$(MAKE) coverage=$(coverage) clean
$(MAKE) $(MAKE_FLAGS) memsize=1716 test_v=$(test_v) -C tests tests-sw
build:
for i in sw sim tools; do \
$(MAKE) $(MAKE_FLAGS) memsize=$(memsize) -C $$i; \
done
$(SUBDIRS):
@$(MAKE) $(MAKE_FLAGS) memsize=$(memsize) -C sw $@
@$(MAKE) $(if $(_verilator), verilator=1) \
$(if $(_coverage), coverate=1) \
$(if $(_top), top=1) $(MAKE_FLAGS) memsize=$(memsize) debug=$(debug) -C sim [email protected]
@$(MAKE) $(if $(_top), top=1) $(MAKE_FLAGS) memsize=$(memsize) tracelog=1 -C tools [email protected]
@echo "Compare the trace between RTL and ISS simulator"
@diff --brief sim/trace.log tools/trace.log
@echo === Simulation passed ===
coverage: clean
@$(MAKE) $(MAKE_FLAGS) memsize=$(memsize) coverage=1 all
@mv sim/*_cov.dat coverage/.
@$(MAKE) $(MAKE_FLAGS) memsize=$(memsize) coverage=1 tests
@if [ "$(test_v)" = "2" ]; then \
mv tests/riscv-arch-test.v2/work/rv32i_m/I/*_cov.dat coverage/.; \
mv tests/riscv-arch-test.v2/work/rv32i_m/M/*_cov.dat coverage/.; \
if [ "$(rv32b)" = "1" ]; then \
mv tests/riscv-arch-test.v2/work/rv32i_m/B/*_cov.dat coverage/.; \
fi; \
else \
echo "TODO: code coverage for riscv-arch-test V3"; \
fi
@$(MAKE) $(MAKE_FLAGS) memsize=$(memsize) -C coverage
@$(MAKE) $(MAKE_FLAGS) memsize=$(memsize) -C tools coverage
clean:
@for i in sw sim tools tests coverage; do \
$(MAKE) test_v=$(test_v) -C $$i clean; \
done
distclean:
@for i in sw sim tools tests coverage; do \
$(MAKE) test_v=$(test_v) -C $$i distclean; \
done