15
15
$(error '$(ARCH ) ' is not a valid architecture, must be one of : RV32, RV64)
16
16
endif
17
17
18
+
19
+ CONFIG_PLATFORM =config/platform.yaml
20
+ CONFIG_ISA =config/isa.yaml
21
+ GENERATED_CONFIG_DIR =generated_definitions/config
22
+ RV_CONFIG =riscv-config
23
+ RV_CONFIG2SAIL =rv_conf2sail
24
+ RV_CONFIG_SAIL =$(GENERATED_CONFIG_DIR ) /riscv_config.sail
25
+ RV_CONFIG_TYPES: =$(shell opam config var riscv_config2sail:share) /riscv_config_types.sail
26
+
18
27
# Instruction sources, depending on target
19
28
SAIL_CHECK_SRCS = riscv_addr_checks_common.sail riscv_addr_checks.sail riscv_misa_ext.sail
20
29
SAIL_DEFAULT_INST = riscv_insts_base.sail riscv_insts_aext.sail riscv_insts_cext.sail riscv_insts_mext.sail riscv_insts_zicsr.sail riscv_insts_next.sail
@@ -67,12 +76,13 @@ SAIL_OTHER_SRCS = $(SAIL_STEP_SRCS) riscv_analysis.sail
67
76
SAIL_OTHER_COQ_SRCS = riscv_termination_common.sail riscv_termination_rv64.sail riscv_analysis.sail
68
77
endif
69
78
79
+ RV_CONFIG_SRCS = $(RV_CONFIG_TYPES ) $(RV_CONFIG_SAIL )
70
80
71
- PRELUDE_SRCS = $(addprefix model/,$(PRELUDE ) )
72
- SAIL_SRCS = $(addprefix model/,$(SAIL_ARCH_SRCS ) $(SAIL_SEQ_INST_SRCS ) $(SAIL_OTHER_SRCS ) )
73
- SAIL_RMEM_SRCS = $(addprefix model/,$(SAIL_ARCH_SRCS ) $(SAIL_RMEM_INST_SRCS ) $(SAIL_OTHER_SRCS ) )
74
- SAIL_RVFI_SRCS = $(addprefix model/,$(SAIL_ARCH_RVFI_SRCS ) $(SAIL_SEQ_INST_SRCS ) $(RVFI_STEP_SRCS ) )
75
- SAIL_COQ_SRCS = $(addprefix model/,$(SAIL_ARCH_SRCS ) $(SAIL_SEQ_INST_SRCS ) $(SAIL_OTHER_COQ_SRCS ) )
81
+ PRELUDE_SRCS = $(RV_CONFIG_SRCS ) $( addprefix model/,$(PRELUDE ) )
82
+ SAIL_SRCS = $(RV_CONFIG_SRCS ) $( addprefix model/,$(SAIL_ARCH_SRCS ) $(SAIL_SEQ_INST_SRCS ) $(SAIL_OTHER_SRCS ) )
83
+ SAIL_RMEM_SRCS = $(RV_CONFIG_SRCS ) $( addprefix model/,$(SAIL_ARCH_SRCS ) $(SAIL_RMEM_INST_SRCS ) $(SAIL_OTHER_SRCS ) )
84
+ SAIL_RVFI_SRCS = $(RV_CONFIG_SRCS ) $( addprefix model/,$(SAIL_ARCH_RVFI_SRCS ) $(SAIL_SEQ_INST_SRCS ) $(RVFI_STEP_SRCS ) )
85
+ SAIL_COQ_SRCS = $(RV_CONFIG_SRCS ) $( addprefix model/,$(SAIL_ARCH_SRCS ) $(SAIL_SEQ_INST_SRCS ) $(SAIL_OTHER_COQ_SRCS ) )
76
86
77
87
PLATFORM_OCAML_SRCS = $(addprefix ocaml_emulator/,platform.ml platform_impl.ml riscv_ocaml_sim.ml)
78
88
@@ -121,10 +131,10 @@ C_LIBS += -L $(RISCV)/lib -lfesvr -lriscv -Wl,-rpath=$(RISCV)/lib
121
131
endif
122
132
123
133
# SAIL_FLAGS = -dtc_verbose 4
134
+ SAIL_FLAGS += -O -Oconstant_fold
124
135
125
136
ifneq (,$(COVERAGE ) )
126
137
C_FLAGS += --coverage -O1
127
- SAIL_FLAGS += -Oconstant_fold
128
138
else
129
139
C_FLAGS += -O3 -flto
130
140
endif
@@ -198,7 +208,7 @@ ocaml_emulator/tracecmp: ocaml_emulator/tracecmp.ml
198
208
199
209
generated_definitions/c/riscv_model_$(ARCH ) .c : $(SAIL_SRCS ) model/main.sail Makefile
200
210
mkdir -p generated_definitions/c
201
- $(SAIL ) $(SAIL_FLAGS ) -O -Oconstant_fold - memo_z3 -c -c_include riscv_prelude.h -c_include riscv_platform.h -c_no_main $(SAIL_SRCS ) model/main.sail -o $(basename $@ )
211
+ $(SAIL ) $(SAIL_FLAGS ) -memo_z3 -c -c_include riscv_prelude.h -c_include riscv_platform.h -c_no_main $(SAIL_SRCS ) model/main.sail -o $(basename $@ )
202
212
203
213
# convenience target
204
214
.PHONY : csim
@@ -209,9 +219,14 @@ rvfi: c_emulator/riscv_rvfi
209
219
c_emulator/riscv_sim_$(ARCH ) : generated_definitions/c/riscv_model_$(ARCH ) .c $(C_INCS ) $(C_SRCS ) Makefile
210
220
gcc -g $(C_WARNINGS ) $(C_FLAGS ) $< $(C_SRCS ) $(SAIL_LIB_DIR ) /* .c $(C_LIBS ) -o $@
211
221
222
+ $(RV_CONFIG_SAIL ) : $(CONFIG_ISA ) $(CONFIG_PLATFORM )
223
+ mkdir -p $(GENERATED_CONFIG_DIR )
224
+ $(RV_CONFIG ) --isa_spec $(CONFIG_ISA ) --platform_spec $(CONFIG_PLATFORM ) --work_dir $(GENERATED_CONFIG_DIR )
225
+ $(RV_CONFIG2SAIL ) -i $(GENERATED_CONFIG_DIR ) /isa_checked.yaml -p $(GENERATED_CONFIG_DIR ) /platform_checked.yaml -o $@
226
+
212
227
generated_definitions/c/riscv_rvfi_model.c : $(SAIL_RVFI_SRCS ) model/main.sail Makefile
213
228
mkdir -p generated_definitions/c
214
- $(SAIL ) $(SAIL_FLAGS ) -O - memo_z3 -c -c_include riscv_prelude.h -c_include riscv_platform.h -c_no_main $(SAIL_RVFI_SRCS ) model/main.sail -o $(basename $@ )
229
+ $(SAIL ) $(SAIL_FLAGS ) -memo_z3 -c -c_include riscv_prelude.h -c_include riscv_platform.h -c_no_main $(SAIL_RVFI_SRCS ) model/main.sail -o $(basename $@ )
215
230
sed -i -e ' /^[[:space:]]*$$/d' $@
216
231
217
232
c_emulator/riscv_rvfi : generated_definitions/c/riscv_rvfi_model.c $(C_INCS ) $(C_SRCS ) Makefile
0 commit comments