forked from openhwgroup/cvw-arch-verif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (81 loc) · 3.33 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
# General Make configuration
.SECONDEXPANSION:
.SUFFIXES:
MAKEFLAGS += --no-print-directory
# Directories and extensions
TESTDIR := tests
SRCDIR64 := $(TESTDIR)/rv64
SRCDIR32 := $(TESTDIR)/rv32
PRIVDIR := $(TESTDIR)/priv
PRIVDIR64 := $(PRIVDIR)/rv64
PRIVDIR32 := $(PRIVDIR)/rv32
WORK := work
SRCEXT := S
OBJEXT := elf
# Dynamically find all source files
UNPRIV_SOURCES = $(shell find $(SRCDIR32) $(SRCDIR64) -type f -regex ".**\.$(SRCEXT)" | sort)
PRIVSOURCES = $(shell find $(PRIVDIR) -type f -regex ".**\.$(SRCEXT)" | sort)
RV32PRIV = $(PRIVSOURCES:$(PRIVDIR)/%=$(PRIVDIR32)/%)
RV32PRIVOBJECTS = $(RV32PRIV:.$(SRCEXT)=.$(OBJEXT))
RV64PRIV = $(PRIVSOURCES:$(PRIVDIR)/%=$(PRIVDIR64)/%)
RV64PRIVOBJECTS = $(RV64PRIV:.$(SRCEXT)=.$(OBJEXT))
PRIVOBJECTS = $(RV32PRIVOBJECTS) $(RV64PRIVOBJECTS)
UNPRIVOBJECTS = $(UNPRIV_SOURCES:.$(SRCEXT)=.$(OBJEXT))
.PHONY: all clean sim merge covergroupgen testgen unpriv priv
# Main targets
all: unpriv priv
unpriv: testgen
$(MAKE) $(UNPRIVOBJECTS)
priv: $(PRIVOBJECTS)
# Test generation scripts
covergroupgen: bin/covergroupgen.py
bin/covergroupgen.py
testgen: covergroupgen bin/testgen.py bin/combinetests.py
bin/testgen.py
bin/combinetests.py
$(PRIVDIR)/Zicsr-CSR-Tests.h: bin/csrtests.py
bin/csrtests.py
# Some instructions get silently converted to 16-bit, this allows only Zc* instr to get converted to 16-bit
ZCA_FLAG = $(if $(findstring /Zca, $(dir $<)),_zca,)
ZCB_FLAG = $(if $(findstring /Zcb, $(dir $<)),_zcb,)
ZCD_FLAG = $(if $(findstring /Zcd, $(dir $<)),_zcd,)
ZCF_FLAG = $(if $(findstring /Zcf, $(dir $<)),_zcf,)
CMPR_FLAGS = $(ZCA_FLAG)$(ZCB_FLAG)$(ZCD_FLAG)$(ZCF_FLAG)
# Set bitwidth and ABI based on XLEN for each test
BITWIDTH = $(if $(findstring 64,$*),64,32)
MABI = $(if $(findstring 32,$*),i,)lp$(BITWIDTH)
# Modify source file for priv tests to support 32-bit and 64-bit tests from the same source
SOURCEFILE = $(subst priv/rv64/,priv/,$(subst priv/rv32/,priv/,$*)).S
EXTRADEPS = $(if $(findstring priv,$*),$(PRIVDIR)/Zicsr-CSR-Tests.h $(PRIVDIR$(BITWIDTH)))
# Don't delete intermediate files
.PRECIOUS: %.elf %.elf.objdump %.elf.memfile
# Compile tests
%.elf: $$(SOURCEFILE) $$(EXTRADEPS)
riscv64-unknown-elf-gcc -g -o $@ -march=rv$(BITWIDTH)g$(CMPR_FLAGS)_zfa_zba_zbb_zbc_zbs_zfh_zicboz_zicbop_zicbom_zicond -mabi=$(MABI) -mcmodel=medany \
-nostartfiles -I$(TESTDIR) -T$(TESTDIR)/link.ld $<
$(MAKE) [email protected] [email protected]
%.elf.objdump: %.elf
riscv64-unknown-elf-objdump -S -D $< > $@
extractFunctionRadix.sh $@
%.elf.memfile: %.elf
riscv64-unknown-elf-elf2hex --bit-width $(BITWIDTH) --input $< --output $@
# Run tests while collecting functional coverage
sim:
rm -f ${WALLY}/sim/questa/fcov_ucdb/*
wsim rv32gc $(TESTDIR)/priv/rv32/ZicsrM.elf --fcov
#wsim rv64gc ${WALLY}/tests/riscof/work/wally-riscv-arch-test/rv64i_m/privilege/src/WALLY-mmu-sv39-svadu-svnapot-svpbmt-01.S/ref/ref.elf --fcov
#wsim rv64gc $(TESTDIR)/rv64/I/WALLY-COV-ALL.elf --fcov
#wsim rv32gc $(TESTDIR)/rv32/M/WALLY-COV-div.elf --fcov
$(MAKE) merge
# Merge coverage files and generate report
merge: $(WORK)
rm -f work/merge*.ucdb
bin/coverreport.py
# Create directories
$(SRCDIR64) $(SRCDIR32) $(PRIVDIR) $(PRIVDIR64) $(PRIVDIR32) $(WORK):
@mkdir -p $@
clean:
rm -rf fcov/rv32/*
rm -rf fcov/rv64/*
rm -rf $(SRCDIR64) $(SRCDIR32) $(PRIVDIR64) $(PRIVDIR32) $(WORK)
rm -rf tests/priv/*.h