-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathMakefile
213 lines (185 loc) · 6.79 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
#
# Ensure the compiler and necessary executables are on the search PATH
#
#
# Ensure you have set the following Variables
#
#
export ROOTDIR = $(shell pwd)
export WORK ?= $(ROOTDIR)/work
include Makefile.include
pipe:= |
empty:=
comma:= ,
space:= $(empty) $(empty)
RISCV_DEVICE_ALL = $(shell ls $(TARGETDIR)/$(RISCV_TARGET)/device/rv$(XLEN)$(RISCV_BASE)_$(RISCV_MODE))
RISCV_DEVICE_OPT = $(subst $(space),$(pipe),$(RISCV_DEVICE_ALL))
RISCV_DEVICE_ALL := $(filter-out Makefile.include,$(RISCV_DEVICE_ALL))
ifeq ($(strip $(RISCV_DEVICE)),)
DEFAULT_TARGET=all_variant
# If make target is specified use this as default
DEFAULT_CLEAN_TARGET=all_clean
else
DEFAULT_TARGET=variant
DEFAULT_CLEAN_TARGET=one_clean
endif
export SUITEDIR = $(ROOTDIR)/riscv-test-suite/rv$(XLEN)$(RISCV_BASE)_$(RISCV_MODE)/$(RISCV_DEVICE)
ifeq ($(RISCV_TARGET),)
# Check riscvOVPsim present
ifneq ($(wildcard $(ROOTDIR)/riscv-ovpsim/bin/*/riscvOVPsim.exe),)
export RISCV_TARGET=riscvOVPsim
else
# Check riscvOVPsimPlus present
ifneq ($(wildcard $(ROOTDIR)/riscv-ovpsim-plus/bin/*/riscvOVPsimPlus.exe),)
export RISCV_TARGET=riscvOVPsimPlus
else
ERROR:=$(error Cannot find either default RISCV_TARGET riscvOVPsim or riscvOVPsimPlus)
endif
endif
endif
$(info )
$(info ============================ VARIABLE INFO ==================================)
$(info ROOTDIR: $(ROOTDIR) [origin: $(origin ROOTDIR)])
$(info WORK: $(WORK) [origin: $(origin WORK)])
$(info TARGETDIR: $(TARGETDIR) [origin: $(origin TARGETDIR)])
$(info RISCV_TARGET: $(RISCV_TARGET) [origin: $(origin RISCV_TARGET)])
$(info XLEN: $(XLEN) [origin: $(origin XLEN)])
$(info RISCV_BASE: $(RISCV_BASE) [origin: $(origin RISCV_BASE)])
$(info RISCV_MODE: $(RISCV_MODE) [origin: $(origin RISCV_MODE)])
$(info RISCV_DEVICE: $(RISCV_DEVICE) [origin: $(origin RISCV_DEVICE)])
$(info =============================================================================)
$(info )
export RISCV_PREFIX ?= riscv64-unknown-elf-
# Check Toolchain on PATH
ifeq (,$(shell which $(RISCV_PREFIX)gcc))
ifeq (,$(shell which $(RISCV_PREFIX)as))
$(error No $(RISCV_PREFIX)gcc or $(RISCV_PREFIX)as on PATH, consider correcting RISCV_PREFIX and/or adding bin directory to PATH)
endif
endif
RVTEST_DEFINES =
ifeq ($(RISCV_ASSERT),1)
RVTEST_DEFINES += -DRVMODEL_ASSERT
endif
ifeq ($(RISCV_ASSERT),2)
RVTEST_DEFINES += -DRVMODEL_ASSERT -DRVMODEL_ASSERT_SHORT
endif
export RVTEST_DEFINES
VERBOSE ?= 0
ifeq ($(VERBOSE),1)
export V=
export REDIR =
export REDIR1 =
export REDIR2 =
else
export V=@
export REDIR = >/dev/null
export REDIR1 = 1>/dev/null
export REDIR2 = 2>/dev/null
endif
PARALLEL ?= 1
ifeq ($(RISCV_TARGET),spike)
PARALLEL = 0
endif
ifeq ($(PARALLEL),0)
JOBS =
endif
default: $(DEFAULT_TARGET)
variant: simulate verify
all_variant:
for isa in $(RISCV_DEVICE_ALL); do \
$(MAKE) $(JOBS) RISCV_TARGET=$(RISCV_TARGET) RISCV_MODE=$(RISCV_MODE) RISCV_BASE=$(RISCV_BASE) RISCV_TARGET_FLAGS="$(RISCV_TARGET_FLAGS)" RISCV_DEVICE=$$isa variant; \
rc=$$?; \
if [ $$rc -ne 0 ]; then \
exit $$rc; \
fi \
done
build: compile
run: simulate
compile:
ifeq ($(wildcard $(SUITEDIR)/Makefile),)
@echo "# Ignore riscv-test-suite/rv$(XLEN)$(RISCV_BASE)_$(RISCV_MODE)/$(RISCV_DEVICE)"
else
$(MAKE) $(JOBS) \
RISCV_TARGET=$(RISCV_TARGET) \
RISCV_DEVICE=$(RISCV_DEVICE) \
RISCV_BASE=$(RISCV_BASE) \
RISCV_MODE=$(RISCV_MODE) \
RISCV_PREFIX=$(RISCV_PREFIX) \
compile -C $(SUITEDIR)
endif
simulate:
ifeq ($(wildcard $(SUITEDIR)/Makefile),)
@echo "# Ignore riscv-test-suite/rv$(XLEN)$(RISCV_BASE)_$(RISCV_MODE)/$(RISCV_DEVICE)"
else
$(MAKE) $(JOBS) \
RISCV_TARGET=$(RISCV_TARGET) \
RISCV_DEVICE=$(RISCV_DEVICE) \
RISCV_BASE=$(RISCV_BASE) \
RISCV_MODE=$(RISCV_MODE) \
RISCV_PREFIX=$(RISCV_PREFIX) \
run -C $(SUITEDIR)
endif
verify: simulate
riscv-test-env/verify.sh \
RISCV_TARGET=$(RISCV_TARGET) \
RISCV_DEVICE=$(RISCV_DEVICE) \
RISCV_BASE=$(RISCV_BASE) \
RISCV_MODE=$(RISCV_MODE) \
RISCV_PREFIX=$(RISCV_PREFIX)
cover: postverify
postverify:
ifeq ($(wildcard $(TARGETDIR)/$(RISCV_TARGET)/postverify.sh),)
$(info No post verify script found $(TARGETDIR)/$(RISCV_TARGET)/postverify.sh)
else
$(TARGETDIR)/$(RISCV_TARGET)/postverify.sh \
RISCV_TARGET=$(RISCV_TARGET) \
RISCV_DEVICE=$(RISCV_DEVICE) \
RISCV_BASE=$(RISCV_BASE) \
RISCV_MODE=$(RISCV_MODE) \
RISCV_PREFIX=$(RISCV_PREFIX)
endif
clean: $(DEFAULT_CLEAN_TARGET)
all_clean:
for isa in $(RISCV_DEVICE_ALL); do \
$(MAKE) $(JOBS) RISCV_TARGET=$(RISCV_TARGET) RISCV_MODE=$(RISCV_MODE) RISCV_BASE=$(RISCV_BASE) RISCV_DEVICE=$$isa clean; \
rc=$$?; \
if [ $$rc -ne 0 ]; then \
exit $$rc; \
fi \
done
one_clean:
ifeq ($(wildcard $(SUITEDIR)/Makefile),)
@echo "# Ignore riscv-test-suite/rv$(XLEN)$(RISCV_BASE)_$(RISCV_MODE)/$(RISCV_DEVICE)"
else
$(MAKE) $(JOBS) \
RISCV_TARGET=$(RISCV_TARGET) \
RISCV_DEVICE=$(RISCV_DEVICE) \
RISCV_BASE=$(RISCV_BASE) \
RISCV_MODE=$(RISCV_MODE) \
RISCV_PREFIX=$(RISCV_PREFIX) \
clean -C $(SUITEDIR)
endif
help:
@echo "RISC-V Architectural Tests"
@echo ""
@echo " Makefile Environment Variables to be set per Target"
@echo " -- TARGETDIR='<directory containing the target folder>'"
@echo " -- XLEN='<make supported xlen>'"
@echo " -- RISCV_TARGET='<name of target>'"
@echo " -- RISCV_TARGET_FLAGS='<any flags to be passed to target>'"
@echo " -- RISCV_DEVICE='$(RISCV_DEVICE_OPT)' [ leave empty to run all devices ]"
@echo " -- RISCV_BASE='<isa i or e>'"
@echo " -- RISCV_MODE='<mode m or mu or msu>'"
@echo " -- RISCV_TEST='<name of the test. eg. I-ADD-01'"
@echo " "
@echo " Other Options"
@echo " -- RISCV_ASSERT='0/1/2' 0(default)-no assertions, 1-full information, 2-report only"
@echo " -- RISCV_GENERATE_OBJFILE='0/1' 0(default)-no object file, 1-object file generated with ELF"
@echo " "
@echo " Makefile targets available"
@echo " -- build: To compile all the tests within the RISCV_DEVICE suite and generate the elfs. Note this will default to running on the I extension alone if RISCV_DEVICE is empty"
@echo " -- run: To run compiled tests on the target model and generate signatures. Note this will default to run aning on the I extension alone if RISCV_DEVICE is empty"
@echo " -- verify: To verify if the generated signatures match the corresponding reference signatures. Note this will default to running on the I extension alone if RISCV_DEVICE is empty"
@echo " -- postverify: To execute a target specific verify script. Note this will default to running on the I extension alone if RISCV_DEVICE is empty"
@echo " -- clean : removes the working directory from the root folder and also from the respective device folders of the target"
@echo " -- default: build, run, and verify on all devices enabled"