aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinlai Wan <xinlai.w@rioslab.org>2024-04-17 14:07:01 +0800
committerGitHub <noreply@github.com>2024-04-17 14:07:01 +0800
commit6605792e014d67292c4adc936d789cdea511b3ed (patch)
tree061692f9a92e9ee37d2940cfde66d7c4bf4c2409
parent9692f84f08290d82d6305fb3934f0b0dcb70191c (diff)
parent16077e126b634c006590b02cb758d48a3882528a (diff)
downloadsail-riscv-6605792e014d67292c4adc936d789cdea511b3ed.zip
sail-riscv-6605792e014d67292c4adc936d789cdea511b3ed.tar.gz
sail-riscv-6605792e014d67292c4adc936d789cdea511b3ed.tar.bz2
Merge branch 'master' into master
Signed-off-by: Xinlai Wan <xinlai.w@rioslab.org>
-rw-r--r--.github/workflows/compile.yml4
-rw-r--r--.github/workflows/test-results.yml8
-rw-r--r--CODE_STYLE.md2
-rw-r--r--LICENCE63
-rw-r--r--Makefile49
-rw-r--r--c_emulator/riscv_platform.c20
-rw-r--r--c_emulator/riscv_platform.h5
-rw-r--r--c_emulator/riscv_platform_impl.c5
-rw-r--r--c_emulator/riscv_platform_impl.h5
-rw-r--r--c_emulator/riscv_sim.c33
-rw-r--r--doc/figs/notes_Virtual_Memory_Fig1.svg1027
-rw-r--r--doc/notes_Virtual_Memory.adoc119
-rw-r--r--handwritten_support/0.11/mem_metadata.lem16
-rw-r--r--handwritten_support/0.11/riscv_extras.lem172
-rw-r--r--handwritten_support/0.11/riscv_extras_fdext.lem216
-rw-r--r--handwritten_support/0.11/riscv_extras_sequential.lem160
-rw-r--r--handwritten_support/mem_metadata.lem8
-rw-r--r--handwritten_support/riscv_extras.lem126
-rw-r--r--handwritten_support/riscv_extras_fdext.lem140
-rw-r--r--handwritten_support/riscv_extras_sequential.lem4
-rw-r--r--model/hex_bits.sail124
-rw-r--r--model/main.sail68
-rw-r--r--model/mapping.sail136
-rw-r--r--model/prelude.sail194
-rw-r--r--model/prelude_mapping.sail771
-rw-r--r--model/prelude_mem.sail78
-rw-r--r--model/prelude_mem_metadata.sail72
-rw-r--r--model/riscv_addr_checks.sail68
-rw-r--r--model/riscv_addr_checks_common.sail72
-rw-r--r--model/riscv_analysis.sail68
-rw-r--r--model/riscv_csr_ext.sail68
-rw-r--r--model/riscv_csr_map.sail132
-rw-r--r--model/riscv_decode_ext.sail68
-rw-r--r--model/riscv_ext_regs.sail68
-rw-r--r--model/riscv_fdext_control.sail80
-rw-r--r--model/riscv_fdext_regs.sail86
-rw-r--r--model/riscv_fetch.sail68
-rw-r--r--model/riscv_fetch_rvfi.sail78
-rw-r--r--model/riscv_flen_D.sail68
-rw-r--r--model/riscv_flen_F.sail68
-rw-r--r--model/riscv_freg_type.sail68
-rw-r--r--model/riscv_insts_aext.sail78
-rw-r--r--model/riscv_insts_base.sail86
-rw-r--r--model/riscv_insts_begin.sail68
-rw-r--r--model/riscv_insts_cdext.sail70
-rw-r--r--model/riscv_insts_cext.sail82
-rw-r--r--model/riscv_insts_cfext.sail74
-rw-r--r--model/riscv_insts_dext.sail68
-rw-r--r--model/riscv_insts_end.sail68
-rw-r--r--model/riscv_insts_fext.sail70
-rw-r--r--model/riscv_insts_hints.sail68
-rw-r--r--model/riscv_insts_mext.sail68
-rw-r--r--model/riscv_insts_next.sail68
-rw-r--r--model/riscv_insts_rmem.sail68
-rw-r--r--model/riscv_insts_vext_arith.sail44
-rwxr-xr-xmodel/riscv_insts_vext_fp.sail82
-rwxr-xr-xmodel/riscv_insts_vext_mask.sail44
-rw-r--r--model/riscv_insts_vext_mem.sail93
-rwxr-xr-xmodel/riscv_insts_vext_red.sail55
-rwxr-xr-xmodel/riscv_insts_vext_utils.sail191
-rwxr-xr-xmodel/riscv_insts_vext_vm.sail48
-rw-r--r--model/riscv_insts_vext_vset.sail66
-rw-r--r--model/riscv_insts_zba.sail68
-rw-r--r--model/riscv_insts_zbb.sail68
-rw-r--r--model/riscv_insts_zbc.sail68
-rw-r--r--model/riscv_insts_zbkb.sail68
-rw-r--r--model/riscv_insts_zbkx.sail68
-rw-r--r--model/riscv_insts_zbs.sail68
-rw-r--r--model/riscv_insts_zcb.sail210
-rw-r--r--model/riscv_insts_zfa.sail84
-rw-r--r--model/riscv_insts_zfh.sail68
-rw-r--r--model/riscv_insts_zicond.sail68
-rw-r--r--model/riscv_insts_zicsr.sail217
-rw-r--r--model/riscv_insts_zkn.sail72
-rw-r--r--model/riscv_insts_zks.sail68
-rw-r--r--model/riscv_jalr_rmem.sail68
-rw-r--r--model/riscv_jalr_seq.sail68
-rw-r--r--model/riscv_mem.sail258
-rw-r--r--model/riscv_misa_ext.sail68
-rw-r--r--model/riscv_next_control.sail84
-rw-r--r--model/riscv_next_regs.sail96
-rw-r--r--model/riscv_pc_access.sail68
-rw-r--r--model/riscv_platform.sail120
-rw-r--r--model/riscv_pmp_control.sail218
-rw-r--r--model/riscv_pmp_regs.sail258
-rw-r--r--model/riscv_pte.sail154
-rw-r--r--model/riscv_ptw.sail121
-rw-r--r--model/riscv_reg_type.sail68
-rw-r--r--model/riscv_regs.sail74
-rw-r--r--model/riscv_softfloat_interface.sail68
-rw-r--r--model/riscv_step.sail74
-rw-r--r--model/riscv_step_common.sail68
-rw-r--r--model/riscv_step_ext.sail68
-rw-r--r--model/riscv_step_rvfi.sail68
-rw-r--r--model/riscv_sync_exception.sail68
-rw-r--r--model/riscv_sys_control.sail290
-rw-r--r--model/riscv_sys_exceptions.sail80
-rw-r--r--model/riscv_sys_regs.sail376
-rw-r--r--model/riscv_termination_common.sail68
-rw-r--r--model/riscv_termination_rv32.sail68
-rw-r--r--model/riscv_termination_rv64.sail68
-rw-r--r--model/riscv_types.sail99
-rw-r--r--model/riscv_types_common.sail68
-rw-r--r--model/riscv_types_ext.sail68
-rw-r--r--model/riscv_types_kext.sail92
-rwxr-xr-xmodel/riscv_vext_control.sail62
-rw-r--r--model/riscv_vext_regs.sail82
-rw-r--r--model/riscv_vlen.sail48
-rw-r--r--model/riscv_vmem.sail452
-rw-r--r--model/riscv_vmem_common.sail313
-rw-r--r--model/riscv_vmem_pte.sail135
-rw-r--r--model/riscv_vmem_ptw.sail66
-rw-r--r--model/riscv_vmem_rv32.sail137
-rw-r--r--model/riscv_vmem_rv64.sail176
-rw-r--r--model/riscv_vmem_sv32.sail262
-rw-r--r--model/riscv_vmem_sv39.sail256
-rw-r--r--model/riscv_vmem_sv48.sail218
-rw-r--r--model/riscv_vmem_tlb.sail203
-rw-r--r--model/riscv_vmem_types.sail68
-rwxr-xr-xmodel/riscv_vreg_type.sail44
-rw-r--r--model/riscv_xlen32.sail68
-rw-r--r--model/riscv_xlen64.sail68
-rw-r--r--model/rvfi_dii.sail148
-rw-r--r--ocaml_emulator/platform.ml11
-rw-r--r--ocaml_emulator/riscv_ocaml_sim.ml12
-rw-r--r--sail-riscv.install2
126 files changed, 4065 insertions, 9619 deletions
diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml
index fa3d1c4..865c748 100644
--- a/.github/workflows/compile.yml
+++ b/.github/workflows/compile.yml
@@ -22,13 +22,13 @@ jobs:
run: eval $(opam env) && test/run_tests.sh
- name: Upload test results
if: always()
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: tests.xml
path: test/tests.xml
- name: Upload event payload
if: always()
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: event.json
path: ${{ github.event_path }}
diff --git a/.github/workflows/test-results.yml b/.github/workflows/test-results.yml
index 65071cd..4201d46 100644
--- a/.github/workflows/test-results.yml
+++ b/.github/workflows/test-results.yml
@@ -12,11 +12,11 @@ jobs:
if: github.event.workflow_run.conclusion != 'skipped'
steps:
- name: Download artifacts
- uses: actions/github-script@v3.1.0
+ uses: actions/github-script@v6
with:
script: |
var fs = require('fs');
- var artifacts = await github.actions.listWorkflowRunArtifacts({
+ var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
@@ -27,7 +27,7 @@ jobs:
var count = matchArtifacts.length;
for (var i = 0; i < count; i++) {
var matchArtifact = matchArtifacts[i];
- var download = await github.actions.downloadArtifact({
+ var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
@@ -43,7 +43,7 @@ jobs:
- name: Extract event payload
run: unzip event.json.zip
- name: Publish test results
- uses: EnricoMi/publish-unit-test-result-action@v1
+ uses: EnricoMi/publish-unit-test-result-action@v2
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: event.json
diff --git a/CODE_STYLE.md b/CODE_STYLE.md
index 9483b01..4463e3a 100644
--- a/CODE_STYLE.md
+++ b/CODE_STYLE.md
@@ -15,6 +15,8 @@ Formatting
* Block-level indentation uses two spaces
+* Tabs should not be used
+
* There should be no trailing spaces on any lines
* All files should end with a newline character
diff --git a/LICENCE b/LICENCE
index ac2cff5..432b78d 100644
--- a/LICENCE
+++ b/LICENCE
@@ -5,25 +5,49 @@ directories except for the snapshots of the Lem and Sail libraries
in the prover_snapshots directory (which include copies of their
licences), is subject to the BSD two-clause licence below.
-Copyright (c) 2017-2023
- Prashanth Mundkur
- Rishiyur S. Nikhil and Bluespec, Inc.
- Jon French
- Brian Campbell
- Robert Norton-Wright
- Alasdair Armstrong
- Thomas Bauereiss
- Shaked Flur
- Christopher Pulte
- Peter Sewell
- Alexander Richardson
- Hesham Almatary
- Jessica Clarke
- Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo
- Peter Rugg
- Aril Computer Corp., for contributions by Scott Johnson
- Philipp Tomsich
- VRULL GmbH, for contributions by its employees
+Copyright (c) 2017-2024
+ ahadali5000
+ Alasdair Armstrong
+ Alexander Richardson
+ Aril Computer Corp., for contributions by Scott Johnson
+ Ben Marshall
+ Bicheng Yang
+ Bilal Sakhawat
+ Brian Campbell
+ Chris Casinghino
+ Christopher Pulte
+ Codasip, for contributions by Tim Hutt, Martin Berger and Ben Fletcher
+ dylux
+ eroom1966
+ Google LLC, for contributions by its employees
+ Hesham Almatary
+ Jan Henrik Weinstock
+ Jessica Clarke
+ Jon French
+ Martin Berger
+ Michael Sammler
+ Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo
+ Muhammad Bilal Sakhawat
+ Nathaniel Wesley Filardo
+ Paul A. Clarke
+ Peter Rugg
+ Peter Sewell
+ Philipp Tomsich
+ Prashanth Mundkur
+ Rafael Sene
+ Rishiyur S. Nikhil (Bluespec, Inc.)
+ Robert Norton-Wright
+ Scott Johnson (Aril Inc.)
+ Shaked Flur
+ Thibaut Pérami
+ Thomas Bauereiss
+ VRULL GmbH, for contributions by its employees
+ William McSpaddden
+ Xinlai Wan
+
+For a complete list of authors run this command:
+
+ git shortlog --summary --numbered --email
All rights reserved.
@@ -42,6 +66,7 @@ This project has received funding from the European Research Council
(ERC) under the European Union’s Horizon 2020 research and innovation
programme (grant agreement 789108, ELVER).
+------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
diff --git a/Makefile b/Makefile
index 9140065..7068968 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,9 @@ else ifeq ($(ARCH),64)
override ARCH := RV64
endif
+# Set OPAMCLI to 2.0 to supress warnings about opam config var
+export OPAMCLI := 2.0
+
ifeq ($(ARCH),RV32)
SAIL_XLEN := riscv_xlen32.sail
else ifeq ($(ARCH),RV64)
@@ -29,6 +32,8 @@ SAIL_DEFAULT_INST += riscv_insts_zbb.sail
SAIL_DEFAULT_INST += riscv_insts_zbc.sail
SAIL_DEFAULT_INST += riscv_insts_zbs.sail
+SAIL_DEFAULT_INST += riscv_insts_zcb.sail
+
SAIL_DEFAULT_INST += riscv_insts_zfh.sail
# Zfa needs to be added after fext, dext and Zfh (as it needs
# definitions from those)
@@ -68,18 +73,24 @@ SAIL_SYS_SRCS += riscv_softfloat_interface.sail riscv_fdext_regs.sail riscv_fdex
SAIL_SYS_SRCS += riscv_csr_ext.sail # access to CSR extensions
SAIL_SYS_SRCS += riscv_sys_control.sail # general exception handling
-SAIL_RV32_VM_SRCS = riscv_vmem_sv32.sail riscv_vmem_rv32.sail
-SAIL_RV64_VM_SRCS = riscv_vmem_sv39.sail riscv_vmem_sv48.sail riscv_vmem_rv64.sail
+# SAIL_RV32_VM_SRCS = riscv_vmem_sv32.sail riscv_vmem_rv32.sail
+# SAIL_RV64_VM_SRCS = riscv_vmem_sv39.sail riscv_vmem_sv48.sail riscv_vmem_rv64.sail
-SAIL_VM_SRCS = riscv_pte.sail riscv_ptw.sail riscv_vmem_common.sail riscv_vmem_tlb.sail
-ifeq ($(ARCH),RV32)
-SAIL_VM_SRCS += $(SAIL_RV32_VM_SRCS)
-else
-SAIL_VM_SRCS += $(SAIL_RV64_VM_SRCS)
-endif
+# SAIL_VM_SRCS = riscv_pte.sail riscv_ptw.sail riscv_vmem_common.sail riscv_vmem_tlb.sail
+# ifeq ($(ARCH),RV32)
+# SAIL_VM_SRCS += $(SAIL_RV32_VM_SRCS)
+# else
+# SAIL_VM_SRCS += $(SAIL_RV64_VM_SRCS)
+# endif
+
+SAIL_VM_SRCS += riscv_vmem_common.sail
+SAIL_VM_SRCS += riscv_vmem_pte.sail
+SAIL_VM_SRCS += riscv_vmem_ptw.sail
+SAIL_VM_SRCS += riscv_vmem_tlb.sail
+SAIL_VM_SRCS += riscv_vmem.sail
# Non-instruction sources
-PRELUDE = prelude.sail prelude_mapping.sail $(SAIL_XLEN) $(SAIL_FLEN) $(SAIL_VLEN) prelude_mem_metadata.sail prelude_mem.sail
+PRELUDE = prelude.sail $(SAIL_XLEN) $(SAIL_FLEN) $(SAIL_VLEN) prelude_mem_metadata.sail prelude_mem.sail
SAIL_REGS_SRCS = riscv_reg_type.sail riscv_freg_type.sail riscv_regs.sail riscv_pc_access.sail riscv_sys_regs.sail
SAIL_REGS_SRCS += riscv_pmp_regs.sail riscv_pmp_control.sail
@@ -184,15 +195,7 @@ C_LIBS += $(SAIL_LIB_DIR)/coverage/libsail_coverage.a -lm -lpthread -ldl
endif
RISCV_EXTRAS_LEM_FILES = riscv_extras.lem mem_metadata.lem riscv_extras_fdext.lem
-# Feature detect if we are on the latest development version of Sail
-# and use an updated lem file if so. This is just until the opam
-# version catches up with changes to the barrier type.
-SAIL_LATEST := $(shell $(SAIL) -have_feature FEATURE_UNION_BARRIER 1>&2 2> /dev/null; echo $$?)
-ifeq ($(SAIL_LATEST),0)
-RISCV_EXTRAS_LEM = $(addprefix handwritten_support/0.11/,$(RISCV_EXTRAS_LEM_FILES))
-else
RISCV_EXTRAS_LEM = $(addprefix handwritten_support/,$(RISCV_EXTRAS_LEM_FILES))
-endif
.PHONY:
@@ -252,9 +255,11 @@ gcovr:
ocaml_emulator/tracecmp: ocaml_emulator/tracecmp.ml
ocamlfind ocamlopt -annot -linkpkg -package unix $^ -o $@
+c_preserve_fns=-c_preserve _set_Misa_C
+
generated_definitions/c/riscv_model_$(ARCH).c: $(SAIL_SRCS) model/main.sail Makefile
mkdir -p generated_definitions/c
- $(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 $@)
+ $(SAIL) $(SAIL_FLAGS) $(c_preserve_fns) -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 $@)
generated_definitions/c2/riscv_model_$(ARCH).c: $(SAIL_SRCS) model/main.sail Makefile
mkdir -p generated_definitions/c2
@@ -293,7 +298,7 @@ rvfi_preserve_fns=-c_preserve rvfi_set_instr_packet \
# sed -i isn't posix compliant, unfortunately
generated_definitions/c/riscv_rvfi_model_$(ARCH).c: $(SAIL_RVFI_SRCS) model/main.sail Makefile
mkdir -p generated_definitions/c
- $(SAIL) $(rvfi_preserve_fns) $(SAIL_FLAGS) -O -Oconstant_fold -memo_z3 -c -c_include riscv_prelude.h -c_include riscv_platform.h -c_no_main $(SAIL_RVFI_SRCS) model/main.sail -o $(basename $@)
+ $(SAIL) $(c_preserve_fns) $(rvfi_preserve_fns) $(SAIL_FLAGS) -O -Oconstant_fold -memo_z3 -c -c_include riscv_prelude.h -c_include riscv_platform.h -c_no_main $(SAIL_RVFI_SRCS) model/main.sail -o $(basename $@)
sed -e '/^[[:space:]]*$$/d' $@ > $@.new
mv $@.new $@
@@ -322,12 +327,12 @@ endif
generated_definitions/lem/$(ARCH)/riscv.lem: $(SAIL_SRCS) Makefile
mkdir -p generated_definitions/lem/$(ARCH) generated_definitions/isabelle/$(ARCH)
- $(SAIL) $(SAIL_FLAGS) -lem -lem_output_dir generated_definitions/lem/$(ARCH) -isa_output_dir generated_definitions/isabelle/$(ARCH) -o riscv -lem_mwords -lem_lib Riscv_extras -lem_lib Riscv_extras_fdext -lem_lib Mem_metadata $(SAIL_SRCS)
+ $(SAIL) $(SAIL_FLAGS) -lem -lem_output_dir generated_definitions/lem/$(ARCH) -isa_output_dir generated_definitions/isabelle/$(ARCH) -o riscv -lem_lib Riscv_extras -lem_lib Riscv_extras_fdext -lem_lib Mem_metadata $(SAIL_SRCS)
echo "declare {isabelle} rename field sync_exception_ext = sync_exception_ext_exception" >> generated_definitions/lem/$(ARCH)/riscv_types.lem
# sed -i isn't posix compliant, unfortunately
generated_definitions/isabelle/$(ARCH)/Riscv.thy: generated_definitions/isabelle/$(ARCH)/ROOT generated_definitions/lem/$(ARCH)/riscv.lem $(RISCV_EXTRAS_LEM) Makefile
- lem -isa -outdir generated_definitions/isabelle/$(ARCH) -lib Sail=$(SAIL_SRC_DIR)/lem_interp -lib Sail=$(SAIL_SRC_DIR)/gen_lib \
+ lem -wl ign -isa -outdir generated_definitions/isabelle/$(ARCH) -lib Sail=$(SAIL_SRC_DIR)/lem_interp -lib Sail=$(SAIL_SRC_DIR)/gen_lib \
$(RISCV_EXTRAS_LEM) \
generated_definitions/lem/$(ARCH)/riscv_types.lem \
generated_definitions/lem/$(ARCH)/riscv.lem
@@ -448,7 +453,7 @@ generated_definitions/for-rmem/riscv.defs: $(SAIL_RMEM_SRCS)
FORCE:
-SHARE_FILES:=$(sort $(wildcard model/*.sail)) $(sort $(wildcard c_emulator/*.c)) $(sort $(wildcard c_emulator/*.h)) $(sort $(wildcard handwritten_support/*.lem)) $(sort $(wildcard handwritten_support/hgen/*.hgen)) $(sort $(wildcard handwritten_support/0.11/*.lem)) $(RMEM_FILES)
+SHARE_FILES:=$(sort $(wildcard model/*.sail)) $(sort $(wildcard c_emulator/*.c)) $(sort $(wildcard c_emulator/*.h)) $(sort $(wildcard handwritten_support/*.lem)) $(sort $(wildcard handwritten_support/hgen/*.hgen)) $(RMEM_FILES)
sail-riscv.install: FORCE
echo 'bin: ["c_emulator/riscv_sim_RV64" "c_emulator/riscv_sim_RV32"]' > sail-riscv.install
echo 'share: [ $(foreach f,$(SHARE_FILES),"$f" {"$f"}) ]' >> sail-riscv.install
diff --git a/c_emulator/riscv_platform.c b/c_emulator/riscv_platform.c
index fbd63fa..6544de6 100644
--- a/c_emulator/riscv_platform.c
+++ b/c_emulator/riscv_platform.c
@@ -32,6 +32,11 @@ bool sys_enable_fdext(unit u)
return rv_enable_fdext;
}
+bool sys_enable_zcb(unit u)
+{
+ return rv_enable_zcb;
+}
+
bool sys_enable_zfinx(unit u)
{
return rv_enable_zfinx;
@@ -47,6 +52,16 @@ bool sys_enable_vext(unit u)
return rv_enable_vext;
}
+uint64_t sys_pmp_count(unit u)
+{
+ return rv_pmp_count;
+}
+
+uint64_t sys_pmp_grain(unit u)
+{
+ return rv_pmp_grain;
+}
+
bool sys_enable_writable_misa(unit u)
{
return rv_enable_writable_misa;
@@ -67,11 +82,6 @@ bool plat_mtval_has_illegal_inst_bits(unit u)
return rv_mtval_has_illegal_inst_bits;
}
-bool plat_enable_pmp(unit u)
-{
- return rv_enable_pmp;
-}
-
mach_bits plat_ram_base(unit u)
{
return rv_ram_base;
diff --git a/c_emulator/riscv_platform.h b/c_emulator/riscv_platform.h
index 4b6541f..4a53d12 100644
--- a/c_emulator/riscv_platform.h
+++ b/c_emulator/riscv_platform.h
@@ -4,15 +4,18 @@
bool sys_enable_rvc(unit);
bool sys_enable_next(unit);
bool sys_enable_fdext(unit);
+bool sys_enable_zcb(unit);
bool sys_enable_zfinx(unit);
bool sys_enable_writable_misa(unit);
bool sys_enable_writable_fiom(unit);
bool sys_enable_vext(unit);
+uint64_t sys_pmp_count(unit);
+uint64_t sys_pmp_grain(unit);
+
bool plat_enable_dirty_update(unit);
bool plat_enable_misaligned_access(unit);
bool plat_mtval_has_illegal_inst_bits(unit);
-bool plat_enable_pmp(unit);
mach_bits plat_ram_base(unit);
mach_bits plat_ram_size(unit);
diff --git a/c_emulator/riscv_platform_impl.c b/c_emulator/riscv_platform_impl.c
index 15ff8ad..449bb1d 100644
--- a/c_emulator/riscv_platform_impl.c
+++ b/c_emulator/riscv_platform_impl.c
@@ -3,7 +3,10 @@
#include <stdio.h>
/* Settings of the platform implementation, with common defaults. */
-bool rv_enable_pmp = false;
+uint64_t rv_pmp_count = 0;
+uint64_t rv_pmp_grain = 0;
+
+bool rv_enable_zcb = false;
bool rv_enable_zfinx = false;
bool rv_enable_rvc = true;
bool rv_enable_next = false;
diff --git a/c_emulator/riscv_platform_impl.h b/c_emulator/riscv_platform_impl.h
index e5c562a..d377c9c 100644
--- a/c_emulator/riscv_platform_impl.h
+++ b/c_emulator/riscv_platform_impl.h
@@ -8,7 +8,10 @@
#define DEFAULT_RSTVEC 0x00001000
-extern bool rv_enable_pmp;
+extern uint64_t rv_pmp_count;
+extern uint64_t rv_pmp_grain;
+
+extern bool rv_enable_zcb;
extern bool rv_enable_zfinx;
extern bool rv_enable_rvc;
extern bool rv_enable_next;
diff --git a/c_emulator/riscv_sim.c b/c_emulator/riscv_sim.c
index 13d1653..bf68da2 100644
--- a/c_emulator/riscv_sim.c
+++ b/c_emulator/riscv_sim.c
@@ -51,6 +51,9 @@ const char *RV32ISA = "RV32IMAC";
#define OPT_TRACE_OUTPUT 1000
#define OPT_ENABLE_WRITABLE_FIOM 1001
+#define OPT_PMP_COUNT 1002
+#define OPT_PMP_GRAIN 1003
+#define OPT_ENABLE_ZCB 10014
static bool do_dump_dts = false;
static bool do_show_times = false;
@@ -119,7 +122,8 @@ char *sailcov_file = NULL;
static struct option options[] = {
{"enable-dirty-update", no_argument, 0, 'd' },
{"enable-misaligned", no_argument, 0, 'm' },
- {"enable-pmp", no_argument, 0, 'P' },
+ {"pmp-count", required_argument, 0, OPT_PMP_COUNT },
+ {"pmp-grain", required_argument, 0, OPT_PMP_GRAIN },
{"enable-next", no_argument, 0, 'N' },
{"ram-size", required_argument, 0, 'z' },
{"disable-compressed", no_argument, 0, 'C' },
@@ -142,6 +146,7 @@ static struct option options[] = {
{"inst-limit", required_argument, 0, 'l' },
{"enable-zfinx", no_argument, 0, 'x' },
{"enable-writable-fiom", no_argument, 0, OPT_ENABLE_WRITABLE_FIOM},
+ {"enable-zcb", no_argument, 0, OPT_ENABLE_ZCB },
#ifdef SAILCOV
{"sailcov-file", required_argument, 0, 'c' },
#endif
@@ -236,6 +241,8 @@ static int process_args(int argc, char **argv)
{
int c;
uint64_t ram_size = 0;
+ uint64_t pmp_count = 0;
+ uint64_t pmp_grain = 0;
while (true) {
c = getopt_long(argc, argv,
"a"
@@ -281,9 +288,23 @@ static int process_args(int argc, char **argv)
fprintf(stderr, "enabling misaligned access.\n");
rv_enable_misaligned = true;
break;
- case 'P':
- fprintf(stderr, "enabling PMP support.\n");
- rv_enable_pmp = true;
+ case OPT_PMP_COUNT:
+ pmp_count = atol(optarg);
+ fprintf(stderr, "PMP count: %" PRIu64 "\n", pmp_count);
+ if (pmp_count != 0 && pmp_count != 16 && pmp_count != 64) {
+ fprintf(stderr, "invalid PMP count: must be 0, 16 or 64");
+ exit(1);
+ }
+ rv_pmp_count = pmp_count;
+ break;
+ case OPT_PMP_GRAIN:
+ pmp_grain = atol(optarg);
+ fprintf(stderr, "PMP grain: %" PRIu64 "\n", pmp_grain);
+ if (pmp_grain >= 64) {
+ fprintf(stderr, "invalid PMP grain: must less than 64");
+ exit(1);
+ }
+ rv_pmp_grain = pmp_grain;
break;
case 'C':
fprintf(stderr, "disabling RVC compressed instructions.\n");
@@ -367,6 +388,10 @@ static int process_args(int argc, char **argv)
case 'l':
insn_limit = atoi(optarg);
break;
+ case OPT_ENABLE_ZCB:
+ fprintf(stderr, "enabling Zcb extension.\n");
+ rv_enable_zcb = true;
+ break;
case 'x':
fprintf(stderr, "enabling Zfinx support.\n");
rv_enable_zfinx = true;
diff --git a/doc/figs/notes_Virtual_Memory_Fig1.svg b/doc/figs/notes_Virtual_Memory_Fig1.svg
new file mode 100644
index 0000000..4c5b224
--- /dev/null
+++ b/doc/figs/notes_Virtual_Memory_Fig1.svg
@@ -0,0 +1,1027 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ width="8.0886383in"
+ height="2.3645477in"
+ viewBox="0 0 205.4514 60.059512"
+ version="1.1"
+ id="svg8"
+ sodipodi:docname="notes_Virtual_Memory_Fig1.svg"
+ inkscape:version="1.3 (0e150ed, 2023-07-21)"
+ inkscape:export-filename="/home/nikhil/git_clones/BESSPIN-CloudGFE/AWSteria_RISCV_Virtio/Doc/Fig_010_AWSteria_RISCV_Virtio.png"
+ inkscape:export-xdpi="96"
+ inkscape:export-ydpi="96"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <defs
+ id="defs2">
+ <marker
+ style="overflow:visible"
+ id="marker6"
+ refX="0"
+ refY="0"
+ orient="auto-start-reverse"
+ inkscape:stockid="Triangle arrow"
+ markerWidth="1"
+ markerHeight="1"
+ viewBox="0 0 1 1"
+ inkscape:isstock="true"
+ inkscape:collect="always"
+ preserveAspectRatio="xMidYMid">
+ <path
+ transform="scale(0.5)"
+ style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
+ d="M 5.77,0 -2.88,5 V -5 Z"
+ id="path6" />
+ </marker>
+ <marker
+ style="overflow:visible"
+ id="marker4"
+ refX="0"
+ refY="0"
+ orient="auto-start-reverse"
+ inkscape:stockid="Triangle arrow"
+ markerWidth="1"
+ markerHeight="1"
+ viewBox="0 0 1 1"
+ inkscape:isstock="true"
+ inkscape:collect="always"
+ preserveAspectRatio="xMidYMid">
+ <path
+ transform="scale(0.5)"
+ style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
+ d="M 5.77,0 -2.88,5 V -5 Z"
+ id="path4" />
+ </marker>
+ <marker
+ style="overflow:visible"
+ id="Triangle"
+ refX="0"
+ refY="0"
+ orient="auto-start-reverse"
+ inkscape:stockid="Triangle arrow"
+ markerWidth="1"
+ markerHeight="1"
+ viewBox="0 0 1 1"
+ inkscape:isstock="true"
+ inkscape:collect="always"
+ preserveAspectRatio="xMidYMid">
+ <path
+ transform="scale(0.5)"
+ style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
+ d="M 5.77,0 -2.88,5 V -5 Z"
+ id="path135" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker1546"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path1544"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker1380"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path1378"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.4,0,0,0.4,4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ style="overflow:visible"
+ id="Arrow1Send"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow1Send"
+ inkscape:isstock="true">
+ <path
+ transform="matrix(-0.2,0,0,-0.2,-1.2,0)"
+ style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ id="path118023"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker2384"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path2382"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker5333"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path5331"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker5323"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path5321"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker4147"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path4145"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker2243"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path2241"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#a20000;fill-opacity:1;fill-rule:evenodd;stroke:#a20000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker1817"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path1157"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.4,0,0,0.4,4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Sstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Sstart"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path1066"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.2,0,0,0.2,1.2,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker2666"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path2664"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.4,0,0,0.4,4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mend"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path1081"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(-0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker2486"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path2484"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker2404"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path2402"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path1057"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Mstart"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path1060"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.4,0,0,0.4,4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lstart"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path1054"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.8,0,0,0.8,10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lstart"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path1072"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(1.1,0,0,1.1,1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path1075"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Tail"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Tail"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <g
+ id="g1102"
+ transform="scale(-1.2)"
+ style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-opacity:1">
+ <path
+ id="path1090"
+ d="M -3.8048674,-3.9585227 0.54352094,0"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path1092"
+ d="M -1.2866832,-3.9585227 3.0617053,0"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path1094"
+ d="M 1.3053582,-3.9585227 5.6537466,0"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path1096"
+ d="M -3.8048674,4.1775838 0.54352094,0.21974226"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path1098"
+ d="M -1.2866832,4.1775838 3.0617053,0.21974226"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path1100"
+ d="M 1.3053582,4.1775838 5.6537466,0.21974226"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1"
+ inkscape:connector-curvature="0" />
+ </g>
+ </marker>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.180926"
+ inkscape:cx="388.67802"
+ inkscape:cy="113.89367"
+ inkscape:document-units="mm"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ units="in"
+ inkscape:showpageshadow="false"
+ inkscape:window-width="1472"
+ inkscape:window-height="840"
+ inkscape:window-x="0"
+ inkscape:window-y="37"
+ inkscape:window-maximized="0"
+ inkscape:document-rotation="0"
+ inkscape:snap-global="false"
+ inkscape:pagecheckerboard="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0"
+ showborder="true"
+ inkscape:deskcolor="#d1d1d1" />
+ <metadata
+ id="metadata5">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-101.49153,-112.42737)">
+ <rect
+ style="fill:#fff1cc;fill-opacity:1;stroke:#000000;stroke-width:0.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect4939"
+ width="125.49309"
+ height="55.944481"
+ x="137.12114"
+ y="114.31551"
+ ry="2.3316531"
+ rx="2.5557346" />
+ <text
+ transform="scale(0.81534918,1.2264684)"
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.58873px;line-height:1.25;font-family:'Ubuntu Mono';-inkscape-font-specification:'Ubuntu Mono, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ x="97.405945"
+ y="134.38924"
+ id="text974" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1059"
+ style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"><flowRegion
+ id="flowRegion1061"><rect
+ id="rect1063"
+ width="80.070229"
+ height="88.413681"
+ x="371.76654"
+ y="181.8848" /></flowRegion><flowPara
+ id="flowPara1065" /></flowRoot>
+ <g
+ id="g9"
+ transform="translate(-49.622752,35.523771)">
+ <rect
+ ry="0"
+ y="108.40541"
+ x="192.79189"
+ height="7.1145091"
+ width="14.717851"
+ id="rect1236"
+ style="fill:#ffdd55;stroke:#000000;stroke-width:0.202686;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ rx="0" />
+ <text
+ id="text1256"
+ y="111.11807"
+ x="200.02472"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:0;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan1254"
+ style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;stroke-width:0.264583"
+ y="111.11807"
+ x="200.02472"
+ sodipodi:role="line">register</tspan><tspan
+ style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;line-height:0.95;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;stroke-width:0.264583"
+ y="114.22251"
+ x="200.02472"
+ sodipodi:role="line"
+ id="tspan7">satp</tspan></text>
+ </g>
+ <text
+ id="text13675"
+ y="147.06259"
+ x="115.48001"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan13673"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="147.06259"
+ x="115.48001"
+ sodipodi:role="line">readCSR()</tspan></text>
+ <text
+ id="text1"
+ y="152.38425"
+ x="114.99237"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan1"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="152.38425"
+ x="114.99237"
+ sodipodi:role="line">writeCSR()</tspan></text>
+ <text
+ id="text2"
+ y="127.36551"
+ x="118.3431"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan2"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="127.36551"
+ x="118.3431"
+ sodipodi:role="line">Exec Fetch</tspan></text>
+ <text
+ id="text4"
+ y="162.47141"
+ x="106.89098"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan4"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="162.47141"
+ x="106.89098"
+ sodipodi:role="line">Exec SFENCE.VMA</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#800000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ x="138.24333"
+ y="118.39961"
+ id="text5"><tspan
+ sodipodi:role="line"
+ x="138.24333"
+ y="118.39961"
+ style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#800000;fill-opacity:1;stroke-width:0.264583"
+ id="tspan5">PUBLIC</tspan></text>
+ <text
+ id="text10"
+ y="154.81339"
+ x="143.27039"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan10"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="154.81339"
+ x="143.27039"
+ sodipodi:role="line">legalize_satp()</tspan></text>
+ <path
+ style="fill:#ffffff;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#Triangle)"
+ d="m 131.08217,146.10039 9.72194,1.41668"
+ id="path10" />
+ <path
+ style="fill:#ffffff;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#Triangle)"
+ d="m 131.01779,150.84595 9.72193,-1.41668"
+ id="path11" />
+ <path
+ style="fill:#ffffff;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#Triangle)"
+ d="m 131.01779,152.20482 9.72193,1.41668"
+ id="path12" />
+ <text
+ id="text12"
+ y="129.33925"
+ x="140.94533"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan12"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="129.33925"
+ x="140.94533"
+ sodipodi:role="line">translateAddr()</tspan></text>
+ <text
+ id="text14"
+ y="137.06709"
+ x="138.13412"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan14"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="137.06709"
+ x="138.13412"
+ sodipodi:role="line">union TR_Result</tspan></text>
+ <path
+ style="fill:#ffffff;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#Triangle)"
+ d="m 134.27151,126.52583 5.24514,1.24367"
+ id="path1" />
+ <path
+ style="fill:#ffffff;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#Triangle)"
+ d="m 134.27649,130.40406 5.1777,-1.00431"
+ id="path2" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#marker4)"
+ d="m 152.7748,130.1562 v 4.02821 l -20.82878,0.0982"
+ id="path3"
+ sodipodi:nodetypes="ccc" />
+ <rect
+ style="fill:#ffeb8c;fill-opacity:1;stroke:#000000;stroke-width:0.250001;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect23780"
+ width="95.946877"
+ height="50.37587"
+ x="166.65634"
+ y="119.94226"
+ ry="2.0797374"
+ rx="2.7964213" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#800000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ x="167.70322"
+ y="123.9887"
+ id="text6"><tspan
+ sodipodi:role="line"
+ x="167.70322"
+ y="123.9887"
+ style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#800000;fill-opacity:1;stroke-width:0.264583"
+ id="tspan6">PRIVATE</tspan></text>
+ <rect
+ style="fill:#f5f5f5;fill-opacity:1;stroke:#000000;stroke-width:0.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1098"
+ width="93.787857"
+ height="26.170418"
+ x="169.13605"
+ y="143.96143"
+ ry="3.3773639"
+ rx="3.2054558" />
+ <text
+ id="text11"
+ y="129.4375"
+ x="171.20601"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan11"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="129.4375"
+ x="171.20601"
+ sodipodi:role="line">translate()</tspan></text>
+ <text
+ id="text16"
+ y="152.201"
+ x="241.45401"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan16"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="152.201"
+ x="241.45401"
+ sodipodi:role="line">add_to_TLB()</tspan></text>
+ <text
+ id="text17"
+ y="152.201"
+ x="216.80208"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan17"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="152.201"
+ x="216.80208"
+ sodipodi:role="line">write_TLB()</tspan></text>
+ <text
+ id="text19"
+ y="129.06493"
+ x="266.80228"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan19"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="129.06493"
+ x="266.80228"
+ sodipodi:role="line">mem_read_priv()</tspan></text>
+ <text
+ id="text20"
+ y="136.8886"
+ x="266.80225"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan20"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="136.8886"
+ x="266.80225"
+ sodipodi:role="line">mem_write_value_priv()</tspan></text>
+ <rect
+ style="fill:#e8e8e8;fill-opacity:1;stroke:#000000;stroke-width:0.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect20"
+ width="71.976585"
+ height="16.149025"
+ x="191.1438"
+ y="154.08107"
+ ry="2.0840757"
+ rx="2.4599962" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#800000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ x="192.46194"
+ y="158.02766"
+ id="text21"><tspan
+ sodipodi:role="line"
+ x="192.46194"
+ y="158.02766"
+ style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#800000;fill-opacity:1;stroke-width:0.264583"
+ id="tspan21">PRIVATE</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#800000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ x="170.6655"
+ y="147.87431"
+ id="text22"><tspan
+ sodipodi:role="line"
+ x="170.6655"
+ y="147.87431"
+ style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#800000;fill-opacity:1;stroke-width:0.264583"
+ id="tspan22">PUBLIC</tspan></text>
+ <g
+ id="g10"
+ transform="translate(-30.652516,-12.719399)">
+ <rect
+ ry="0"
+ y="174.35956"
+ x="223.64394"
+ height="7.1145091"
+ width="14.717851"
+ id="rect7"
+ style="fill:#ffdd55;stroke:#000000;stroke-width:0.202686;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ rx="0" />
+ <text
+ id="text9"
+ y="177.07222"
+ x="230.87677"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:0;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan8"
+ style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;stroke-width:0.264583"
+ y="177.07222"
+ x="230.87677"
+ sodipodi:role="line">register</tspan><tspan
+ style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;line-height:0.95;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;stroke-width:0.264583"
+ y="180.17667"
+ x="230.87677"
+ sodipodi:role="line"
+ id="tspan9">tlb</tspan></text>
+ </g>
+ <text
+ id="text23"
+ y="129.4375"
+ x="199.20695"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan23"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="129.4375"
+ x="199.20695"
+ sodipodi:role="line">translate_TLB_miss()</tspan></text>
+ <text
+ id="text24"
+ y="137.29741"
+ x="195.8665"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan24"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="137.29741"
+ x="195.8665"
+ sodipodi:role="line">translate_TLB_hit()</tspan></text>
+ <text
+ id="text25"
+ y="152.201"
+ x="188.56508"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan25"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="152.201"
+ x="188.56508"
+ sodipodi:role="line">lookup_TLB()</tspan></text>
+ <text
+ id="text26"
+ y="167.38203"
+ x="143.40154"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan26"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="167.38203"
+ x="143.40154"
+ sodipodi:role="line">init_vmem()</tspan></text>
+ <text
+ id="text27"
+ y="167.28378"
+ x="172.77797"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan27"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="167.28378"
+ x="172.77797"
+ sodipodi:role="line">init_TLB()</tspan></text>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#marker6)"
+ d="m 161.71545,166.40828 h 9.43685"
+ id="path27" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#marker6)"
+ d="m 133.911,166.60478 h 7.03222"
+ id="path28" />
+ <text
+ id="text28"
+ y="167.39078"
+ x="115.92992"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan28"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="167.39078"
+ x="115.92992"
+ sodipodi:role="line">init_model()</tspan></text>
+ <path
+ style="fill:#ffffff;stroke:#000000;stroke-width:0.250001;stroke-dasharray:none;marker-end:url(#Triangle)"
+ d="m 176.87577,129.89865 10.83428,18.5958"
+ id="path29" />
+ <path
+ style="fill:#ffffff;stroke:#000000;stroke-width:0.249999;stroke-dasharray:none;marker-end:url(#Triangle)"
+ d="m 186.89072,128.86365 7.96138,5.91995"
+ id="path31" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.249999;stroke-dasharray:none;marker-end:url(#marker6)"
+ d="m 186.76893,128.64926 h 10.72358"
+ id="path32" />
+ <text
+ id="text32"
+ y="129.4375"
+ x="238.05617"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan32"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="129.4375"
+ x="238.05617"
+ sodipodi:role="line">pt_walk()</tspan></text>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.249999;stroke-dasharray:none;marker-end:url(#marker6)"
+ d="m 231.21921,128.64926 h 5.27935"
+ id="path33" />
+ <text
+ id="text33"
+ y="168.06976"
+ x="213.94431"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan33"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="168.06976"
+ x="213.94431"
+ sodipodi:role="line">make_TLB_Entry()</tspan></text>
+ <text
+ id="text18"
+ y="158.48621"
+ x="213.68057"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan18"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="158.48621"
+ x="213.68057"
+ sodipodi:role="line">match_TLB_Entry()</tspan></text>
+ <text
+ id="text13"
+ y="162.36276"
+ x="173.46573"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan13"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="162.36276"
+ x="173.46573"
+ sodipodi:role="line">flush_TLB()</tspan></text>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#marker6)"
+ d="m 133.91099,161.48895 h 37.84215"
+ id="path5" />
+ <text
+ id="text15"
+ y="163.39867"
+ x="213.97531"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan15"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="163.39867"
+ x="213.97531"
+ sodipodi:role="line">flush_TLB_Entry()</tspan></text>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#marker6)"
+ d="m 252.20272,128.64926 h 13.71791"
+ id="path34" />
+ <path
+ style="fill:#ffffff;stroke:#000000;stroke-width:0.250001;stroke-dasharray:none;marker-end:url(#Triangle)"
+ d="m 252.27727,128.30859 13.41221,7.08193"
+ id="path35" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#marker6)"
+ d="m 223.7105,136.54059 h 42.02785"
+ id="path36" />
+ <path
+ style="fill:#ffffff;stroke:#000000;stroke-width:0.249998;stroke-dasharray:none;marker-end:url(#Triangle)"
+ d="m 197.59749,137.97424 17.60506,12.38488"
+ id="path37" />
+ <path
+ style="fill:#ffffff;stroke:#000000;stroke-width:0.249997;stroke-dasharray:none;marker-end:url(#Triangle)"
+ d="m 223.9594,130.04656 16.5295,19.76265"
+ id="path38" />
+ <text
+ id="text38"
+ y="116.68557"
+ x="186.33632"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:'Courier New';-inkscape-font-specification:'Courier New Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan38"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.82222px;font-family:'Courier New';-inkscape-font-specification:'Courier New Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="116.68557"
+ x="186.33632"
+ sodipodi:role="line">riscv_vmem.sail</tspan></text>
+ <text
+ id="text39"
+ y="146.455"
+ x="203.03865"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:'Courier New';-inkscape-font-specification:'Courier New Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan39"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.82222px;font-family:'Courier New';-inkscape-font-specification:'Courier New Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="146.455"
+ x="203.03865"
+ sodipodi:role="line">riscv_vmem_tlb.sail</tspan></text>
+ <text
+ id="text40"
+ y="145.43625"
+ x="266.60574"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan40"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="145.43625"
+ x="266.60574"
+ sodipodi:role="line">satp64Mode_of_Bits()</tspan></text>
+ <text
+ id="text41"
+ y="150.93819"
+ x="266.50751"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan41"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="150.93819"
+ x="266.50751"
+ sodipodi:role="line">cur_privilege</tspan></text>
+ <text
+ id="text42"
+ y="154.67165"
+ x="266.40927"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan42"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="154.67165"
+ x="266.40927"
+ sodipodi:role="line">effectivePrivilege()</tspan></text>
+ <text
+ id="text43"
+ y="131.39372"
+ x="102.97906"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan43"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="131.39372"
+ x="102.97906"
+ sodipodi:role="line">Exec Load/Store/AMO</tspan></text>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25;stroke-dasharray:none;marker-end:url(#marker6)"
+ d="m 162.96671,128.551 h 6.88608"
+ id="path43" />
+ <text
+ id="text3"
+ y="158.58211"
+ x="266.40927"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
+ xml:space="preserve"><tspan
+ id="tspan3"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:2.82222px;font-family:sans-serif;-inkscape-font-specification:sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.264583"
+ y="158.58211"
+ x="266.40927"
+ sodipodi:role="line">plat_enable_dirty_update()</tspan></text>
+ <rect
+ style="fill:none;stroke:#000000;stroke-width:0.0999998;stroke-dasharray:none"
+ id="rect1"
+ width="205.35141"
+ height="59.959511"
+ x="101.54153"
+ y="112.47737"
+ rx="0"
+ ry="0" />
+ </g>
+</svg>
diff --git a/doc/notes_Virtual_Memory.adoc b/doc/notes_Virtual_Memory.adoc
new file mode 100644
index 0000000..fba39a1
--- /dev/null
+++ b/doc/notes_Virtual_Memory.adoc
@@ -0,0 +1,119 @@
+= Notes on the Virtual Memory part Sail RISC-V Spec
+
+NOTE: this is an AsciiDoc document and can be processed into
+ browser-readable HTML by the free, open-source tool
+ `asciidoctor`.
+
+NOTE: If you are a code maintainer, kindly update this document if
+ there are any significant developements in vmem code.
+
+This is a commentary/reader's guide to the virtual memory ("vmem")
+code in the Sail RISC-V Formal Spec ("Golden Model"). The primary
+vmem specification code is in file:
+
+ model/riscv_vmem.sail
+
+Additional files:
+
+ model/riscv_vmem_common.sail
+ model/riscv_vmem_pte.sail
+ model/riscv_vmem_ptw.sail
+ model/riscv_vmem_tlb.sail
+ model/riscv_vmem_types.sail
+
+`riscv_vmem_common.sail` contains the parameterization for Sv32, Sv39,
+Sv48 and Sv57.
+
+`riscv_vmem_pte.sail` describes Page Table Entries, checks for
+permission bits, etc.
+
+`riscv_vmem_ptw.sail` describes Page Table Walk exceptions.
+
+`riscv_vmem_tlb.sail` implements a simple TLB (Translation Look-Aside
+Buffer). TLBs are not part of the RISC-V architecture spec.
+Nevertheless, it is useful to model at least a minimal TLB so that we
+can demonstrate and test SFENCE.VMA functionality (without TLBs,
+SFENCE.VMA is a no-op and there's nothing to test).
+
+TLBs are also useful for sail-riscv model simulation speed. Without a
+TLB, every Fetch and Load/Store/AMO in virtual memory mode requires a
+full page table walk. Speed matters mostly for large simulations
+(e.g., Linux-boot can speed up from tens of minutes to a few minutes).
+
+The main vmem code in `riscv_vmem.sail` is structured and commented to
+make it is easy to ignore/skip TLB-related parts.
+
+`riscv_vmem_types.sail` concerns non-standard extensions to the vmem
+system and can be ignored (it is used, e.g., by U.Cambridge's CHERI
+system).
+
+// SECTION ================================================================
+== Simplified call graph
+
+The following figure shows a rough call graph, and this can serve as a
+guide for understanding the code.
+
+image::./figs/notes_Virtual_Memory_Fig1.svg[align="center"]
+
+The yellow rectangle(s) represent the code in `riscv_vmem.sail`, and
+the grey rectangle(s) represent the code in `riscv_vmem_tlb.sail`. In
+each case, the lighter outer rectangle shows the publicly visible
+resources ("API"), and the darker inner rectangle shows internal
+(private) resources.
+
+On the left are shown the external places from which the vmem code is
+invoked, using its public resources. On the right are shown the
+external resources used by the vmem code.
+
+The main flow (ignoring TLBs) is at the top: The external execution
+code for instruction fetch, load, store and AMO invoke
+`translateAddr()` and receive a result of `TR_Result` type.
+`translateAddr()`, in turn, invokes `translate()`,
+`translate_TLB_miss()` and `pt_walk()`; the latter invokes the
+external `mem_read_priv()` to read PTEs (Page Table Entries) from
+memory. The SATP register lives in this vmem code, and is accessed by
+the external general `readCSR()` and `writeCSR()` functions.
+
+`translate()` invokes `lookup_TLB()` and, if a hit, invokes
+`translate_TLB_hit()`, avoiding a page-table walk (and therefore no
+reads from memory).
+
+`mem_write_value_priv()` is called for writing back, to memory, PTEs
+(Page Table Entries) whose A and/or D bits have been modified as part
+of the access.
+
+// SECTION ================================================================
+== Status
+
+* 2024-02-18: Many stylistic updates based on PR comments.
+
+* 2023-11-30: Passing all ISA tests in `tests/riscv-tests` (163 for
+ RV32 and 229 for RV64, about half of which run with Virtual Memory).
+ Also passing 712 tests in GitHub CI flow.
+
+* 2023-11-30: Sv57 not yet implemented (the code has placeholders
+ for Sv57 support; search for "Sv57")
+
+* 2023-11-30: Sv48 or Sv57 have not been tested; we do not have any tests for them.
+
+// SECTION ================================================================
+== Diary notes
+
+2019: Original code written, primarily by https://github.com/pmundkur[@pmundkur]
+
+2023-11: Refactored by https://github.com/rsnikhil[@rsnikhil] for:
+
+* Unifying previously separate RV32/RV64, Sv32/Sv39/Sv57 code into a
+ single, parameterized code.
+* Misc. stylistic improvements.
+* Deleted older files:
++
+ riscv_pte.sail
+ riscv_ptw.sail
+ riscv_vmem_common.sail
+ riscv_vmem_rv32.sail
+ riscv_vmem_rv64.sail
+ riscv_vmem_sv32.sail
+ riscv_vmem_sv39.sail
+ riscv_vmem_sv48.sail
++
diff --git a/handwritten_support/0.11/mem_metadata.lem b/handwritten_support/0.11/mem_metadata.lem
deleted file mode 100644
index 8a8c070..0000000
--- a/handwritten_support/0.11/mem_metadata.lem
+++ /dev/null
@@ -1,16 +0,0 @@
-open import Pervasives
-open import Pervasives_extra
-open import Sail2_instr_kinds
-open import Sail2_values
-open import Sail2_operators_mwords
-open import Sail2_prompt_monad
-open import Sail2_prompt
-
-val write_ram : forall 'rv 'e 'a 'n. Size 'a, Size 'n => write_kind -> mword 'a -> integer -> mword 'n -> unit -> monad 'rv bool 'e
-let write_ram wk addr width data meta =
- write_mem wk () addr width data
-
-val read_ram : forall 'rv 'e 'a 'n. Size 'a, Size 'n => read_kind -> mword 'a -> integer -> bool -> monad 'rv (mword 'n * unit) 'e
-let read_ram rk addr width read_tag =
- read_mem rk () addr width >>= (fun (data : mword 'n) ->
- return (data, ()))
diff --git a/handwritten_support/0.11/riscv_extras.lem b/handwritten_support/0.11/riscv_extras.lem
deleted file mode 100644
index 2509057..0000000
--- a/handwritten_support/0.11/riscv_extras.lem
+++ /dev/null
@@ -1,172 +0,0 @@
-open import Pervasives
-open import Pervasives_extra
-open import Sail2_instr_kinds
-open import Sail2_values
-open import Sail2_operators_mwords
-open import Sail2_prompt_monad
-open import Sail2_prompt
-
-type bitvector 'a = mword 'a
-
-let MEM_fence_rw_rw () = barrier (Barrier_RISCV_rw_rw ())
-let MEM_fence_r_rw () = barrier (Barrier_RISCV_r_rw ())
-let MEM_fence_r_r () = barrier (Barrier_RISCV_r_r ())
-let MEM_fence_rw_w () = barrier (Barrier_RISCV_rw_w ())
-let MEM_fence_w_w () = barrier (Barrier_RISCV_w_w ())
-let MEM_fence_w_rw () = barrier (Barrier_RISCV_w_rw ())
-let MEM_fence_rw_r () = barrier (Barrier_RISCV_rw_r ())
-let MEM_fence_r_w () = barrier (Barrier_RISCV_r_w ())
-let MEM_fence_w_r () = barrier (Barrier_RISCV_w_r ())
-let MEM_fence_tso () = barrier (Barrier_RISCV_tso ())
-let MEM_fence_i () = barrier (Barrier_RISCV_i ())
-
-val MEMea : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_strong_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_conditional : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_conditional_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_conditional_strong_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-
-let MEMea addr size = write_mem_ea Write_plain () addr size
-let MEMea_release addr size = write_mem_ea Write_RISCV_release () addr size
-let MEMea_strong_release addr size = write_mem_ea Write_RISCV_strong_release () addr size
-let MEMea_conditional addr size = write_mem_ea Write_RISCV_conditional () addr size
-let MEMea_conditional_release addr size = write_mem_ea Write_RISCV_conditional_release () addr size
-let MEMea_conditional_strong_release addr size
- = write_mem_ea Write_RISCV_conditional_strong_release () addr size
-
-val MEMr : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_strong_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_reserved : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_reserved_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_reserved_strong_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-
-let MEMr addrsize size hexRAM addr = read_mem Read_plain addrsize addr size
-let MEMr_acquire addrsize size hexRAM addr = read_mem Read_RISCV_acquire addrsize addr size
-let MEMr_strong_acquire addrsize size hexRAM addr = read_mem Read_RISCV_strong_acquire addrsize addr size
-let MEMr_reserved addrsize size hexRAM addr = read_mem Read_RISCV_reserved addrsize addr size
-let MEMr_reserved_acquire addrsize size hexRAM addr = read_mem Read_RISCV_reserved_acquire addrsize addr size
-let MEMr_reserved_strong_acquire addrsize size hexRAM addr = read_mem Read_RISCV_reserved_strong_acquire addrsize addr size
-
-val MEMw : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-val MEMw_release : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-val MEMw_strong_release : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-val MEMw_conditional : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-val MEMw_conditional_release : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-val MEMw_conditional_strong_release : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-
-let MEMw addrsize size hexRAM addr = write_mem Write_plain addrsize addr size
-let MEMw_release addrsize size hexRAM addr = write_mem Write_RISCV_release addrsize addr size
-let MEMw_strong_release addrsize size hexRAM addr = write_mem Write_RISCV_strong_release addrsize addr size
-let MEMw_conditional addrsize size hexRAM addr = write_mem Write_RISCV_conditional addrsize addr size
-let MEMw_conditional_release addrsize size hexRAM addr = write_mem Write_RISCV_conditional_release addrsize addr size
-let MEMw_conditional_strong_release addrsize size hexRAM addr = write_mem Write_RISCV_conditional_strong_release addrsize addr size
-
-val load_reservation : forall 'a. Size 'a => bitvector 'a -> unit
-let load_reservation addr = ()
-
-let speculate_conditional_success () = excl_result ()
-
-let match_reservation _ = true
-let cancel_reservation () = ()
-
-val sys_enable_writable_misa : unit -> bool
-let sys_enable_writable_misa () = true
-declare ocaml target_rep function sys_enable_writable_misa = `Platform.enable_writable_misa`
-
-val sys_enable_rvc : unit -> bool
-let sys_enable_rvc () = true
-declare ocaml target_rep function sys_enable_rvc = `Platform.enable_rvc`
-
-val sys_enable_next : unit -> bool
-let sys_enable_next () = true
-declare ocaml target_rep function sys_enable_next = `Platform.enable_next`
-
-val sys_enable_fdext : unit -> bool
-let sys_enable_fdext () = true
-declare ocaml target_rep function sys_enable_fdext = `Platform.enable_fdext`
-
-val sys_enable_zfinx : unit -> bool
-let sys_enable_zfinx () = false
-declare ocaml target_rep function sys_enable_zfinx = `Platform.enable_zfinx`
-
-val plat_ram_base : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_ram_base () = wordFromInteger 0
-declare ocaml target_rep function plat_ram_base = `Platform.dram_base`
-
-val plat_ram_size : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_ram_size () = wordFromInteger 0
-declare ocaml target_rep function plat_ram_size = `Platform.dram_size`
-
-val plat_rom_base : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_rom_base () = wordFromInteger 0
-declare ocaml target_rep function plat_rom_base = `Platform.rom_base`
-
-val plat_rom_size : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_rom_size () = wordFromInteger 0
-declare ocaml target_rep function plat_rom_size = `Platform.rom_size`
-
-val plat_clint_base : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_clint_base () = wordFromInteger 0
-declare ocaml target_rep function plat_clint_base = `Platform.clint_base`
-
-val plat_clint_size : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_clint_size () = wordFromInteger 0
-declare ocaml target_rep function plat_clint_size = `Platform.clint_size`
-
-val plat_enable_dirty_update : unit -> bool
-let plat_enable_dirty_update () = false
-declare ocaml target_rep function plat_enable_dirty_update = `Platform.enable_dirty_update`
-
-val plat_enable_misaligned_access : unit -> bool
-let plat_enable_misaligned_access () = false
-declare ocaml target_rep function plat_enable_misaligned_access = `Platform.enable_misaligned_access`
-
-val plat_enable_pmp : unit -> bool
-let plat_enable_pmp () = false
-declare ocaml target_rep function plat_enable_pmp = `Platform.enable_pmp`
-
-val plat_mtval_has_illegal_inst_bits : unit -> bool
-let plat_mtval_has_illegal_inst_bits () = false
-declare ocaml target_rep function plat_mtval_has_illegal_inst_bits = `Platform.mtval_has_illegal_inst_bits`
-
-val plat_insns_per_tick : unit -> integer
-let plat_insns_per_tick () = 1
-declare ocaml target_rep function plat_insns_per_tick = `Platform.insns_per_tick`
-
-val plat_htif_tohost : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_htif_tohost () = wordFromInteger 0
-declare ocaml target_rep function plat_htif_tohost = `Platform.htif_tohost`
-
-val plat_term_write : forall 'a. Size 'a => bitvector 'a -> unit
-let plat_term_write _ = ()
-declare ocaml target_rep function plat_term_write = `Platform.term_write`
-
-val plat_term_read : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_term_read () = wordFromInteger 0
-declare ocaml target_rep function plat_term_read = `Platform.term_read`
-
-val plat_get_16_random_bits : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_get_16_random_bits () = wordFromInteger 0
-declare ocaml target_rep function plat_get_16_random_bits = `Platform.get_16_random_bits`
-
-val shift_bits_right : forall 'a 'b. Size 'a, Size 'b => bitvector 'a -> bitvector 'b -> bitvector 'a
-let shift_bits_right v m = shiftr v (uint m)
-val shift_bits_left : forall 'a 'b. Size 'a, Size 'b => bitvector 'a -> bitvector 'b -> bitvector 'a
-let shift_bits_left v m = shiftl v (uint m)
-
-val print_string : string -> string -> unit
-let print_string msg s = () (* print_endline (msg ^ s) *)
-
-val prerr_string : string -> string -> unit
-let prerr_string msg s = prerr_endline (msg ^ s)
-
-val prerr_bits : forall 'a. Size 'a => string -> bitvector 'a -> unit
-let prerr_bits msg bs = prerr_endline (msg ^ (show_bitlist (bits_of bs)))
-
-val print_bits : forall 'a. Size 'a => string -> bitvector 'a -> unit
-let print_bits msg bs = () (* print_endline (msg ^ (show_bitlist (bits_of bs))) *)
-
-val print_dbg : string -> unit
-let print_dbg msg = ()
diff --git a/handwritten_support/0.11/riscv_extras_fdext.lem b/handwritten_support/0.11/riscv_extras_fdext.lem
deleted file mode 100644
index e24a63d..0000000
--- a/handwritten_support/0.11/riscv_extras_fdext.lem
+++ /dev/null
@@ -1,216 +0,0 @@
-open import Pervasives
-open import Pervasives_extra
-open import Sail2_instr_kinds
-open import Sail2_values
-open import Sail2_operators_mwords
-open import Sail2_prompt_monad
-open import Sail2_prompt
-
-type bitvector 'a = mword 'a
-
-(* stub functions emulating the C softfloat interface *)
-
-val softfloat_f16_add : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f16_add _ _ _ = ()
-
-val softfloat_f16_sub : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f16_sub _ _ _ = ()
-
-val softfloat_f16_mul : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f16_mul _ _ _ = ()
-
-val softfloat_f16_div : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f16_div _ _ _ = ()
-
-val softfloat_f32_add : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f32_add _ _ _ = ()
-
-val softfloat_f32_sub : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f32_sub _ _ _ = ()
-
-val softfloat_f32_mul : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f32_mul _ _ _ = ()
-
-val softfloat_f32_div : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f32_div _ _ _ = ()
-
-val softfloat_f64_add : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f64_add _ _ _ = ()
-
-val softfloat_f64_sub : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f64_sub _ _ _ = ()
-
-val softfloat_f64_mul : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f64_mul _ _ _ = ()
-
-val softfloat_f64_div : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
-let softfloat_f64_div _ _ _ = ()
-
-
-val softfloat_f16_muladd : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> bitvector 's -> unit
-let softfloat_f16_muladd _ _ _ _ = ()
-
-val softfloat_f32_muladd : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> bitvector 's -> unit
-let softfloat_f32_muladd _ _ _ _ = ()
-
-val softfloat_f64_muladd : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> bitvector 's -> unit
-let softfloat_f64_muladd _ _ _ _ = ()
-
-
-val softfloat_f16_sqrt : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f16_sqrt _ _ = ()
-
-val softfloat_f32_sqrt : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f32_sqrt _ _ = ()
-
-val softfloat_f64_sqrt : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f64_sqrt _ _ = ()
-
-
-val softfloat_f16_to_i32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f16_to_i32 _ _ = ()
-
-val softfloat_f16_to_ui32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f16_to_ui32 _ _ = ()
-
-val softfloat_i32_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_i32_to_f16 _ _ = ()
-
-val softfloat_ui32_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_ui32_to_f16 _ _ = ()
-
-val softfloat_f16_to_i64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f16_to_i64 _ _ = ()
-
-val softfloat_f16_to_ui64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f16_to_ui64 _ _ = ()
-
-val softfloat_i64_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_i64_to_f16 _ _ = ()
-
-val softfloat_ui64_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_ui64_to_f16 _ _ = ()
-
-
-val softfloat_f32_to_i32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f32_to_i32 _ _ = ()
-
-val softfloat_f32_to_ui32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f32_to_ui32 _ _ = ()
-
-val softfloat_i32_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_i32_to_f32 _ _ = ()
-
-val softfloat_ui32_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_ui32_to_f32 _ _ = ()
-
-val softfloat_f32_to_i64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f32_to_i64 _ _ = ()
-
-val softfloat_f32_to_ui64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f32_to_ui64 _ _ = ()
-
-val softfloat_i64_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_i64_to_f32 _ _ = ()
-
-val softfloat_ui64_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_ui64_to_f32 _ _ = ()
-
-
-val softfloat_f64_to_i32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f64_to_i32 _ _ = ()
-
-val softfloat_f64_to_ui32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f64_to_ui32 _ _ = ()
-
-val softfloat_i32_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_i32_to_f64 _ _ = ()
-
-val softfloat_ui32_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_ui32_to_f64 _ _ = ()
-
-val softfloat_f64_to_i64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f64_to_i64 _ _ = ()
-
-val softfloat_f64_to_ui64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f64_to_ui64 _ _ = ()
-
-val softfloat_i64_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_i64_to_f64 _ _ = ()
-
-val softfloat_ui64_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_ui64_to_f64 _ _ = ()
-
-
-val softfloat_f16_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f16_to_f32 _ _ = ()
-
-val softfloat_f16_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f16_to_f64 _ _ = ()
-
-val softfloat_f32_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f32_to_f64 _ _ = ()
-
-val softfloat_f32_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f32_to_f16 _ _ = ()
-
-val softfloat_f64_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f64_to_f16 _ _ = ()
-
-val softfloat_f64_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
-let softfloat_f64_to_f32 _ _ = ()
-
-
-val softfloat_f16_lt : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f16_lt _ _ = ()
-
-val softfloat_f16_lt_quiet : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f16_lt_quiet _ _ = ()
-
-val softfloat_f16_le : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f16_le _ _ = ()
-
-val softfloat_f16_le_quiet : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f16_le_quiet _ _ = ()
-
-val softfloat_f16_eq : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f16_eq _ _ = ()
-
-val softfloat_f32_lt : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f32_lt _ _ = ()
-
-val softfloat_f32_lt_quiet : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f32_lt_quiet _ _ = ()
-
-val softfloat_f32_le : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f32_le _ _ = ()
-
-val softfloat_f32_le_quiet : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f32_le_quiet _ _ = ()
-
-val softfloat_f32_eq : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f32_eq _ _ = ()
-
-val softfloat_f64_lt : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f64_lt _ _ = ()
-
-val softfloat_f64_lt_quiet : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f64_lt_quiet _ _ = ()
-
-val softfloat_f64_le : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f64_le _ _ = ()
-
-val softfloat_f64_le_quiet : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f64_le_quiet _ _ = ()
-
-val softfloat_f64_eq : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
-let softfloat_f64_eq _ _ = ()
-
-val softfloat_f16_round_to_int : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bool -> unit
-let softfloat_f16_round_to_int _ _ _ = ()
-
-val softfloat_f32_round_to_int : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bool -> unit
-let softfloat_f32_round_to_int _ _ _ = ()
-
-val softfloat_f64_round_to_int : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bool -> unit
-let softfloat_f64_round_to_int _ _ _ = ()
diff --git a/handwritten_support/0.11/riscv_extras_sequential.lem b/handwritten_support/0.11/riscv_extras_sequential.lem
deleted file mode 100644
index 0c23651..0000000
--- a/handwritten_support/0.11/riscv_extras_sequential.lem
+++ /dev/null
@@ -1,160 +0,0 @@
-open import Pervasives
-open import Pervasives_extra
-open import Sail2_instr_kinds
-open import Sail2_values
-open import Sail2_operators_mwords
-open import Sail2_prompt_monad
-open import Sail2_prompt
-
-type bitvector 'a = mword 'a
-
-let MEM_fence_rw_rw () = barrier (Barrier_RISCV_rw_rw ())
-let MEM_fence_r_rw () = barrier (Barrier_RISCV_r_rw ())
-let MEM_fence_r_r () = barrier (Barrier_RISCV_r_r ())
-let MEM_fence_rw_w () = barrier (Barrier_RISCV_rw_w ())
-let MEM_fence_w_w () = barrier (Barrier_RISCV_w_w ())
-let MEM_fence_w_rw () = barrier (Barrier_RISCV_w_rw ())
-let MEM_fence_rw_r () = barrier (Barrier_RISCV_rw_r ())
-let MEM_fence_r_w () = barrier (Barrier_RISCV_r_w ())
-let MEM_fence_w_r () = barrier (Barrier_RISCV_w_r ())
-let MEM_fence_tso () = barrier (Barrier_RISCV_tso ())
-let MEM_fence_i () = barrier (Barrier_RISCV_i ())
-
-val MEMea : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_strong_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_conditional : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_conditional_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_conditional_strong_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-
-let MEMea addr size = write_mem_ea Write_plain addr size
-let MEMea_release addr size = write_mem_ea Write_RISCV_release addr size
-let MEMea_strong_release addr size = write_mem_ea Write_RISCV_strong_release addr size
-let MEMea_conditional addr size = write_mem_ea Write_RISCV_conditional addr size
-let MEMea_conditional_release addr size = write_mem_ea Write_RISCV_conditional_release addr size
-let MEMea_conditional_strong_release addr size
- = write_mem_ea Write_RISCV_conditional_strong_release addr size
-
-val MEMr : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_strong_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_reserved : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_reserved_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_reserved_strong_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-
-let MEMr addrsize size hexRAM addr = read_mem Read_plain addr size
-let MEMr_acquire addrsize size hexRAM addr = read_mem Read_RISCV_acquire addr size
-let MEMr_strong_acquire addrsize size hexRAM addr = read_mem Read_RISCV_strong_acquire addr size
-let MEMr_reserved addrsize size hexRAM addr = read_mem Read_RISCV_reserved addr size
-let MEMr_reserved_acquire addrsize size hexRAM addr = read_mem Read_RISCV_reserved_acquire addr size
-let MEMr_reserved_strong_acquire addrsize size hexRAM addr = read_mem Read_RISCV_reserved_strong_acquire addr size
-
-val write_ram : forall 'rv 'a 'b 'e. Size 'a, Size 'b =>
- integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-let write_ram addrsize size hexRAM address value =
- write_mem Write_plain address size value
-
-val read_ram : forall 'rv 'a 'b 'e. Size 'a, Size 'b =>
- integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-let read_ram addrsize size hexRAM address =
- read_mem Read_plain address size
-
-val load_reservation : forall 'a. Size 'a => bitvector 'a -> unit
-let load_reservation addr = ()
-
-let speculate_conditional_success () = excl_result ()
-
-let match_reservation _ = true
-let cancel_reservation () = ()
-
-val sys_enable_writable_misa : unit -> bool
-let sys_enable_writable_misa () = true
-declare ocaml target_rep function sys_enable_writable_misa = `Platform.enable_writable_misa`
-
-val sys_enable_rvc : unit -> bool
-let sys_enable_rvc () = true
-declare ocaml target_rep function sys_enable_rvc = `Platform.enable_rvc`
-
-val sys_enable_zfinx : unit -> bool
-let sys_enable_zfinx () = false
-declare ocaml target_rep function sys_enable_zfinx = `Platform.enable_zfinx`
-
-val sys_enable_next : unit -> bool
-let sys_enable_next () = true
-declare ocaml target_rep function sys_enable_next = `Platform.enable_next`
-
-val plat_ram_base : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_ram_base () = wordFromInteger 0
-declare ocaml target_rep function plat_ram_base = `Platform.dram_base`
-
-val plat_ram_size : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_ram_size () = wordFromInteger 0
-declare ocaml target_rep function plat_ram_size = `Platform.dram_size`
-
-val plat_rom_base : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_rom_base () = wordFromInteger 0
-declare ocaml target_rep function plat_rom_base = `Platform.rom_base`
-
-val plat_rom_size : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_rom_size () = wordFromInteger 0
-declare ocaml target_rep function plat_rom_size = `Platform.rom_size`
-
-val plat_clint_base : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_clint_base () = wordFromInteger 0
-declare ocaml target_rep function plat_clint_base = `Platform.clint_base`
-
-val plat_clint_size : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_clint_size () = wordFromInteger 0
-declare ocaml target_rep function plat_clint_size = `Platform.clint_size`
-
-val plat_enable_dirty_update : unit -> bool
-let plat_enable_dirty_update () = false
-declare ocaml target_rep function plat_enable_dirty_update = `Platform.enable_dirty_update`
-
-val plat_enable_misaligned_access : unit -> bool
-let plat_enable_misaligned_access () = false
-declare ocaml target_rep function plat_enable_misaligned_access = `Platform.enable_misaligned_access`
-
-val plat_enable_pmp : unit -> bool
-let plat_enable_pmp () = false
-declare ocaml target_rep function plat_enable_pmp = `Platform.enable_pmp`
-
-val plat_mtval_has_illegal_inst_bits : unit -> bool
-let plat_mtval_has_illegal_inst_bits () = false
-declare ocaml target_rep function plat_mtval_has_illegal_inst_bits = `Platform.mtval_has_illegal_inst_bits`
-
-val plat_insns_per_tick : unit -> integer
-let plat_insns_per_tick () = 1
-declare ocaml target_rep function plat_insns_per_tick = `Platform.insns_per_tick`
-
-val plat_htif_tohost : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_htif_tohost () = wordFromInteger 0
-declare ocaml target_rep function plat_htif_tohost = `Platform.htif_tohost`
-
-val plat_term_write : forall 'a. Size 'a => bitvector 'a -> unit
-let plat_term_write _ = ()
-declare ocaml target_rep function plat_term_write = `Platform.term_write`
-
-val plat_term_read : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_term_read () = wordFromInteger 0
-declare ocaml target_rep function plat_term_read = `Platform.term_read`
-
-val shift_bits_right : forall 'a 'b. Size 'a, Size 'b => bitvector 'a -> bitvector 'b -> bitvector 'a
-let shift_bits_right v m = shiftr v (uint m)
-val shift_bits_left : forall 'a 'b. Size 'a, Size 'b => bitvector 'a -> bitvector 'b -> bitvector 'a
-let shift_bits_left v m = shiftl v (uint m)
-
-val print_string : string -> string -> unit
-let print_string msg s = () (* print_endline (msg ^ s) *)
-
-val prerr_string : string -> string -> unit
-let prerr_string msg s = prerr_endline (msg ^ s)
-
-val prerr_bits : forall 'a. Size 'a => string -> bitvector 'a -> unit
-let prerr_bits msg bs = prerr_endline (msg ^ (show_bitlist (bits_of bs)))
-
-val print_bits : forall 'a. Size 'a => string -> bitvector 'a -> unit
-let print_bits msg bs = () (* print_endline (msg ^ (show_bitlist (bits_of bs))) *)
-
-val print_dbg : string -> unit
-let print_dbg msg = ()
diff --git a/handwritten_support/mem_metadata.lem b/handwritten_support/mem_metadata.lem
index eadcada..6ea7691 100644
--- a/handwritten_support/mem_metadata.lem
+++ b/handwritten_support/mem_metadata.lem
@@ -72,15 +72,15 @@ open import Pervasives
open import Pervasives_extra
open import Sail2_instr_kinds
open import Sail2_values
-open import Sail2_operators_mwords
+open import Sail2_operators_bitlists
open import Sail2_prompt_monad
open import Sail2_prompt
-val write_ram : forall 'rv 'e 'a 'n. Size 'a, Size 'n => write_kind -> mword 'a -> integer -> mword 'n -> unit -> monad 'rv bool 'e
+val write_ram : forall 'rv 'e. write_kind -> list bitU -> integer -> list bitU -> unit -> monad 'rv bool 'e
let write_ram wk addr width data meta =
write_mem wk () addr width data
-val read_ram : forall 'rv 'e 'a 'n. Size 'a, Size 'n => read_kind -> mword 'a -> integer -> bool -> monad 'rv (mword 'n * unit) 'e
+val read_ram : forall 'rv 'e. read_kind -> list bitU -> integer -> bool -> monad 'rv (list bitU * unit) 'e
let read_ram rk addr width read_tag =
- read_mem rk () addr width >>= (fun (data : mword 'n) ->
+ read_mem rk () addr width >>= (fun data ->
return (data, ()))
diff --git a/handwritten_support/riscv_extras.lem b/handwritten_support/riscv_extras.lem
index 5f92ee9..27e8ee5 100644
--- a/handwritten_support/riscv_extras.lem
+++ b/handwritten_support/riscv_extras.lem
@@ -72,30 +72,30 @@ open import Pervasives
open import Pervasives_extra
open import Sail2_instr_kinds
open import Sail2_values
-open import Sail2_operators_mwords
+open import Sail2_operators_bitlists
open import Sail2_prompt_monad
open import Sail2_prompt
-type bitvector 'a = mword 'a
-
-let MEM_fence_rw_rw () = barrier Barrier_RISCV_rw_rw
-let MEM_fence_r_rw () = barrier Barrier_RISCV_r_rw
-let MEM_fence_r_r () = barrier Barrier_RISCV_r_r
-let MEM_fence_rw_w () = barrier Barrier_RISCV_rw_w
-let MEM_fence_w_w () = barrier Barrier_RISCV_w_w
-let MEM_fence_w_rw () = barrier Barrier_RISCV_w_rw
-let MEM_fence_rw_r () = barrier Barrier_RISCV_rw_r
-let MEM_fence_r_w () = barrier Barrier_RISCV_r_w
-let MEM_fence_w_r () = barrier Barrier_RISCV_w_r
-let MEM_fence_tso () = barrier Barrier_RISCV_tso
-let MEM_fence_i () = barrier Barrier_RISCV_i
-
-val MEMea : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_strong_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_conditional : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_conditional_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
-val MEMea_conditional_strong_release : forall 'rv 'a 'e. Size 'a => bitvector 'a -> integer -> monad 'rv unit 'e
+type bitvector = list Sail2_values.bitU
+
+let MEM_fence_rw_rw () = barrier (Barrier_RISCV_rw_rw ())
+let MEM_fence_r_rw () = barrier (Barrier_RISCV_r_rw ())
+let MEM_fence_r_r () = barrier (Barrier_RISCV_r_r ())
+let MEM_fence_rw_w () = barrier (Barrier_RISCV_rw_w ())
+let MEM_fence_w_w () = barrier (Barrier_RISCV_w_w ())
+let MEM_fence_w_rw () = barrier (Barrier_RISCV_w_rw ())
+let MEM_fence_rw_r () = barrier (Barrier_RISCV_rw_r ())
+let MEM_fence_r_w () = barrier (Barrier_RISCV_r_w ())
+let MEM_fence_w_r () = barrier (Barrier_RISCV_w_r ())
+let MEM_fence_tso () = barrier (Barrier_RISCV_tso ())
+let MEM_fence_i () = barrier (Barrier_RISCV_i ())
+
+val MEMea : forall 'rv 'e. bitvector -> integer -> monad 'rv unit 'e
+val MEMea_release : forall 'rv 'e. bitvector -> integer -> monad 'rv unit 'e
+val MEMea_strong_release : forall 'rv 'e. bitvector -> integer -> monad 'rv unit 'e
+val MEMea_conditional : forall 'rv 'e. bitvector -> integer -> monad 'rv unit 'e
+val MEMea_conditional_release : forall 'rv 'e. bitvector -> integer -> monad 'rv unit 'e
+val MEMea_conditional_strong_release : forall 'rv 'e. bitvector -> integer -> monad 'rv unit 'e
let MEMea addr size = write_mem_ea Write_plain () addr size
let MEMea_release addr size = write_mem_ea Write_RISCV_release () addr size
@@ -103,14 +103,14 @@ let MEMea_strong_release addr size = write_mem_ea Write_RISCV_strong_relea
let MEMea_conditional addr size = write_mem_ea Write_RISCV_conditional () addr size
let MEMea_conditional_release addr size = write_mem_ea Write_RISCV_conditional_release () addr size
let MEMea_conditional_strong_release addr size
- = write_mem_ea Write_RISCV_conditional_strong_release () addr size
+ = write_mem_ea Write_RISCV_conditional_strong_release () addr size
-val MEMr : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_strong_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_reserved : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_reserved_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
-val MEMr_reserved_strong_acquire : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> monad 'rv (bitvector 'b) 'e
+val MEMr : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> monad 'rv bitvector 'e
+val MEMr_acquire : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> monad 'rv bitvector 'e
+val MEMr_strong_acquire : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> monad 'rv bitvector 'e
+val MEMr_reserved : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> monad 'rv bitvector 'e
+val MEMr_reserved_acquire : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> monad 'rv bitvector 'e
+val MEMr_reserved_strong_acquire : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> monad 'rv bitvector 'e
let MEMr addrsize size hexRAM addr = read_mem Read_plain addrsize addr size
let MEMr_acquire addrsize size hexRAM addr = read_mem Read_RISCV_acquire addrsize addr size
@@ -119,12 +119,12 @@ let MEMr_reserved addrsize size hexRAM addr = read_mem Read_RISCV
let MEMr_reserved_acquire addrsize size hexRAM addr = read_mem Read_RISCV_reserved_acquire addrsize addr size
let MEMr_reserved_strong_acquire addrsize size hexRAM addr = read_mem Read_RISCV_reserved_strong_acquire addrsize addr size
-val MEMw : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-val MEMw_release : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-val MEMw_strong_release : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-val MEMw_conditional : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-val MEMw_conditional_release : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
-val MEMw_conditional_strong_release : forall 'rv 'a 'b 'e. Size 'a, Size 'b => integer -> integer -> bitvector 'a -> bitvector 'a -> bitvector 'b -> monad 'rv bool 'e
+val MEMw : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> bitvector -> monad 'rv bool 'e
+val MEMw_release : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> bitvector -> monad 'rv bool 'e
+val MEMw_strong_release : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> bitvector -> monad 'rv bool 'e
+val MEMw_conditional : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> bitvector -> monad 'rv bool 'e
+val MEMw_conditional_release : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> bitvector -> monad 'rv bool 'e
+val MEMw_conditional_strong_release : forall 'rv 'a 'b 'e. integer -> integer -> bitvector -> bitvector -> bitvector -> monad 'rv bool 'e
let MEMw addrsize size hexRAM addr = write_mem Write_plain addrsize addr size
let MEMw_release addrsize size hexRAM addr = write_mem Write_RISCV_release addrsize addr size
@@ -133,7 +133,7 @@ let MEMw_conditional addrsize size hexRAM addr = write_mem Write_
let MEMw_conditional_release addrsize size hexRAM addr = write_mem Write_RISCV_conditional_release addrsize addr size
let MEMw_conditional_strong_release addrsize size hexRAM addr = write_mem Write_RISCV_conditional_strong_release addrsize addr size
-val load_reservation : forall 'a. Size 'a => bitvector 'a -> unit
+val load_reservation : bitvector -> unit
let load_reservation addr = ()
let speculate_conditional_success () = excl_result ()
@@ -161,32 +161,36 @@ val sys_enable_zfinx : unit -> bool
let sys_enable_zfinx () = false
declare ocaml target_rep function sys_enable_zfinx = `Platform.enable_zfinx`
+val sys_enable_vext : unit -> bool
+let sys_enable_vext () = true
+declare ocaml target_rep function sys_enable_vext = `Platform.enable_vext`
+
val sys_enable_writable_fiom : unit -> bool
let sys_enable_writable_fiom () = true
declare ocaml target_rep function sys_enable_writable_fiom = `Platform.enable_writable_fiom`
-val plat_ram_base : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_ram_base () = wordFromInteger 0
+val plat_ram_base : unit -> bitvector
+let plat_ram_base () = []
declare ocaml target_rep function plat_ram_base = `Platform.dram_base`
-val plat_ram_size : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_ram_size () = wordFromInteger 0
+val plat_ram_size : unit -> bitvector
+let plat_ram_size () = []
declare ocaml target_rep function plat_ram_size = `Platform.dram_size`
-val plat_rom_base : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_rom_base () = wordFromInteger 0
+val plat_rom_base : unit -> bitvector
+let plat_rom_base () = []
declare ocaml target_rep function plat_rom_base = `Platform.rom_base`
-val plat_rom_size : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_rom_size () = wordFromInteger 0
+val plat_rom_size : unit -> bitvector
+let plat_rom_size () = []
declare ocaml target_rep function plat_rom_size = `Platform.rom_size`
-val plat_clint_base : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_clint_base () = wordFromInteger 0
+val plat_clint_base : unit -> bitvector
+let plat_clint_base () = []
declare ocaml target_rep function plat_clint_base = `Platform.clint_base`
-val plat_clint_size : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_clint_size () = wordFromInteger 0
+val plat_clint_size : unit -> bitvector
+let plat_clint_size () = []
declare ocaml target_rep function plat_clint_size = `Platform.clint_size`
val plat_enable_dirty_update : unit -> bool
@@ -197,10 +201,6 @@ val plat_enable_misaligned_access : unit -> bool
let plat_enable_misaligned_access () = false
declare ocaml target_rep function plat_enable_misaligned_access = `Platform.enable_misaligned_access`
-val plat_enable_pmp : unit -> bool
-let plat_enable_pmp () = false
-declare ocaml target_rep function plat_enable_pmp = `Platform.enable_pmp`
-
val plat_mtval_has_illegal_inst_bits : unit -> bool
let plat_mtval_has_illegal_inst_bits () = false
declare ocaml target_rep function plat_mtval_has_illegal_inst_bits = `Platform.mtval_has_illegal_inst_bits`
@@ -209,25 +209,25 @@ val plat_insns_per_tick : unit -> integer
let plat_insns_per_tick () = 1
declare ocaml target_rep function plat_insns_per_tick = `Platform.insns_per_tick`
-val plat_htif_tohost : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_htif_tohost () = wordFromInteger 0
+val plat_htif_tohost : unit -> bitvector
+let plat_htif_tohost () = []
declare ocaml target_rep function plat_htif_tohost = `Platform.htif_tohost`
-val plat_term_write : forall 'a. Size 'a => bitvector 'a -> unit
+val plat_term_write : bitvector -> unit
let plat_term_write _ = ()
declare ocaml target_rep function plat_term_write = `Platform.term_write`
-val plat_term_read : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_term_read () = wordFromInteger 0
+val plat_term_read : unit -> bitvector
+let plat_term_read () = []
declare ocaml target_rep function plat_term_read = `Platform.term_read`
-val plat_get_16_random_bits : forall 'a. Size 'a => unit -> bitvector 'a
-let plat_get_16_random_bits () = wordFromInteger 0
+val plat_get_16_random_bits : unit -> bitvector
+let plat_get_16_random_bits () = []
declare ocaml target_rep function plat_get_16_random_bits = `Platform.get_16_random_bits`
-val shift_bits_right : forall 'a 'b. Size 'a, Size 'b => bitvector 'a -> bitvector 'b -> bitvector 'a
+val shift_bits_right : bitvector -> bitvector -> bitvector
let shift_bits_right v m = shiftr v (uint m)
-val shift_bits_left : forall 'a 'b. Size 'a, Size 'b => bitvector 'a -> bitvector 'b -> bitvector 'a
+val shift_bits_left : bitvector -> bitvector -> bitvector
let shift_bits_left v m = shiftl v (uint m)
val print_string : string -> string -> unit
@@ -236,11 +236,11 @@ let print_string msg s = () (* print_endline (msg ^ s) *)
val prerr_string : string -> string -> unit
let prerr_string msg s = prerr_endline (msg ^ s)
-val prerr_bits : forall 'a. Size 'a => string -> bitvector 'a -> unit
+val prerr_bits : string -> bitvector -> unit
let prerr_bits msg bs = prerr_endline (msg ^ (show_bitlist (bits_of bs)))
-val print_bits : forall 'a. Size 'a => string -> bitvector 'a -> unit
-let print_bits msg bs = () (* print_endline (msg ^ (show_bitlist (bits_of bs))) *)
+val print_bits : string -> bitvector -> unit
+let print_bits msg bs = print_endline (msg ^ (show_bitlist (bits_of bs)))
val print_dbg : string -> unit
let print_dbg msg = ()
diff --git a/handwritten_support/riscv_extras_fdext.lem b/handwritten_support/riscv_extras_fdext.lem
index 84e76ee..81c6af5 100644
--- a/handwritten_support/riscv_extras_fdext.lem
+++ b/handwritten_support/riscv_extras_fdext.lem
@@ -76,193 +76,211 @@ open import Sail2_operators_mwords
open import Sail2_prompt_monad
open import Sail2_prompt
-type bitvector 'a = mword 'a
+type bitvector = list Sail2_values.bitU
(* stub functions emulating the C softfloat interface *)
-val softfloat_f16_add : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f16_round_to_int : bitvector -> bitvector -> bool -> unit
+let softfloat_f16_round_to_int _ _ _ = ()
+
+val softfloat_f32_round_to_int : bitvector -> bitvector -> bool -> unit
+let softfloat_f32_round_to_int _ _ _ = ()
+
+val softfloat_f64_round_to_int : bitvector -> bitvector -> bool -> unit
+let softfloat_f64_round_to_int _ _ _ = ()
+
+val softfloat_f16_add : bitvector -> bitvector -> bitvector -> unit
let softfloat_f16_add _ _ _ = ()
-val softfloat_f16_sub : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f16_sub : bitvector -> bitvector -> bitvector -> unit
let softfloat_f16_sub _ _ _ = ()
-val softfloat_f16_mul : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f16_mul : bitvector -> bitvector -> bitvector -> unit
let softfloat_f16_mul _ _ _ = ()
-val softfloat_f16_div : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f16_div : bitvector -> bitvector -> bitvector -> unit
let softfloat_f16_div _ _ _ = ()
-val softfloat_f32_add : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f32_add : bitvector -> bitvector -> bitvector -> unit
let softfloat_f32_add _ _ _ = ()
-val softfloat_f32_sub : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f32_sub : bitvector -> bitvector -> bitvector -> unit
let softfloat_f32_sub _ _ _ = ()
-val softfloat_f32_mul : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f32_mul : bitvector -> bitvector -> bitvector -> unit
let softfloat_f32_mul _ _ _ = ()
-val softfloat_f32_div : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f32_div : bitvector -> bitvector -> bitvector -> unit
let softfloat_f32_div _ _ _ = ()
-val softfloat_f64_add : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f64_add : bitvector -> bitvector -> bitvector -> unit
let softfloat_f64_add _ _ _ = ()
-val softfloat_f64_sub : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f64_sub : bitvector -> bitvector -> bitvector -> unit
let softfloat_f64_sub _ _ _ = ()
-val softfloat_f64_mul : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f64_mul : bitvector -> bitvector -> bitvector -> unit
let softfloat_f64_mul _ _ _ = ()
-val softfloat_f64_div : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> unit
+val softfloat_f64_div : bitvector -> bitvector -> bitvector -> unit
let softfloat_f64_div _ _ _ = ()
-val softfloat_f16_muladd : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> bitvector 's -> unit
+val softfloat_f16_muladd : bitvector -> bitvector -> bitvector -> bitvector -> unit
let softfloat_f16_muladd _ _ _ _ = ()
-val softfloat_f32_muladd : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> bitvector 's -> unit
+val softfloat_f32_muladd : bitvector -> bitvector -> bitvector -> bitvector -> unit
let softfloat_f32_muladd _ _ _ _ = ()
-val softfloat_f64_muladd : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> bitvector 's -> bitvector 's -> unit
+val softfloat_f64_muladd : bitvector -> bitvector -> bitvector -> bitvector -> unit
let softfloat_f64_muladd _ _ _ _ = ()
-val softfloat_f16_sqrt : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f16_sqrt : bitvector -> bitvector -> unit
let softfloat_f16_sqrt _ _ = ()
-val softfloat_f32_sqrt : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f32_sqrt : bitvector -> bitvector -> unit
let softfloat_f32_sqrt _ _ = ()
-val softfloat_f64_sqrt : forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f64_sqrt : bitvector -> bitvector -> unit
let softfloat_f64_sqrt _ _ = ()
-val softfloat_f16_to_i32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f16_to_i32: bitvector -> bitvector -> unit
let softfloat_f16_to_i32 _ _ = ()
-val softfloat_f16_to_ui32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f16_to_ui32: bitvector -> bitvector -> unit
let softfloat_f16_to_ui32 _ _ = ()
-val softfloat_i32_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_i32_to_f16: bitvector -> bitvector -> unit
let softfloat_i32_to_f16 _ _ = ()
-val softfloat_ui32_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_ui32_to_f16: bitvector -> bitvector -> unit
let softfloat_ui32_to_f16 _ _ = ()
-val softfloat_f16_to_i64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f16_to_i64: bitvector -> bitvector -> unit
let softfloat_f16_to_i64 _ _ = ()
-val softfloat_f16_to_ui64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f16_to_ui64: bitvector -> bitvector -> unit
let softfloat_f16_to_ui64 _ _ = ()
-val softfloat_i64_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_i64_to_f16: bitvector -> bitvector -> unit
let softfloat_i64_to_f16 _ _ = ()
-val softfloat_ui64_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_ui64_to_f16: bitvector -> bitvector -> unit
let softfloat_ui64_to_f16 _ _ = ()
-val softfloat_f32_to_i32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f32_to_i32: bitvector -> bitvector -> unit
let softfloat_f32_to_i32 _ _ = ()
-val softfloat_f32_to_ui32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f32_to_ui32: bitvector -> bitvector -> unit
let softfloat_f32_to_ui32 _ _ = ()
-val softfloat_i32_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_i32_to_f32: bitvector -> bitvector -> unit
let softfloat_i32_to_f32 _ _ = ()
-val softfloat_ui32_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_ui32_to_f32: bitvector -> bitvector -> unit
let softfloat_ui32_to_f32 _ _ = ()
-val softfloat_f32_to_i64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f32_to_i64: bitvector -> bitvector -> unit
let softfloat_f32_to_i64 _ _ = ()
-val softfloat_f32_to_ui64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f32_to_ui64: bitvector -> bitvector -> unit
let softfloat_f32_to_ui64 _ _ = ()
-val softfloat_i64_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_i64_to_f32: bitvector -> bitvector -> unit
let softfloat_i64_to_f32 _ _ = ()
-val softfloat_ui64_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_ui64_to_f32: bitvector -> bitvector -> unit
let softfloat_ui64_to_f32 _ _ = ()
-val softfloat_f64_to_i32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f64_to_i32: bitvector -> bitvector -> unit
let softfloat_f64_to_i32 _ _ = ()
-val softfloat_f64_to_ui32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f64_to_ui32: bitvector -> bitvector -> unit
let softfloat_f64_to_ui32 _ _ = ()
-val softfloat_i32_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_i32_to_f64: bitvector -> bitvector -> unit
let softfloat_i32_to_f64 _ _ = ()
-val softfloat_ui32_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_ui32_to_f64: bitvector -> bitvector -> unit
let softfloat_ui32_to_f64 _ _ = ()
-val softfloat_f64_to_i64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f64_to_i64: bitvector -> bitvector -> unit
let softfloat_f64_to_i64 _ _ = ()
-val softfloat_f64_to_ui64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f64_to_ui64: bitvector -> bitvector -> unit
let softfloat_f64_to_ui64 _ _ = ()
-val softfloat_i64_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_i64_to_f64: bitvector -> bitvector -> unit
let softfloat_i64_to_f64 _ _ = ()
-val softfloat_ui64_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_ui64_to_f64: bitvector -> bitvector -> unit
let softfloat_ui64_to_f64 _ _ = ()
-val softfloat_f16_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f16_to_f32: bitvector -> bitvector -> unit
let softfloat_f16_to_f32 _ _ = ()
-val softfloat_f16_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f16_to_f64: bitvector -> bitvector -> unit
let softfloat_f16_to_f64 _ _ = ()
-val softfloat_f32_to_f64: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f32_to_f64: bitvector -> bitvector -> unit
let softfloat_f32_to_f64 _ _ = ()
-val softfloat_f32_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f32_to_f16: bitvector -> bitvector -> unit
let softfloat_f32_to_f16 _ _ = ()
-val softfloat_f64_to_f16: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f64_to_f16: bitvector -> bitvector -> unit
let softfloat_f64_to_f16 _ _ = ()
-val softfloat_f64_to_f32: forall 'rm 's. Size 'rm, Size 's => bitvector 'rm -> bitvector 's -> unit
+val softfloat_f64_to_f32: bitvector -> bitvector -> unit
let softfloat_f64_to_f32 _ _ = ()
-val softfloat_f16_lt : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f16_lt : bitvector -> bitvector -> unit
let softfloat_f16_lt _ _ = ()
-val softfloat_f16_lt_quiet : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f16_lt_quiet : bitvector -> bitvector -> unit
let softfloat_f16_lt_quiet _ _ = ()
-val softfloat_f16_le : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f16_le : bitvector -> bitvector -> unit
let softfloat_f16_le _ _ = ()
-val softfloat_f16_eq : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f16_le_quiet : bitvector -> bitvector -> unit
+let softfloat_f16_le_quiet _ _ = ()
+
+val softfloat_f16_eq : bitvector -> bitvector -> unit
let softfloat_f16_eq _ _ = ()
-val softfloat_f32_lt : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f32_lt : bitvector -> bitvector -> unit
let softfloat_f32_lt _ _ = ()
-val softfloat_f32_lt_quiet : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f32_lt_quiet : bitvector -> bitvector -> unit
let softfloat_f32_lt_quiet _ _ = ()
-val softfloat_f32_le : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f32_le : bitvector -> bitvector -> unit
let softfloat_f32_le _ _ = ()
-val softfloat_f32_eq : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f32_le_quiet : bitvector -> bitvector -> unit
+let softfloat_f32_le_quiet _ _ = ()
+
+val softfloat_f32_eq : bitvector -> bitvector -> unit
let softfloat_f32_eq _ _ = ()
-val softfloat_f64_lt : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f64_lt : bitvector -> bitvector -> unit
let softfloat_f64_lt _ _ = ()
-val softfloat_f64_lt_quiet : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f64_lt_quiet : bitvector -> bitvector -> unit
let softfloat_f64_lt_quiet _ _ = ()
-val softfloat_f64_le : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f64_le : bitvector -> bitvector -> unit
let softfloat_f64_le _ _ = ()
-val softfloat_f64_eq : forall 's. Size 's => bitvector 's -> bitvector 's -> unit
+val softfloat_f64_le_quiet : bitvector -> bitvector -> unit
+let softfloat_f64_le_quiet _ _ = ()
+
+val softfloat_f64_eq : bitvector -> bitvector -> unit
let softfloat_f64_eq _ _ = ()
diff --git a/handwritten_support/riscv_extras_sequential.lem b/handwritten_support/riscv_extras_sequential.lem
index 102d082..d113908 100644
--- a/handwritten_support/riscv_extras_sequential.lem
+++ b/handwritten_support/riscv_extras_sequential.lem
@@ -189,10 +189,6 @@ val plat_enable_misaligned_access : unit -> bool
let plat_enable_misaligned_access () = false
declare ocaml target_rep function plat_enable_misaligned_access = `Platform.enable_misaligned_access`
-val plat_enable_pmp : unit -> bool
-let plat_enable_pmp () = false
-declare ocaml target_rep function plat_enable_pmp = `Platform.enable_pmp`
-
val plat_mtval_has_illegal_inst_bits : unit -> bool
let plat_mtval_has_illegal_inst_bits () = false
declare ocaml target_rep function plat_mtval_has_illegal_inst_bits = `Platform.mtval_has_illegal_inst_bits`
diff --git a/model/hex_bits.sail b/model/hex_bits.sail
new file mode 100644
index 0000000..81e25e1
--- /dev/null
+++ b/model/hex_bits.sail
@@ -0,0 +1,124 @@
+// Note: This file is temporarily copied here from the Sail compiler. It can
+// be removed when Sail 0.18 is released.
+
+/*==========================================================================*/
+/* Sail */
+/* */
+/* Sail and the Sail architecture models here, comprising all files and */
+/* directories except the ASL-derived Sail code in the aarch64 directory, */
+/* are subject to the BSD two-clause licence below. */
+/* */
+/* The ASL derived parts of the ARMv8.3 specification in */
+/* aarch64/no_vector and aarch64/full are copyright ARM Ltd. */
+/* */
+/* Copyright (c) 2013-2021 */
+/* Kathyrn Gray */
+/* Shaked Flur */
+/* Stephen Kell */
+/* Gabriel Kerneis */
+/* Robert Norton-Wright */
+/* Christopher Pulte */
+/* Peter Sewell */
+/* Alasdair Armstrong */
+/* Brian Campbell */
+/* Thomas Bauereiss */
+/* Anthony Fox */
+/* Jon French */
+/* Dominic Mulligan */
+/* Stephen Kell */
+/* Mark Wassell */
+/* Alastair Reid (Arm Ltd) */
+/* */
+/* All rights reserved. */
+/* */
+/* This work was partially supported by EPSRC grant EP/K008528/1 <a */
+/* href="http://www.cl.cam.ac.uk/users/pes20/rems">REMS: Rigorous */
+/* Engineering for Mainstream Systems</a>, an ARM iCASE award, EPSRC IAA */
+/* KTF funding, and donations from Arm. This project has received */
+/* funding from the European Research Council (ERC) under the European */
+/* Union’s Horizon 2020 research and innovation programme (grant */
+/* agreement No 789108, ELVER). */
+/* */
+/* This software was developed by SRI International and the University of */
+/* Cambridge Computer Laboratory (Department of Computer Science and */
+/* Technology) under DARPA/AFRL contracts FA8650-18-C-7809 ("CIFV") */
+/* and FA8750-10-C-0237 ("CTSRD"). */
+/* */
+/* Redistribution and use in source and binary forms, with or without */
+/* modification, are permitted provided that the following conditions */
+/* are met: */
+/* 1. Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* 2. Redistributions in binary form must reproduce the above copyright */
+/* notice, this list of conditions and the following disclaimer in */
+/* the documentation and/or other materials provided with the */
+/* distribution. */
+/* */
+/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
+/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
+/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
+/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
+/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
+/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
+/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
+/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
+/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
+/* SUCH DAMAGE. */
+/*==========================================================================*/
+
+$ifndef _HEX_BITS
+$define _HEX_BITS
+
+$include <vector.sail>
+$include <string.sail>
+
+val "parse_hex_bits" : forall 'n, 'n > 0. (int('n), string) -> bits('n)
+val "valid_hex_bits" : forall 'n, 'n > 0. (int('n), string) -> bool
+
+val hex_bits : forall 'n, 'n > 0. bits('n) <-> (int('n), string)
+
+function hex_bits_forwards(bv) = (length(bv), hex_str(unsigned(bv)))
+function hex_bits_forwards_matches(bv) = true
+
+function hex_bits_backwards(n, str) = parse_hex_bits(n, str)
+function hex_bits_backwards_matches(n, str) = valid_hex_bits(n, str)
+
+mapping hex_bits_1 : bits(1) <-> string = { hex_bits(1, s) <-> s }
+mapping hex_bits_2 : bits(2) <-> string = { hex_bits(2, s) <-> s }
+mapping hex_bits_3 : bits(3) <-> string = { hex_bits(3, s) <-> s }
+mapping hex_bits_4 : bits(4) <-> string = { hex_bits(4, s) <-> s }
+mapping hex_bits_5 : bits(5) <-> string = { hex_bits(5, s) <-> s }
+mapping hex_bits_6 : bits(6) <-> string = { hex_bits(6, s) <-> s }
+mapping hex_bits_7 : bits(7) <-> string = { hex_bits(7, s) <-> s }
+mapping hex_bits_8 : bits(8) <-> string = { hex_bits(8, s) <-> s }
+mapping hex_bits_9 : bits(9) <-> string = { hex_bits(9, s) <-> s }
+
+mapping hex_bits_10 : bits(10) <-> string = { hex_bits(10, s) <-> s }
+mapping hex_bits_11 : bits(11) <-> string = { hex_bits(11, s) <-> s }
+mapping hex_bits_12 : bits(12) <-> string = { hex_bits(12, s) <-> s }
+mapping hex_bits_13 : bits(13) <-> string = { hex_bits(13, s) <-> s }
+mapping hex_bits_14 : bits(14) <-> string = { hex_bits(14, s) <-> s }
+mapping hex_bits_15 : bits(15) <-> string = { hex_bits(15, s) <-> s }
+mapping hex_bits_16 : bits(16) <-> string = { hex_bits(16, s) <-> s }
+mapping hex_bits_17 : bits(17) <-> string = { hex_bits(17, s) <-> s }
+mapping hex_bits_18 : bits(18) <-> string = { hex_bits(18, s) <-> s }
+mapping hex_bits_19 : bits(19) <-> string = { hex_bits(19, s) <-> s }
+
+mapping hex_bits_20 : bits(20) <-> string = { hex_bits(20, s) <-> s }
+mapping hex_bits_21 : bits(21) <-> string = { hex_bits(21, s) <-> s }
+mapping hex_bits_22 : bits(22) <-> string = { hex_bits(22, s) <-> s }
+mapping hex_bits_23 : bits(23) <-> string = { hex_bits(23, s) <-> s }
+mapping hex_bits_24 : bits(24) <-> string = { hex_bits(24, s) <-> s }
+mapping hex_bits_25 : bits(25) <-> string = { hex_bits(25, s) <-> s }
+mapping hex_bits_26 : bits(26) <-> string = { hex_bits(26, s) <-> s }
+mapping hex_bits_27 : bits(27) <-> string = { hex_bits(27, s) <-> s }
+mapping hex_bits_28 : bits(28) <-> string = { hex_bits(28, s) <-> s }
+mapping hex_bits_29 : bits(29) <-> string = { hex_bits(29, s) <-> s }
+
+mapping hex_bits_30 : bits(30) <-> string = { hex_bits(30, s) <-> s }
+mapping hex_bits_31 : bits(31) <-> string = { hex_bits(31, s) <-> s }
+mapping hex_bits_32 : bits(32) <-> string = { hex_bits(32, s) <-> s }
+
+$endif _HEX_BITS
diff --git a/model/main.sail b/model/main.sail
index 6887120..c545e27 100644
--- a/model/main.sail
+++ b/model/main.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
function main () : unit -> unit = {
diff --git a/model/mapping.sail b/model/mapping.sail
new file mode 100644
index 0000000..ec8b759
--- /dev/null
+++ b/model/mapping.sail
@@ -0,0 +1,136 @@
+// Note: This file is temporarily copied here from the Sail compiler. It can
+// be removed when Sail 0.18 is released.
+
+/*==========================================================================*/
+/* Sail */
+/* */
+/* Sail and the Sail architecture models here, comprising all files and */
+/* directories except the ASL-derived Sail code in the aarch64 directory, */
+/* are subject to the BSD two-clause licence below. */
+/* */
+/* The ASL derived parts of the ARMv8.3 specification in */
+/* aarch64/no_vector and aarch64/full are copyright ARM Ltd. */
+/* */
+/* Copyright (c) 2013-2021 */
+/* Kathyrn Gray */
+/* Shaked Flur */
+/* Stephen Kell */
+/* Gabriel Kerneis */
+/* Robert Norton-Wright */
+/* Christopher Pulte */
+/* Peter Sewell */
+/* Alasdair Armstrong */
+/* Brian Campbell */
+/* Thomas Bauereiss */
+/* Anthony Fox */
+/* Jon French */
+/* Dominic Mulligan */
+/* Stephen Kell */
+/* Mark Wassell */
+/* Alastair Reid (Arm Ltd) */
+/* */
+/* All rights reserved. */
+/* */
+/* This work was partially supported by EPSRC grant EP/K008528/1 <a */
+/* href="http://www.cl.cam.ac.uk/users/pes20/rems">REMS: Rigorous */
+/* Engineering for Mainstream Systems</a>, an ARM iCASE award, EPSRC IAA */
+/* KTF funding, and donations from Arm. This project has received */
+/* funding from the European Research Council (ERC) under the European */
+/* Union’s Horizon 2020 research and innovation programme (grant */
+/* agreement No 789108, ELVER). */
+/* */
+/* This software was developed by SRI International and the University of */
+/* Cambridge Computer Laboratory (Department of Computer Science and */
+/* Technology) under DARPA/AFRL contracts FA8650-18-C-7809 ("CIFV") */
+/* and FA8750-10-C-0237 ("CTSRD"). */
+/* */
+/* Redistribution and use in source and binary forms, with or without */
+/* modification, are permitted provided that the following conditions */
+/* are met: */
+/* 1. Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* 2. Redistributions in binary form must reproduce the above copyright */
+/* notice, this list of conditions and the following disclaimer in */
+/* the documentation and/or other materials provided with the */
+/* distribution. */
+/* */
+/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
+/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
+/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
+/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
+/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
+/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
+/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
+/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
+/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
+/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
+/* SUCH DAMAGE. */
+/*==========================================================================*/
+
+$ifndef _MAPPING
+$define _MAPPING
+
+$include <arith.sail>
+$include <option.sail>
+
+val string_take = pure "string_take" : (string, nat) -> string
+val string_drop = pure "string_drop" : (string, nat) -> string
+val string_length = pure "string_length" : string -> nat
+val string_append = pure {coq: "String.append", c: "concat_str", _: "string_append"} : (string, string) -> string
+val string_startswith = pure "string_startswith" : (string, string) -> bool
+
+val n_leading_spaces = pure { coq: "n_leading_spaces_Z" } : string -> nat
+function n_leading_spaces s =
+ match s {
+ "" => 0,
+ _ => match string_take(s, 1) {
+ " " => 1 + n_leading_spaces(string_drop(s, 1)),
+ _ => 0
+ }
+ }
+
+/*!
+In a string mapping this is treated as `[ ]+`, i.e one or more space
+characters. It is printed as a single space `" "`.
+*/
+val spc : unit <-> string
+
+function spc_forwards() = " "
+function spc_forwards_matches() = true
+
+function spc_backwards _ = ()
+function spc_backwards_matches s = {
+ let len = string_length(s);
+ n_leading_spaces(s) == len & len > 0
+}
+
+/*!
+In a string mapping this is treated as `[ ]*`, i.e. zero or more space
+characters. It is printed as the empty string.
+*/
+val opt_spc : unit <-> string
+
+function opt_spc_forwards() = ""
+function opt_spc_forwards_matches() = true
+
+function opt_spc_backwards _ = ()
+function opt_spc_backwards_matches s = n_leading_spaces(s) == string_length(s)
+
+/*!
+Like `opt_spc`, in a string mapping this is treated as `[ ]*`, i.e. zero or more space
+characters. It differs however in that it is printed as a single space `" "`.
+*/
+val def_spc : unit <-> string
+
+function def_spc_forwards() = " "
+function def_spc_forwards_matches() = true
+
+function def_spc_backwards _ = ()
+function def_spc_backwards_matches s = n_leading_spaces(s) == string_length(s)
+
+mapping sep : unit <-> string = {
+ () <-> opt_spc() ^ "," ^ def_spc()
+}
+
+$endif
diff --git a/model/prelude.sail b/model/prelude.sail
index 6b5e46c..028af21 100644
--- a/model/prelude.sail
+++ b/model/prelude.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
default Order dec
@@ -74,69 +12,33 @@ $include <smt.sail>
$include <option.sail>
$include <arith.sail>
$include <string.sail>
+$include "mapping.sail"
$include <vector_dec.sail>
$include <regfp.sail>
+$include <generic_equality.sail>
+$include "hex_bits.sail"
-val string_startswith = "string_startswith" : (string, string) -> bool
-val string_drop = "string_drop" : (string, nat) -> string
-val string_take = "string_take" : (string, nat) -> string
-val string_length = "string_length" : string -> nat
-val string_append = {c: "concat_str", _: "string_append"} : (string, string) -> string
-
-val eq_anything = {ocaml: "(fun (x, y) -> x = y)", interpreter: "eq_anything", lem: "eq", coq: "generic_eq", c: "eq_anything"} : forall ('a : Type). ('a, 'a) -> bool
-
-overload operator == = {eq_string, eq_anything}
-
-val "reg_deref" : forall ('a : Type). register('a) -> 'a
-/* sneaky deref with no effect necessary for bitfield writes */
-val _reg_deref = "reg_deref" : forall ('a : Type). register('a) -> 'a
-
-val any_vector_update = {ocaml: "update", lem: "update_list_dec", coq: "vector_update"} : forall 'n ('a : Type).
- (vector('n, dec, 'a), int, 'a) -> vector('n, dec, 'a)
-
-overload vector_update = {any_vector_update}
-
-val update_subrange = {ocaml: "update_subrange", interpreter: "update_subrange", lem: "update_subrange_vec_dec", coq: "update_subrange_vec_dec"} : forall 'n 'm 'o.
- (bits('n), atom('m), atom('o), bits('m - ('o - 1))) -> bits('n)
-
-val vector_concat = {ocaml: "append", lem: "append_list", coq: "vec_concat"} : forall ('n : Int) ('m : Int) ('a : Type).
- (vector('n, dec, 'a), vector('m, dec, 'a)) -> vector('n + 'm, dec, 'a)
-
-overload append = {vector_concat}
val not_bit : bit -> bit
-
function not_bit(b) = if b == bitone then bitzero else bitone
overload ~ = {not_bool, not_vec, not_bit}
-val not = pure {coq: "negb", _: "not"} : forall ('p : Bool). bool('p) -> bool(not('p))
-
-val neq_vec = {lem: "neq"} : forall 'n. (bits('n), bits('n)) -> bool
-
-function neq_vec (x, y) = not_bool(eq_bits(x, y))
-
-val neq_anything = {lem: "neq", coq: "generic_neq"} : forall ('a : Type). ('a, 'a) -> bool
-
-function neq_anything (x, y) = not_bool(x == y)
-
-overload operator != = {neq_vec, neq_anything}
+// not_bool alias.
+val not : forall ('p : Bool). bool('p) -> bool(not('p))
+function not(b) = not_bool(b)
overload operator & = {and_vec}
overload operator | = {or_vec}
-val string_of_int = {c: "string_of_int", ocaml: "string_of_int", interpreter: "string_of_int", lem: "stringFromInteger", coq: "string_of_int"} : int -> string
-
-val "string_of_bits" : forall 'n. bits('n) -> string
-
-function string_of_bit(b: bit) -> string =
+function bit_str(b: bit) -> string =
match b {
bitzero => "0b0",
bitone => "0b1"
}
-overload BitStr = {string_of_bits, string_of_bit}
+overload BitStr = {bits_str, bit_str}
val int_power = {ocaml: "int_power", interpreter: "int_power", lem: "pow", coq: "pow", c: "pow_int"} : (int, int) -> int
@@ -164,7 +66,7 @@ overload min = {min_int}
overload max = {max_int}
-val pow2 = "pow2" : forall 'n. atom('n) -> atom(2 ^ 'n)
+val pow2 = "pow2" : forall 'n. int('n) -> int(2 ^ 'n)
val print = "print_endline" : string -> unit
val print_string = "print_string" : (string, string) -> unit
@@ -210,26 +112,35 @@ function bit_to_bool b = match b {
bitzero => false
}
-val to_bits : forall 'l, 'l >= 0.(atom('l), int) -> bits('l)
+val to_bits : forall 'l, 'l >= 0.(int('l), int) -> bits('l)
function to_bits (l, n) = get_slice_int(l, n, 0)
infix 4 <_s
+infix 4 >_s
+infix 4 <=_s
infix 4 >=_s
infix 4 <_u
-infix 4 >=_u
+infix 4 >_u
infix 4 <=_u
+infix 4 >=_u
val operator <_s : forall 'n, 'n > 0. (bits('n), bits('n)) -> bool
+val operator >_s : forall 'n, 'n > 0. (bits('n), bits('n)) -> bool
+val operator <=_s : forall 'n, 'n > 0. (bits('n), bits('n)) -> bool
val operator >=_s : forall 'n, 'n > 0. (bits('n), bits('n)) -> bool
val operator <_u : forall 'n. (bits('n), bits('n)) -> bool
-val operator >=_u : forall 'n. (bits('n), bits('n)) -> bool
+val operator >_u : forall 'n. (bits('n), bits('n)) -> bool
val operator <=_u : forall 'n. (bits('n), bits('n)) -> bool
+val operator >=_u : forall 'n. (bits('n), bits('n)) -> bool
function operator <_s (x, y) = signed(x) < signed(y)
+function operator >_s (x, y) = signed(x) > signed(y)
+function operator <=_s (x, y) = signed(x) <= signed(y)
function operator >=_s (x, y) = signed(x) >= signed(y)
function operator <_u (x, y) = unsigned(x) < unsigned(y)
-function operator >=_u (x, y) = unsigned(x) >= unsigned(y)
+function operator >_u (x, y) = unsigned(x) > unsigned(y)
function operator <=_u (x, y) = unsigned(x) <= unsigned(y)
+function operator >=_u (x, y) = unsigned(x) >= unsigned(y)
infix 7 >>
infix 7 <<
@@ -237,8 +148,8 @@ infix 7 <<
val "shift_bits_right" : forall 'n 'm. (bits('n), bits('m)) -> bits('n)
val "shift_bits_left" : forall 'n 'm. (bits('n), bits('m)) -> bits('n)
-val "shiftl" : forall 'm 'n, 'n >= 0. (bits('m), atom('n)) -> bits('m)
-val "shiftr" : forall 'm 'n, 'n >= 0. (bits('m), atom('n)) -> bits('m)
+val "shiftl" : forall 'm 'n, 'n >= 0. (bits('m), int('n)) -> bits('m)
+val "shiftr" : forall 'm 'n, 'n >= 0. (bits('m), int('n)) -> bits('m)
overload operator >> = {shift_bits_right, shiftr}
overload operator << = {shift_bits_left, shiftl}
@@ -264,11 +175,11 @@ val rotate_bits_left : forall 'n 'm, 'm >= 0. (bits('n), bits('m)) -> bits('n)
function rotate_bits_left (v, n) =
(v << n) | (v >> (to_bits(length(n), length(v)) - n))
-val rotater : forall 'm 'n, 'm >= 'n >= 0. (bits('m), atom('n)) -> bits('m)
+val rotater : forall 'm 'n, 'm >= 'n >= 0. (bits('m), int('n)) -> bits('m)
function rotater (v, n) =
(v >> n) | (v << (length(v) - n))
-val rotatel : forall 'm 'n, 'm >= 'n >= 0. (bits('m), atom('n)) -> bits('m)
+val rotatel : forall 'm 'n, 'm >= 'n >= 0. (bits('m), int('n)) -> bits('m)
function rotatel (v, n) =
(v << n) | (v >> (length(v) - n))
@@ -284,53 +195,6 @@ function reverse_bits_in_byte (xs : bits(8)) -> bits(8) = {
overload reverse = {reverse_bits_in_byte}
-/* helpers for mappings */
-
-val spc : unit <-> string
-val opt_spc : unit <-> string
-val def_spc : unit <-> string
-
-val "decimal_string_of_bits" : forall 'n. bits('n) -> string
-val hex_bits : forall 'n . (atom('n), bits('n)) <-> string
-
-val n_leading_spaces : string -> nat
-function n_leading_spaces s =
- match s {
- "" => 0,
- _ => match string_take(s, 1) {
- " " => 1 + n_leading_spaces(string_drop(s, 1)),
- _ => 0
- }
- }
-
-val spc_forwards : unit -> string
-function spc_forwards () = " "
-val spc_backwards : string -> unit
-function spc_backwards s = ()
-val spc_matches_prefix : string -> option((unit, nat))
-function spc_matches_prefix s = {
- let n = n_leading_spaces(s);
- match n {
- 0 => None(),
- _ => Some((), n)
- }
-}
-
-val opt_spc_forwards : unit -> string
-function opt_spc_forwards () = ""
-val opt_spc_backwards : string -> unit
-function opt_spc_backwards s = ()
-val opt_spc_matches_prefix : string -> option((unit, nat))
-function opt_spc_matches_prefix s =
- Some((), n_leading_spaces(s))
-
-val def_spc_forwards : unit -> string
-function def_spc_forwards () = " "
-val def_spc_backwards : string -> unit
-function def_spc_backwards s = ()
-val def_spc_matches_prefix : string -> option((unit, nat))
-function def_spc_matches_prefix s = opt_spc_matches_prefix(s)
-
overload operator / = {quot_round_zero}
overload operator * = {mult_atom, mult_int}
diff --git a/model/prelude_mapping.sail b/model/prelude_mapping.sail
deleted file mode 100644
index ff449d1..0000000
--- a/model/prelude_mapping.sail
+++ /dev/null
@@ -1,771 +0,0 @@
-/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
-/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=======================================================================================*/
-
-/* Some helper functions for the assembler mappings. */
-
-/* These mappings produce a lot of pattern match warnings that are not useful.
- The following directive suppresses them (and will be ignored by older versions of Sail
- with one additional warning). Would be better to fix the warnings properly but I don't
- know how. */
-$suppress_warnings
-
-/* Python:
-f = """val hex_bits_{0} : bits({0}) <-> string
-val hex_bits_{0}_forwards = "decimal_string_of_bits" : bits({0}) -> string
-val hex_bits_{0}_forwards_matches : bits({0}) -> bool
-function hex_bits_{0}_forwards_matches bv = true
-val "hex_bits_{0}_matches_prefix" : string -> option((bits({0}), nat))
-val hex_bits_{0}_backwards_matches : string -> bool
-function hex_bits_{0}_backwards_matches s = match s {{
- s if match hex_bits_{0}_matches_prefix(s) {{
- Some (_, n) if n == string_length(s) => true,
- _ => false
- }} => true,
- _ => false
-}}
-val hex_bits_{0}_backwards : string -> bits({0})
-function hex_bits_{0}_backwards s =
- match hex_bits_{0}_matches_prefix(s) {{
- Some (bv, n) if n == string_length(s) => bv
- }}
-"""
-
-for i in list(range(1, 34)) + [48, 64]:
- print(f.format(i))
-
-*/
-val hex_bits_1 : bits(1) <-> string
-val hex_bits_1_forwards = "decimal_string_of_bits" : bits(1) -> string
-val hex_bits_1_forwards_matches : bits(1) -> bool
-function hex_bits_1_forwards_matches bv = true
-val "hex_bits_1_matches_prefix" : string -> option((bits(1), nat))
-val hex_bits_1_backwards_matches : string -> bool
-function hex_bits_1_backwards_matches s = match s {
- s if match hex_bits_1_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_1_backwards : string -> bits(1)
-function hex_bits_1_backwards s =
- match hex_bits_1_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_2 : bits(2) <-> string
-val hex_bits_2_forwards = "decimal_string_of_bits" : bits(2) -> string
-val hex_bits_2_forwards_matches : bits(2) -> bool
-function hex_bits_2_forwards_matches bv = true
-val "hex_bits_2_matches_prefix" : string -> option((bits(2), nat))
-val hex_bits_2_backwards_matches : string -> bool
-function hex_bits_2_backwards_matches s = match s {
- s if match hex_bits_2_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_2_backwards : string -> bits(2)
-function hex_bits_2_backwards s =
- match hex_bits_2_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_3 : bits(3) <-> string
-val hex_bits_3_forwards = "decimal_string_of_bits" : bits(3) -> string
-val hex_bits_3_forwards_matches : bits(3) -> bool
-function hex_bits_3_forwards_matches bv = true
-val "hex_bits_3_matches_prefix" : string -> option((bits(3), nat))
-val hex_bits_3_backwards_matches : string -> bool
-function hex_bits_3_backwards_matches s = match s {
- s if match hex_bits_3_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_3_backwards : string -> bits(3)
-function hex_bits_3_backwards s =
- match hex_bits_3_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_4 : bits(4) <-> string
-val hex_bits_4_forwards = "decimal_string_of_bits" : bits(4) -> string
-val hex_bits_4_forwards_matches : bits(4) -> bool
-function hex_bits_4_forwards_matches bv = true
-val "hex_bits_4_matches_prefix" : string -> option((bits(4), nat))
-val hex_bits_4_backwards_matches : string -> bool
-function hex_bits_4_backwards_matches s = match s {
- s if match hex_bits_4_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_4_backwards : string -> bits(4)
-function hex_bits_4_backwards s =
- match hex_bits_4_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_5 : bits(5) <-> string
-val hex_bits_5_forwards = "decimal_string_of_bits" : bits(5) -> string
-val hex_bits_5_forwards_matches : bits(5) -> bool
-function hex_bits_5_forwards_matches bv = true
-val "hex_bits_5_matches_prefix" : string -> option((bits(5), nat))
-val hex_bits_5_backwards_matches : string -> bool
-function hex_bits_5_backwards_matches s = match s {
- s if match hex_bits_5_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_5_backwards : string -> bits(5)
-function hex_bits_5_backwards s =
- match hex_bits_5_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_6 : bits(6) <-> string
-val hex_bits_6_forwards = "decimal_string_of_bits" : bits(6) -> string
-val hex_bits_6_forwards_matches : bits(6) -> bool
-function hex_bits_6_forwards_matches bv = true
-val "hex_bits_6_matches_prefix" : string -> option((bits(6), nat))
-val hex_bits_6_backwards_matches : string -> bool
-function hex_bits_6_backwards_matches s = match s {
- s if match hex_bits_6_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_6_backwards : string -> bits(6)
-function hex_bits_6_backwards s =
- match hex_bits_6_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_7 : bits(7) <-> string
-val hex_bits_7_forwards = "decimal_string_of_bits" : bits(7) -> string
-val hex_bits_7_forwards_matches : bits(7) -> bool
-function hex_bits_7_forwards_matches bv = true
-val "hex_bits_7_matches_prefix" : string -> option((bits(7), nat))
-val hex_bits_7_backwards_matches : string -> bool
-function hex_bits_7_backwards_matches s = match s {
- s if match hex_bits_7_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_7_backwards : string -> bits(7)
-function hex_bits_7_backwards s =
- match hex_bits_7_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_8 : bits(8) <-> string
-val hex_bits_8_forwards = "decimal_string_of_bits" : bits(8) -> string
-val hex_bits_8_forwards_matches : bits(8) -> bool
-function hex_bits_8_forwards_matches bv = true
-val "hex_bits_8_matches_prefix" : string -> option((bits(8), nat))
-val hex_bits_8_backwards_matches : string -> bool
-function hex_bits_8_backwards_matches s = match s {
- s if match hex_bits_8_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_8_backwards : string -> bits(8)
-function hex_bits_8_backwards s =
- match hex_bits_8_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_9 : bits(9) <-> string
-val hex_bits_9_forwards = "decimal_string_of_bits" : bits(9) -> string
-val hex_bits_9_forwards_matches : bits(9) -> bool
-function hex_bits_9_forwards_matches bv = true
-val "hex_bits_9_matches_prefix" : string -> option((bits(9), nat))
-val hex_bits_9_backwards_matches : string -> bool
-function hex_bits_9_backwards_matches s = match s {
- s if match hex_bits_9_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_9_backwards : string -> bits(9)
-function hex_bits_9_backwards s =
- match hex_bits_9_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_10 : bits(10) <-> string
-val hex_bits_10_forwards = "decimal_string_of_bits" : bits(10) -> string
-val hex_bits_10_forwards_matches : bits(10) -> bool
-function hex_bits_10_forwards_matches bv = true
-val "hex_bits_10_matches_prefix" : string -> option((bits(10), nat))
-val hex_bits_10_backwards_matches : string -> bool
-function hex_bits_10_backwards_matches s = match s {
- s if match hex_bits_10_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_10_backwards : string -> bits(10)
-function hex_bits_10_backwards s =
- match hex_bits_10_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_11 : bits(11) <-> string
-val hex_bits_11_forwards = "decimal_string_of_bits" : bits(11) -> string
-val hex_bits_11_forwards_matches : bits(11) -> bool
-function hex_bits_11_forwards_matches bv = true
-val "hex_bits_11_matches_prefix" : string -> option((bits(11), nat))
-val hex_bits_11_backwards_matches : string -> bool
-function hex_bits_11_backwards_matches s = match s {
- s if match hex_bits_11_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_11_backwards : string -> bits(11)
-function hex_bits_11_backwards s =
- match hex_bits_11_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_12 : bits(12) <-> string
-val hex_bits_12_forwards = "decimal_string_of_bits" : bits(12) -> string
-val hex_bits_12_forwards_matches : bits(12) -> bool
-function hex_bits_12_forwards_matches bv = true
-// XXX TODO the following builtin does not exist (at least for C backend) so I have
-// substituted a dummy one that always returns None. This means that assembly_backwards
-// (i.e. string -> ast) might not work but we don't actually use that for anything.
-//val "hex_bits_12_matches_prefix" : string -> option((bits(12), nat))
-function hex_bits_12_matches_prefix (s : string) -> option((bits(12), nat)) = None()
-val hex_bits_12_backwards_matches : string -> bool
-function hex_bits_12_backwards_matches s = match s {
- s if match hex_bits_12_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_12_backwards : string -> bits(12)
-function hex_bits_12_backwards s =
- match hex_bits_12_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_13 : bits(13) <-> string
-val hex_bits_13_forwards = "decimal_string_of_bits" : bits(13) -> string
-val hex_bits_13_forwards_matches : bits(13) -> bool
-function hex_bits_13_forwards_matches bv = true
-val "hex_bits_13_matches_prefix" : string -> option((bits(13), nat))
-val hex_bits_13_backwards_matches : string -> bool
-function hex_bits_13_backwards_matches s = match s {
- s if match hex_bits_13_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_13_backwards : string -> bits(13)
-function hex_bits_13_backwards s =
- match hex_bits_13_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_14 : bits(14) <-> string
-val hex_bits_14_forwards = "decimal_string_of_bits" : bits(14) -> string
-val hex_bits_14_forwards_matches : bits(14) -> bool
-function hex_bits_14_forwards_matches bv = true
-val "hex_bits_14_matches_prefix" : string -> option((bits(14), nat))
-val hex_bits_14_backwards_matches : string -> bool
-function hex_bits_14_backwards_matches s = match s {
- s if match hex_bits_14_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_14_backwards : string -> bits(14)
-function hex_bits_14_backwards s =
- match hex_bits_14_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_15 : bits(15) <-> string
-val hex_bits_15_forwards = "decimal_string_of_bits" : bits(15) -> string
-val hex_bits_15_forwards_matches : bits(15) -> bool
-function hex_bits_15_forwards_matches bv = true
-val "hex_bits_15_matches_prefix" : string -> option((bits(15), nat))
-val hex_bits_15_backwards_matches : string -> bool
-function hex_bits_15_backwards_matches s = match s {
- s if match hex_bits_15_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_15_backwards : string -> bits(15)
-function hex_bits_15_backwards s =
- match hex_bits_15_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_16 : bits(16) <-> string
-val hex_bits_16_forwards = "decimal_string_of_bits" : bits(16) -> string
-val hex_bits_16_forwards_matches : bits(16) -> bool
-function hex_bits_16_forwards_matches bv = true
-val "hex_bits_16_matches_prefix" : string -> option((bits(16), nat))
-val hex_bits_16_backwards_matches : string -> bool
-function hex_bits_16_backwards_matches s = match s {
- s if match hex_bits_16_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_16_backwards : string -> bits(16)
-function hex_bits_16_backwards s =
- match hex_bits_16_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_17 : bits(17) <-> string
-val hex_bits_17_forwards = "decimal_string_of_bits" : bits(17) -> string
-val hex_bits_17_forwards_matches : bits(17) -> bool
-function hex_bits_17_forwards_matches bv = true
-val "hex_bits_17_matches_prefix" : string -> option((bits(17), nat))
-val hex_bits_17_backwards_matches : string -> bool
-function hex_bits_17_backwards_matches s = match s {
- s if match hex_bits_17_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_17_backwards : string -> bits(17)
-function hex_bits_17_backwards s =
- match hex_bits_17_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_18 : bits(18) <-> string
-val hex_bits_18_forwards = "decimal_string_of_bits" : bits(18) -> string
-val hex_bits_18_forwards_matches : bits(18) -> bool
-function hex_bits_18_forwards_matches bv = true
-val "hex_bits_18_matches_prefix" : string -> option((bits(18), nat))
-val hex_bits_18_backwards_matches : string -> bool
-function hex_bits_18_backwards_matches s = match s {
- s if match hex_bits_18_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_18_backwards : string -> bits(18)
-function hex_bits_18_backwards s =
- match hex_bits_18_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_19 : bits(19) <-> string
-val hex_bits_19_forwards = "decimal_string_of_bits" : bits(19) -> string
-val hex_bits_19_forwards_matches : bits(19) -> bool
-function hex_bits_19_forwards_matches bv = true
-val "hex_bits_19_matches_prefix" : string -> option((bits(19), nat))
-val hex_bits_19_backwards_matches : string -> bool
-function hex_bits_19_backwards_matches s = match s {
- s if match hex_bits_19_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_19_backwards : string -> bits(19)
-function hex_bits_19_backwards s =
- match hex_bits_19_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_20 : bits(20) <-> string
-val hex_bits_20_forwards = "decimal_string_of_bits" : bits(20) -> string
-val hex_bits_20_forwards_matches : bits(20) -> bool
-function hex_bits_20_forwards_matches bv = true
-val "hex_bits_20_matches_prefix" : string -> option((bits(20), nat))
-val hex_bits_20_backwards_matches : string -> bool
-function hex_bits_20_backwards_matches s = match s {
- s if match hex_bits_20_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_20_backwards : string -> bits(20)
-function hex_bits_20_backwards s =
- match hex_bits_20_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_21 : bits(21) <-> string
-val hex_bits_21_forwards = "decimal_string_of_bits" : bits(21) -> string
-val hex_bits_21_forwards_matches : bits(21) -> bool
-function hex_bits_21_forwards_matches bv = true
-val "hex_bits_21_matches_prefix" : string -> option((bits(21), nat))
-val hex_bits_21_backwards_matches : string -> bool
-function hex_bits_21_backwards_matches s = match s {
- s if match hex_bits_21_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_21_backwards : string -> bits(21)
-function hex_bits_21_backwards s =
- match hex_bits_21_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_22 : bits(22) <-> string
-val hex_bits_22_forwards = "decimal_string_of_bits" : bits(22) -> string
-val hex_bits_22_forwards_matches : bits(22) -> bool
-function hex_bits_22_forwards_matches bv = true
-val "hex_bits_22_matches_prefix" : string -> option((bits(22), nat))
-val hex_bits_22_backwards_matches : string -> bool
-function hex_bits_22_backwards_matches s = match s {
- s if match hex_bits_22_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_22_backwards : string -> bits(22)
-function hex_bits_22_backwards s =
- match hex_bits_22_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_23 : bits(23) <-> string
-val hex_bits_23_forwards = "decimal_string_of_bits" : bits(23) -> string
-val hex_bits_23_forwards_matches : bits(23) -> bool
-function hex_bits_23_forwards_matches bv = true
-val "hex_bits_23_matches_prefix" : string -> option((bits(23), nat))
-val hex_bits_23_backwards_matches : string -> bool
-function hex_bits_23_backwards_matches s = match s {
- s if match hex_bits_23_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_23_backwards : string -> bits(23)
-function hex_bits_23_backwards s =
- match hex_bits_23_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_24 : bits(24) <-> string
-val hex_bits_24_forwards = "decimal_string_of_bits" : bits(24) -> string
-val hex_bits_24_forwards_matches : bits(24) -> bool
-function hex_bits_24_forwards_matches bv = true
-val "hex_bits_24_matches_prefix" : string -> option((bits(24), nat))
-val hex_bits_24_backwards_matches : string -> bool
-function hex_bits_24_backwards_matches s = match s {
- s if match hex_bits_24_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_24_backwards : string -> bits(24)
-function hex_bits_24_backwards s =
- match hex_bits_24_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_25 : bits(25) <-> string
-val hex_bits_25_forwards = "decimal_string_of_bits" : bits(25) -> string
-val hex_bits_25_forwards_matches : bits(25) -> bool
-function hex_bits_25_forwards_matches bv = true
-val "hex_bits_25_matches_prefix" : string -> option((bits(25), nat))
-val hex_bits_25_backwards_matches : string -> bool
-function hex_bits_25_backwards_matches s = match s {
- s if match hex_bits_25_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_25_backwards : string -> bits(25)
-function hex_bits_25_backwards s =
- match hex_bits_25_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_26 : bits(26) <-> string
-val hex_bits_26_forwards = "decimal_string_of_bits" : bits(26) -> string
-val hex_bits_26_forwards_matches : bits(26) -> bool
-function hex_bits_26_forwards_matches bv = true
-val "hex_bits_26_matches_prefix" : string -> option((bits(26), nat))
-val hex_bits_26_backwards_matches : string -> bool
-function hex_bits_26_backwards_matches s = match s {
- s if match hex_bits_26_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_26_backwards : string -> bits(26)
-function hex_bits_26_backwards s =
- match hex_bits_26_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_27 : bits(27) <-> string
-val hex_bits_27_forwards = "decimal_string_of_bits" : bits(27) -> string
-val hex_bits_27_forwards_matches : bits(27) -> bool
-function hex_bits_27_forwards_matches bv = true
-val "hex_bits_27_matches_prefix" : string -> option((bits(27), nat))
-val hex_bits_27_backwards_matches : string -> bool
-function hex_bits_27_backwards_matches s = match s {
- s if match hex_bits_27_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_27_backwards : string -> bits(27)
-function hex_bits_27_backwards s =
- match hex_bits_27_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_28 : bits(28) <-> string
-val hex_bits_28_forwards = "decimal_string_of_bits" : bits(28) -> string
-val hex_bits_28_forwards_matches : bits(28) -> bool
-function hex_bits_28_forwards_matches bv = true
-val "hex_bits_28_matches_prefix" : string -> option((bits(28), nat))
-val hex_bits_28_backwards_matches : string -> bool
-function hex_bits_28_backwards_matches s = match s {
- s if match hex_bits_28_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_28_backwards : string -> bits(28)
-function hex_bits_28_backwards s =
- match hex_bits_28_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_29 : bits(29) <-> string
-val hex_bits_29_forwards = "decimal_string_of_bits" : bits(29) -> string
-val hex_bits_29_forwards_matches : bits(29) -> bool
-function hex_bits_29_forwards_matches bv = true
-val "hex_bits_29_matches_prefix" : string -> option((bits(29), nat))
-val hex_bits_29_backwards_matches : string -> bool
-function hex_bits_29_backwards_matches s = match s {
- s if match hex_bits_29_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_29_backwards : string -> bits(29)
-function hex_bits_29_backwards s =
- match hex_bits_29_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_30 : bits(30) <-> string
-val hex_bits_30_forwards = "decimal_string_of_bits" : bits(30) -> string
-val hex_bits_30_forwards_matches : bits(30) -> bool
-function hex_bits_30_forwards_matches bv = true
-val "hex_bits_30_matches_prefix" : string -> option((bits(30), nat))
-val hex_bits_30_backwards_matches : string -> bool
-function hex_bits_30_backwards_matches s = match s {
- s if match hex_bits_30_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_30_backwards : string -> bits(30)
-function hex_bits_30_backwards s =
- match hex_bits_30_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_31 : bits(31) <-> string
-val hex_bits_31_forwards = "decimal_string_of_bits" : bits(31) -> string
-val hex_bits_31_forwards_matches : bits(31) -> bool
-function hex_bits_31_forwards_matches bv = true
-val "hex_bits_31_matches_prefix" : string -> option((bits(31), nat))
-val hex_bits_31_backwards_matches : string -> bool
-function hex_bits_31_backwards_matches s = match s {
- s if match hex_bits_31_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_31_backwards : string -> bits(31)
-function hex_bits_31_backwards s =
- match hex_bits_31_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_32 : bits(32) <-> string
-val hex_bits_32_forwards = "decimal_string_of_bits" : bits(32) -> string
-val hex_bits_32_forwards_matches : bits(32) -> bool
-function hex_bits_32_forwards_matches bv = true
-val "hex_bits_32_matches_prefix" : string -> option((bits(32), nat))
-val hex_bits_32_backwards_matches : string -> bool
-function hex_bits_32_backwards_matches s = match s {
- s if match hex_bits_32_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_32_backwards : string -> bits(32)
-function hex_bits_32_backwards s =
- match hex_bits_32_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_33 : bits(33) <-> string
-val hex_bits_33_forwards = "decimal_string_of_bits" : bits(33) -> string
-val hex_bits_33_forwards_matches : bits(33) -> bool
-function hex_bits_33_forwards_matches bv = true
-val "hex_bits_33_matches_prefix" : string -> option((bits(33), nat))
-val hex_bits_33_backwards_matches : string -> bool
-function hex_bits_33_backwards_matches s = match s {
- s if match hex_bits_33_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_33_backwards : string -> bits(33)
-function hex_bits_33_backwards s =
- match hex_bits_33_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_48 : bits(48) <-> string
-val hex_bits_48_forwards = "decimal_string_of_bits" : bits(48) -> string
-val hex_bits_48_forwards_matches : bits(48) -> bool
-function hex_bits_48_forwards_matches bv = true
-val "hex_bits_48_matches_prefix" : string -> option((bits(48), nat))
-val hex_bits_48_backwards_matches : string -> bool
-function hex_bits_48_backwards_matches s = match s {
- s if match hex_bits_48_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_48_backwards : string -> bits(48)
-function hex_bits_48_backwards s =
- match hex_bits_48_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
-
-val hex_bits_64 : bits(64) <-> string
-val hex_bits_64_forwards = "decimal_string_of_bits" : bits(64) -> string
-val hex_bits_64_forwards_matches : bits(64) -> bool
-function hex_bits_64_forwards_matches bv = true
-val "hex_bits_64_matches_prefix" : string -> option((bits(64), nat))
-val hex_bits_64_backwards_matches : string -> bool
-function hex_bits_64_backwards_matches s = match s {
- s if match hex_bits_64_matches_prefix(s) {
- Some (_, n) if n == string_length(s) => true,
- _ => false
- } => true,
- _ => false
-}
-val hex_bits_64_backwards : string -> bits(64)
-function hex_bits_64_backwards s =
- match hex_bits_64_matches_prefix(s) {
- Some (bv, n) if n == string_length(s) => bv
- }
diff --git a/model/prelude_mem.sail b/model/prelude_mem.sail
index 3bbf437..c4f3d07 100644
--- a/model/prelude_mem.sail
+++ b/model/prelude_mem.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* These functions define the primitives for physical memory access.
@@ -89,7 +27,7 @@
capabilities and SIMD / vector instructions will also need more. */
type max_mem_access : Int = 16
-val write_ram = {lem: "write_ram", coq: "write_ram"} : forall 'n, 0 < 'n <= max_mem_access . (write_kind, xlenbits, atom('n), bits(8 * 'n), mem_meta) -> bool
+val write_ram = {lem: "write_ram", coq: "write_ram"} : forall 'n, 0 < 'n <= max_mem_access . (write_kind, xlenbits, int('n), bits(8 * 'n), mem_meta) -> bool
function write_ram(wk, addr, width, data, meta) = {
/* Write out metadata only if the value write succeeds.
* It is assumed for now that this write always succeeds;
@@ -103,14 +41,14 @@ function write_ram(wk, addr, width, data, meta) = {
ret
}
-val write_ram_ea : forall 'n, 0 < 'n <= max_mem_access . (write_kind, xlenbits, atom('n)) -> unit
+val write_ram_ea : forall 'n, 0 < 'n <= max_mem_access . (write_kind, xlenbits, int('n)) -> unit
function write_ram_ea(wk, addr, width) =
__write_mem_ea(wk, sizeof(xlen), addr, width)
-val read_ram = {lem: "read_ram", coq: "read_ram"} : forall 'n, 0 < 'n <= max_mem_access . (read_kind, xlenbits, atom('n), bool) -> (bits(8 * 'n), mem_meta)
+val read_ram = {lem: "read_ram", coq: "read_ram"} : forall 'n, 0 < 'n <= max_mem_access . (read_kind, xlenbits, int('n), bool) -> (bits(8 * 'n), mem_meta)
function read_ram(rk, addr, width, read_meta) =
let meta = if read_meta then __ReadRAM_Meta(addr, width) else default_meta in
(__read_mem(rk, sizeof(xlen), addr, width), meta)
-val __TraceMemoryWrite : forall 'n 'm. (atom('n), bits('m), bits(8 * 'n)) -> unit
-val __TraceMemoryRead : forall 'n 'm. (atom('n), bits('m), bits(8 * 'n)) -> unit
+val __TraceMemoryWrite : forall 'n 'm. (int('n), bits('m), bits(8 * 'n)) -> unit
+val __TraceMemoryRead : forall 'n 'm. (int('n), bits('m), bits(8 * 'n)) -> unit
diff --git a/model/prelude_mem_metadata.sail b/model/prelude_mem_metadata.sail
index 919cee3..b8dd81b 100644
--- a/model/prelude_mem_metadata.sail
+++ b/model/prelude_mem_metadata.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* The default metadata carries no information, and is implemented
@@ -76,8 +14,8 @@ type mem_meta = unit
let default_meta : mem_meta = ()
-val __WriteRAM_Meta : forall 'n. (xlenbits, atom('n), mem_meta) -> unit
+val __WriteRAM_Meta : forall 'n. (xlenbits, int('n), mem_meta) -> unit
function __WriteRAM_Meta(addr, width, meta) = ()
-val __ReadRAM_Meta : forall 'n. (xlenbits, atom('n)) -> mem_meta
+val __ReadRAM_Meta : forall 'n. (xlenbits, int('n)) -> mem_meta
function __ReadRAM_Meta(addr, width) = ()
diff --git a/model/riscv_addr_checks.sail b/model/riscv_addr_checks.sail
index 33091d9..f9c7835 100644
--- a/model/riscv_addr_checks.sail
+++ b/model/riscv_addr_checks.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* default fetch address checks */
diff --git a/model/riscv_addr_checks_common.sail b/model/riscv_addr_checks_common.sail
index f22ffb2..b7a2698 100644
--- a/model/riscv_addr_checks_common.sail
+++ b/model/riscv_addr_checks_common.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Extensions may wish to interpose on fetch, control transfer, and data
@@ -102,7 +40,7 @@ union Ext_PhysAddr_Check = {
* return Some(exception) to abort the read or None to allow it to proceed. The
* check is performed after PMP checks and does not apply to MMIO memory.
*/
-val ext_check_phys_mem_read : forall 'n, 0 < 'n <= max_mem_access . (AccessType (ext_access_type), xlenbits, atom('n), bool, bool, bool, bool) -> Ext_PhysAddr_Check
+val ext_check_phys_mem_read : forall 'n, 0 < 'n <= max_mem_access . (AccessType (ext_access_type), xlenbits, int('n), bool, bool, bool, bool) -> Ext_PhysAddr_Check
/*!
* Validate a write to physical memory.
@@ -110,4 +48,4 @@ val ext_check_phys_mem_read : forall 'n, 0 < 'n <= max_mem_access . (AccessType
* to abort the write or None to allow it to proceed. The check is performed
* after PMP checks and does not apply to MMIO memory.
*/
-val ext_check_phys_mem_write : forall 'n, 0 < 'n <= max_mem_access . (write_kind, xlenbits, atom('n), bits(8 * 'n), mem_meta) -> Ext_PhysAddr_Check
+val ext_check_phys_mem_write : forall 'n, 0 < 'n <= max_mem_access . (write_kind, xlenbits, int('n), bits(8 * 'n), mem_meta) -> Ext_PhysAddr_Check
diff --git a/model/riscv_analysis.sail b/model/riscv_analysis.sail
index fc801f6..0d72bed 100644
--- a/model/riscv_analysis.sail
+++ b/model/riscv_analysis.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
$include <regfp.sail>
diff --git a/model/riscv_csr_ext.sail b/model/riscv_csr_ext.sail
index d5af771..4d43df5 100644
--- a/model/riscv_csr_ext.sail
+++ b/model/riscv_csr_ext.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
mapping clause csr_name_map = reg <-> hex_bits_12(reg)
diff --git a/model/riscv_csr_map.sail b/model/riscv_csr_map.sail
index da68556..9e3e804 100644
--- a/model/riscv_csr_map.sail
+++ b/model/riscv_csr_map.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Mapping of csr addresses to their names. */
@@ -113,6 +51,8 @@ mapping clause csr_name_map = 0x143 <-> "stval"
mapping clause csr_name_map = 0x144 <-> "sip"
/* supervisor protection and translation */
mapping clause csr_name_map = 0x180 <-> "satp"
+/* supervisor envcfg */
+mapping clause csr_name_map = 0x10A <-> "senvcfg"
/* machine information registers */
mapping clause csr_name_map = 0xF11 <-> "mvendorid"
mapping clause csr_name_map = 0xF12 <-> "marchid"
@@ -127,6 +67,8 @@ mapping clause csr_name_map = 0x304 <-> "mie"
mapping clause csr_name_map = 0x305 <-> "mtvec"
mapping clause csr_name_map = 0x306 <-> "mcounteren"
mapping clause csr_name_map = 0x320 <-> "mcountinhibit"
+/* machine envcfg */
+mapping clause csr_name_map = 0x30A <-> "menvcfg"
/* machine trap handling */
mapping clause csr_name_map = 0x340 <-> "mscratch"
mapping clause csr_name_map = 0x341 <-> "mepc"
@@ -138,6 +80,18 @@ mapping clause csr_name_map = 0x3A0 <-> "pmpcfg0"
mapping clause csr_name_map = 0x3A1 <-> "pmpcfg1"
mapping clause csr_name_map = 0x3A2 <-> "pmpcfg2"
mapping clause csr_name_map = 0x3A3 <-> "pmpcfg3"
+mapping clause csr_name_map = 0x3A4 <-> "pmpcfg4"
+mapping clause csr_name_map = 0x3A5 <-> "pmpcfg5"
+mapping clause csr_name_map = 0x3A6 <-> "pmpcfg6"
+mapping clause csr_name_map = 0x3A7 <-> "pmpcfg7"
+mapping clause csr_name_map = 0x3A8 <-> "pmpcfg8"
+mapping clause csr_name_map = 0x3A9 <-> "pmpcfg9"
+mapping clause csr_name_map = 0x3AA <-> "pmpcfg10"
+mapping clause csr_name_map = 0x3AB <-> "pmpcfg11"
+mapping clause csr_name_map = 0x3AC <-> "pmpcfg12"
+mapping clause csr_name_map = 0x3AD <-> "pmpcfg13"
+mapping clause csr_name_map = 0x3AE <-> "pmpcfg14"
+mapping clause csr_name_map = 0x3AF <-> "pmpcfg15"
mapping clause csr_name_map = 0x3B0 <-> "pmpaddr0"
mapping clause csr_name_map = 0x3B1 <-> "pmpaddr1"
mapping clause csr_name_map = 0x3B2 <-> "pmpaddr2"
@@ -154,6 +108,54 @@ mapping clause csr_name_map = 0x3BC <-> "pmpaddr12"
mapping clause csr_name_map = 0x3BD <-> "pmpaddr13"
mapping clause csr_name_map = 0x3BE <-> "pmpaddr14"
mapping clause csr_name_map = 0x3BF <-> "pmpaddr15"
+mapping clause csr_name_map = 0x3C0 <-> "pmpaddr16"
+mapping clause csr_name_map = 0x3C1 <-> "pmpaddr17"
+mapping clause csr_name_map = 0x3C2 <-> "pmpaddr18"
+mapping clause csr_name_map = 0x3C3 <-> "pmpaddr19"
+mapping clause csr_name_map = 0x3C4 <-> "pmpaddr20"
+mapping clause csr_name_map = 0x3C5 <-> "pmpaddr21"
+mapping clause csr_name_map = 0x3C6 <-> "pmpaddr22"
+mapping clause csr_name_map = 0x3C7 <-> "pmpaddr23"
+mapping clause csr_name_map = 0x3C8 <-> "pmpaddr24"
+mapping clause csr_name_map = 0x3C9 <-> "pmpaddr25"
+mapping clause csr_name_map = 0x3CA <-> "pmpaddr26"
+mapping clause csr_name_map = 0x3CB <-> "pmpaddr27"
+mapping clause csr_name_map = 0x3CC <-> "pmpaddr28"
+mapping clause csr_name_map = 0x3CD <-> "pmpaddr29"
+mapping clause csr_name_map = 0x3CE <-> "pmpaddr30"
+mapping clause csr_name_map = 0x3CF <-> "pmpaddr31"
+mapping clause csr_name_map = 0x3D0 <-> "pmpaddr32"
+mapping clause csr_name_map = 0x3D1 <-> "pmpaddr33"
+mapping clause csr_name_map = 0x3D2 <-> "pmpaddr34"
+mapping clause csr_name_map = 0x3D3 <-> "pmpaddr35"
+mapping clause csr_name_map = 0x3D4 <-> "pmpaddr36"
+mapping clause csr_name_map = 0x3D5 <-> "pmpaddr37"
+mapping clause csr_name_map = 0x3D6 <-> "pmpaddr38"
+mapping clause csr_name_map = 0x3D7 <-> "pmpaddr39"
+mapping clause csr_name_map = 0x3D8 <-> "pmpaddr40"
+mapping clause csr_name_map = 0x3D9 <-> "pmpaddr41"
+mapping clause csr_name_map = 0x3DA <-> "pmpaddr42"
+mapping clause csr_name_map = 0x3DB <-> "pmpaddr43"
+mapping clause csr_name_map = 0x3DC <-> "pmpaddr44"
+mapping clause csr_name_map = 0x3DD <-> "pmpaddr45"
+mapping clause csr_name_map = 0x3DE <-> "pmpaddr46"
+mapping clause csr_name_map = 0x3DF <-> "pmpaddr47"
+mapping clause csr_name_map = 0x3E0 <-> "pmpaddr48"
+mapping clause csr_name_map = 0x3E1 <-> "pmpaddr49"
+mapping clause csr_name_map = 0x3E2 <-> "pmpaddr50"
+mapping clause csr_name_map = 0x3E3 <-> "pmpaddr51"
+mapping clause csr_name_map = 0x3E4 <-> "pmpaddr52"
+mapping clause csr_name_map = 0x3E5 <-> "pmpaddr53"
+mapping clause csr_name_map = 0x3E6 <-> "pmpaddr54"
+mapping clause csr_name_map = 0x3E7 <-> "pmpaddr55"
+mapping clause csr_name_map = 0x3E8 <-> "pmpaddr56"
+mapping clause csr_name_map = 0x3E9 <-> "pmpaddr57"
+mapping clause csr_name_map = 0x3EA <-> "pmpaddr58"
+mapping clause csr_name_map = 0x3EB <-> "pmpaddr59"
+mapping clause csr_name_map = 0x3EC <-> "pmpaddr60"
+mapping clause csr_name_map = 0x3ED <-> "pmpaddr61"
+mapping clause csr_name_map = 0x3EE <-> "pmpaddr62"
+mapping clause csr_name_map = 0x3EF <-> "pmpaddr63"
/* machine counters/timers */
mapping clause csr_name_map = 0xB00 <-> "mcycle"
mapping clause csr_name_map = 0xB02 <-> "minstret"
diff --git a/model/riscv_decode_ext.sail b/model/riscv_decode_ext.sail
index b215109..cea0e95 100644
--- a/model/riscv_decode_ext.sail
+++ b/model/riscv_decode_ext.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Extensions may wish to interpose and transform decoded instructions,
diff --git a/model/riscv_ext_regs.sail b/model/riscv_ext_regs.sail
index 8568e6a..28ed111 100644
--- a/model/riscv_ext_regs.sail
+++ b/model/riscv_ext_regs.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* This file contains register handling functions that can be
diff --git a/model/riscv_fdext_control.sail b/model/riscv_fdext_control.sail
index 563d600..8f29999 100644
--- a/model/riscv_fdext_control.sail
+++ b/model/riscv_fdext_control.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* **************************************************************** */
@@ -83,12 +21,12 @@ function clause ext_is_CSR_defined (0x001, _) = haveFExt() | haveZfinx()
function clause ext_is_CSR_defined (0x002, _) = haveFExt() | haveZfinx()
function clause ext_is_CSR_defined (0x003, _) = haveFExt() | haveZfinx()
-function clause ext_read_CSR (0x001) = Some (zero_extend (fcsr.FFLAGS()))
-function clause ext_read_CSR (0x002) = Some (zero_extend (fcsr.FRM()))
-function clause ext_read_CSR (0x003) = Some (zero_extend (fcsr.bits()))
+function clause ext_read_CSR (0x001) = Some(zero_extend(fcsr[FFLAGS]))
+function clause ext_read_CSR (0x002) = Some(zero_extend(fcsr[FRM]))
+function clause ext_read_CSR (0x003) = Some(zero_extend(fcsr.bits))
-function clause ext_write_CSR (0x001, value) = { ext_write_fcsr (fcsr.FRM(), value [4..0]); Some(zero_extend(fcsr.FFLAGS())) }
-function clause ext_write_CSR (0x002, value) = { ext_write_fcsr (value [2..0], fcsr.FFLAGS()); Some(zero_extend(fcsr.FRM())) }
-function clause ext_write_CSR (0x003, value) = { ext_write_fcsr (value [7..5], value [4..0]); Some(zero_extend(fcsr.bits())) }
+function clause ext_write_CSR (0x001, value) = { ext_write_fcsr(fcsr[FRM], value[4..0]); Some(zero_extend(fcsr[FFLAGS])) }
+function clause ext_write_CSR (0x002, value) = { ext_write_fcsr(value[2..0], fcsr[FFLAGS]); Some(zero_extend(fcsr[FRM])) }
+function clause ext_write_CSR (0x003, value) = { ext_write_fcsr(value[7..5], value[4..0]); Some(zero_extend(fcsr.bits)) }
/* **************************************************************** */
diff --git a/model/riscv_fdext_regs.sail b/model/riscv_fdext_regs.sail
index 7958016..4806bfc 100644
--- a/model/riscv_fdext_regs.sail
+++ b/model/riscv_fdext_regs.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* **************************************************************** */
@@ -99,7 +37,7 @@ function nan_box_H val_16b =
val nan_unbox_H : flenbits -> bits(16)
function nan_unbox_H regval =
if (sizeof(flen) == 32)
- then if regval [32..16] == 0x_FFFF
+ then if regval [31..16] == 0x_FFFF
then regval [15..0]
else canonical_NaN_H()
else if regval [63..16] == 0x_FFFF_FFFF_FFFF
@@ -165,8 +103,8 @@ register f31 : fregtype
function dirty_fd_context() -> unit = {
assert(sys_enable_fdext());
- mstatus->FS() = extStatus_to_bits(Dirty);
- mstatus->SD() = 0b1
+ mstatus[FS] = extStatus_to_bits(Dirty);
+ mstatus[SD] = 0b1
}
function dirty_fd_context_if_present() -> unit = {
@@ -261,7 +199,7 @@ function wF (r, in_v) = {
if get_config_print_reg()
then
/* TODO: will only print bits; should we print in floating point format? */
- print_reg("f" ^ string_of_int(r) ^ " <- " ^ FRegStr(v));
+ print_reg("f" ^ dec_str(r) ^ " <- " ^ FRegStr(v));
}
function rF_bits(i: bits(5)) -> flenbits = rF(unsigned(i))
@@ -526,18 +464,18 @@ register fcsr : Fcsr
val ext_write_fcsr : (bits(3), bits(5)) -> unit
function ext_write_fcsr (frm, fflags) = {
- fcsr->FRM() = frm; /* Note: frm can be an illegal value, 101, 110, 111 */
- fcsr->FFLAGS() = fflags;
+ fcsr[FRM] = frm; /* Note: frm can be an illegal value, 101, 110, 111 */
+ fcsr[FFLAGS] = fflags;
dirty_fd_context_if_present();
}
/* OR flags into the fflags register. */
val accrue_fflags : (bits(5)) -> unit
function accrue_fflags(flags) = {
- let f = fcsr.FFLAGS() | flags;
- if fcsr.FFLAGS() != f
+ let f = fcsr[FFLAGS] | flags;
+ if fcsr[FFLAGS] != f
then {
- fcsr->FFLAGS() = f;
+ fcsr[FFLAGS] = f;
dirty_fd_context_if_present();
}
}
diff --git a/model/riscv_fetch.sail b/model/riscv_fetch.sail
index 4c54ccc..9c9e06a 100644
--- a/model/riscv_fetch.sail
+++ b/model/riscv_fetch.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Current fetch hooks for RISC-V extensions call extensions
diff --git a/model/riscv_fetch_rvfi.sail b/model/riscv_fetch_rvfi.sail
index b036c1b..d252375 100644
--- a/model/riscv_fetch_rvfi.sail
+++ b/model/riscv_fetch_rvfi.sail
@@ -1,78 +1,16 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
function fetch() -> FetchResult = {
- rvfi_inst_data->rvfi_order() = minstret;
- rvfi_pc_data->rvfi_pc_rdata() = zero_extend(get_arch_pc());
- rvfi_inst_data->rvfi_mode() = zero_extend(privLevel_to_bits(cur_privilege));
- rvfi_inst_data->rvfi_ixl() = zero_extend(misa.MXL());
+ rvfi_inst_data[rvfi_order] = minstret;
+ rvfi_pc_data[rvfi_pc_rdata] = zero_extend(get_arch_pc());
+ rvfi_inst_data[rvfi_mode] = zero_extend(privLevel_to_bits(cur_privilege));
+ rvfi_inst_data[rvfi_ixl] = zero_extend(misa[MXL]);
/* First allow extensions to check pc */
match ext_fetch_check_pc(PC, PC) {
@@ -84,7 +22,7 @@ function fetch() -> FetchResult = {
else match translateAddr(use_pc, Execute()) {
TR_Failure(e, _) => F_Error(e, PC),
TR_Address(_, _) => {
- let i = rvfi_instruction.rvfi_insn();
+ let i = rvfi_instruction[rvfi_insn];
rvfi_inst_data->rvfi_insn() = zero_extend(i);
if (i[1 .. 0] != 0b11)
then F_RVC(i[15 .. 0])
diff --git a/model/riscv_flen_D.sail b/model/riscv_flen_D.sail
index 4c924b5..0edfa77 100644
--- a/model/riscv_flen_D.sail
+++ b/model/riscv_flen_D.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Define the FLEN value for the 'D' extension. */
diff --git a/model/riscv_flen_F.sail b/model/riscv_flen_F.sail
index 358e14b..c104936 100644
--- a/model/riscv_flen_F.sail
+++ b/model/riscv_flen_F.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Define the FLEN value for the 'F' extension. */
diff --git a/model/riscv_freg_type.sail b/model/riscv_freg_type.sail
index fc41f63..a084c0f 100644
--- a/model/riscv_freg_type.sail
+++ b/model/riscv_freg_type.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Definitions for floating point registers (F and D extensions) */
diff --git a/model/riscv_insts_aext.sail b/model/riscv_insts_aext.sail
index ff7dc74..0f4da83 100644
--- a/model/riscv_insts_aext.sail
+++ b/model/riscv_insts_aext.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ****************************************************************** */
@@ -106,7 +44,7 @@ function amo_width_valid(size : word_width) -> bool = {
union clause ast = LOADRES : (bool, bool, regidx, word_width, regidx)
mapping clause encdec = LOADRES(aq, rl, rs1, size, rd) if amo_width_valid(size)
- <-> 0b00010 @ bool_bits(aq) @ bool_bits(rl) @ 0b00000 @ rs1 @ 0b0 @ size_bits(size) @ rd @ 0b0101111 if amo_width_valid(size)
+ <-> 0b00010 @ bool_bits(aq) @ bool_bits(rl) @ 0b00000 @ rs1 @ 0b0 @ size_enc(size) @ rd @ 0b0101111 if amo_width_valid(size)
/* We could set load-reservations on physical or virtual addresses.
@@ -165,13 +103,13 @@ function clause execute(LOADRES(aq, rl, rs1, width, rd)) = {
}
mapping clause assembly = LOADRES(aq, rl, rs1, size, rd)
- <-> "lr." ^ size_mnemonic(size) ^ maybe_aq(aq) ^ maybe_rl(rl) ^ spc() ^ reg_name(rd) ^ sep() ^ reg_name(rs1)
+ <-> "lr." ^ size_mnemonic(size) ^ maybe_aq(aq) ^ maybe_rl(rl) ^ spc() ^ reg_name(rd) ^ sep() ^ "(" ^ reg_name(rs1) ^ ")"
/* ****************************************************************** */
union clause ast = STORECON : (bool, bool, regidx, regidx, word_width, regidx)
mapping clause encdec = STORECON(aq, rl, rs2, rs1, size, rd) if amo_width_valid(size)
- <-> 0b00011 @ bool_bits(aq) @ bool_bits(rl) @ rs2 @ rs1 @ 0b0 @ size_bits(size) @ rd @ 0b0101111 if amo_width_valid(size)
+ <-> 0b00011 @ bool_bits(aq) @ bool_bits(rl) @ rs2 @ rs1 @ 0b0 @ size_enc(size) @ rd @ 0b0101111 if amo_width_valid(size)
/* NOTE: Currently, we only EA if address translation is successful. This may need revisiting. */
function clause execute (STORECON(aq, rl, rs2, rs1, width, rd)) = {
@@ -251,7 +189,7 @@ function clause execute (STORECON(aq, rl, rs2, rs1, width, rd)) = {
}
mapping clause assembly = STORECON(aq, rl, rs2, rs1, size, rd)
- <-> "sc." ^ size_mnemonic(size) ^ maybe_aq(aq) ^ maybe_rl(rl) ^ spc() ^ reg_name(rd) ^ sep() ^ reg_name(rs1) ^ sep() ^ reg_name(rs2)
+ <-> "sc." ^ size_mnemonic(size) ^ maybe_aq(aq) ^ maybe_rl(rl) ^ spc() ^ reg_name(rd) ^ sep() ^ reg_name(rs2) ^ sep() ^ "(" ^ reg_name(rs1) ^ ")"
/* ****************************************************************** */
union clause ast = AMO : (amoop, bool, bool, regidx, regidx, word_width, regidx)
@@ -269,7 +207,7 @@ mapping encdec_amoop : amoop <-> bits(5) = {
}
mapping clause encdec = AMO(op, aq, rl, rs2, rs1, size, rd) if amo_width_valid(size)
- <-> encdec_amoop(op) @ bool_bits(aq) @ bool_bits(rl) @ rs2 @ rs1 @ 0b0 @ size_bits(size) @ rd @ 0b0101111 if amo_width_valid(size)
+ <-> encdec_amoop(op) @ bool_bits(aq) @ bool_bits(rl) @ rs2 @ rs1 @ 0b0 @ size_enc(size) @ rd @ 0b0101111 if amo_width_valid(size)
/* NOTE: Currently, we only EA if address translation is successful.
This may need revisiting. */
diff --git a/model/riscv_insts_base.sail b/model/riscv_insts_base.sail
index 30e886a..9c4630b 100644
--- a/model/riscv_insts_base.sail
+++ b/model/riscv_insts_base.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ****************************************************************** */
@@ -154,7 +92,7 @@ mapping clause encdec = RISCV_JALR(imm, rs1, rd)
<-> imm @ rs1 @ 0b000 @ rd @ 0b1100111
mapping clause assembly = RISCV_JALR(imm, rs1, rd)
- <-> "jalr" ^ spc() ^ reg_name(rd) ^ sep() ^ reg_name(rs1) ^ sep() ^ hex_bits_12(imm)
+ <-> "jalr" ^ spc() ^ reg_name(rd) ^ sep() ^ hex_bits_12(imm) ^ "(" ^ reg_name(rs1) ^ ")"
/* see riscv_jalr_seq.sail or riscv_jalr_rmem.sail for the execute clause. */
@@ -359,8 +297,8 @@ union clause ast = LOAD : (bits(12), regidx, regidx, bool, word_width, bool, boo
/* unsigned loads are only present for widths strictly less than xlen,
signed loads also present for widths equal to xlen */
-mapping clause encdec = LOAD(imm, rs1, rd, is_unsigned, size, false, false) if (word_width_bytes(size) < sizeof(xlen_bytes)) | (not(is_unsigned) & word_width_bytes(size) <= sizeof(xlen_bytes))
- <-> imm @ rs1 @ bool_bits(is_unsigned) @ size_bits(size) @ rd @ 0b0000011 if (word_width_bytes(size) < sizeof(xlen_bytes)) | (not(is_unsigned) & word_width_bytes(size) <= sizeof(xlen_bytes))
+mapping clause encdec = LOAD(imm, rs1, rd, is_unsigned, size, false, false) if (size_bytes(size) < sizeof(xlen_bytes)) | (not(is_unsigned) & size_bytes(size) <= sizeof(xlen_bytes))
+ <-> imm @ rs1 @ bool_bits(is_unsigned) @ size_enc(size) @ rd @ 0b0000011 if (size_bytes(size) < sizeof(xlen_bytes)) | (not(is_unsigned) & size_bytes(size) <= sizeof(xlen_bytes))
val extend_value : forall 'n, 0 < 'n <= xlen_bytes. (bool, MemoryOpResult(bits(8 * 'n))) -> MemoryOpResult(xlenbits)
function extend_value(is_unsigned, value) = match (value) {
@@ -430,13 +368,13 @@ mapping maybe_u = {
}
mapping clause assembly = LOAD(imm, rs1, rd, is_unsigned, size, aq, rl)
- <-> "l" ^ size_mnemonic(size) ^ maybe_u(is_unsigned) ^ maybe_aq(aq) ^ maybe_rl(rl) ^ spc() ^ reg_name(rd) ^ sep() ^ hex_bits_12(imm) ^ opt_spc() ^ "(" ^ opt_spc() ^ reg_name(rs1) ^ opt_spc() ^ ")"
+ <-> "l" ^ size_mnemonic(size) ^ maybe_u(is_unsigned) ^ maybe_aq(aq) ^ maybe_rl(rl) ^ spc() ^ reg_name(rd) ^ sep() ^ hex_bits_12(imm) ^ "(" ^ reg_name(rs1) ^ ")"
/* ****************************************************************** */
union clause ast = STORE : (bits(12), regidx, regidx, word_width, bool, bool)
-mapping clause encdec = STORE(imm7 @ imm5, rs2, rs1, size, false, false) if word_width_bytes(size) <= sizeof(xlen_bytes)
- <-> imm7 : bits(7) @ rs2 @ rs1 @ 0b0 @ size_bits(size) @ imm5 : bits(5) @ 0b0100011 if word_width_bytes(size) <= sizeof(xlen_bytes)
+mapping clause encdec = STORE(imm7 @ imm5, rs2, rs1, size, false, false) if size_bytes(size) <= sizeof(xlen_bytes)
+ <-> imm7 : bits(7) @ rs2 @ rs1 @ 0b0 @ size_enc(size) @ imm5 : bits(5) @ 0b0100011 if size_bytes(size) <= sizeof(xlen_bytes)
/* NOTE: Currently, we only EA if address translation is successful.
This may need revisiting. */
@@ -789,7 +727,7 @@ mapping clause encdec = SRET()
function clause execute SRET() = {
let sret_illegal : bool = match cur_privilege {
User => true,
- Supervisor => not(haveSupMode ()) | mstatus.TSR() == 0b1,
+ Supervisor => not(haveSupMode ()) | mstatus[TSR] == 0b1,
Machine => not(haveSupMode ())
};
if sret_illegal
@@ -826,7 +764,7 @@ mapping clause encdec = WFI()
function clause execute WFI() =
match cur_privilege {
Machine => { platform_wfi(); RETIRE_SUCCESS },
- Supervisor => if mstatus.TW() == 0b1
+ Supervisor => if mstatus[TW] == 0b1
then { handle_illegal(); RETIRE_FAIL }
else { platform_wfi(); RETIRE_SUCCESS },
User => { handle_illegal(); RETIRE_FAIL }
@@ -845,7 +783,7 @@ function clause execute SFENCE_VMA(rs1, rs2) = {
let asid : option(xlenbits) = if rs2 == 0b00000 then None() else Some(X(rs2));
match cur_privilege {
User => { handle_illegal(); RETIRE_FAIL },
- Supervisor => match (architecture(get_mstatus_SXL(mstatus)), mstatus.TVM()) {
+ Supervisor => match (architecture(get_mstatus_SXL(mstatus)), mstatus[TVM]) {
(Some(_), 0b1) => { handle_illegal(); RETIRE_FAIL },
(Some(_), 0b0) => { flush_TLB(asid, addr); RETIRE_SUCCESS },
(_, _) => internal_error(__FILE__, __LINE__, "unimplemented sfence architecture")
diff --git a/model/riscv_insts_begin.sail b/model/riscv_insts_begin.sail
index dd7865f..4287535 100644
--- a/model/riscv_insts_begin.sail
+++ b/model/riscv_insts_begin.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Instruction definitions.
diff --git a/model/riscv_insts_cdext.sail b/model/riscv_insts_cdext.sail
index 8851e34..aeda8fc 100644
--- a/model/riscv_insts_cdext.sail
+++ b/model/riscv_insts_cdext.sail
@@ -1,77 +1,15 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ********************************************************************* */
/* This file specifies the compressed floating-point instructions.
*
- * These instructions are only legal if misa.C() and misa.D()
+ * These instructions are only legal if misa[C] and misa[D]
* are set.
*/
diff --git a/model/riscv_insts_cext.sail b/model/riscv_insts_cext.sail
index f9f49d3..2cf3b41 100644
--- a/model/riscv_insts_cext.sail
+++ b/model/riscv_insts_cext.sail
@@ -1,77 +1,15 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ********************************************************************* */
/* This file specifies the compressed instructions in the 'C' extension. */
-/* These instructions are only legal if misa.C() is true. Instead of
+/* These instructions are only legal if misa[C] is true. Instead of
* checking this in every execute clause, we currently do the check in one place
* in the fetch-execute logic.
*/
@@ -286,9 +224,9 @@ mapping clause assembly = C_LUI(imm, rd)
union clause ast = C_SRLI : (bits(6), cregidx)
mapping clause encdec_compressed = C_SRLI(nzui5 @ nzui40, rsd)
- if nzui5 @ nzui40 != 0b000000
+ if nzui5 @ nzui40 != 0b000000 & (sizeof(xlen) == 64 | nzui5 == 0b0)
<-> 0b100 @ nzui5 : bits(1) @ 0b00 @ rsd : cregidx @ nzui40 : bits(5) @ 0b01
- if nzui5 @ nzui40 != 0b000000
+ if nzui5 @ nzui40 != 0b000000 & (sizeof(xlen) == 64 | nzui5 == 0b0)
function clause execute (C_SRLI(shamt, rsd)) = {
let rsd = creg2reg_idx(rsd);
@@ -304,9 +242,9 @@ mapping clause assembly = C_SRLI(shamt, rsd)
union clause ast = C_SRAI : (bits(6), cregidx)
mapping clause encdec_compressed = C_SRAI(nzui5 @ nzui40, rsd)
- if nzui5 @ nzui40 != 0b000000
+ if nzui5 @ nzui40 != 0b000000 & (sizeof(xlen) == 64 | nzui5 == 0b0)
<-> 0b100 @ nzui5 : bits(1) @ 0b01 @ rsd : cregidx @ nzui40 : bits(5) @ 0b01
- if nzui5 @ nzui40 != 0b000000
+ if nzui5 @ nzui40 != 0b000000 & (sizeof(xlen) == 64 | nzui5 == 0b0)
function clause execute (C_SRAI(shamt, rsd)) = {
let rsd = creg2reg_idx(rsd);
@@ -529,8 +467,8 @@ function clause execute (C_SWSP(uimm, rs2)) = {
execute(STORE(imm, rs2, sp, WORD, false, false))
}
-mapping clause assembly = C_SWSP(uimm, rd)
- <-> "c.swsp" ^ spc() ^ reg_name(rd) ^ sep() ^ hex_bits_6(uimm)
+mapping clause assembly = C_SWSP(uimm, rs2)
+ <-> "c.swsp" ^ spc() ^ reg_name(rs2) ^ sep() ^ hex_bits_6(uimm)
/* ****************************************************************** */
union clause ast = C_SDSP : (bits(6), regidx)
diff --git a/model/riscv_insts_cfext.sail b/model/riscv_insts_cfext.sail
index 632495e..71b1e0b 100644
--- a/model/riscv_insts_cfext.sail
+++ b/model/riscv_insts_cfext.sail
@@ -1,77 +1,15 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ********************************************************************* */
/* This file specifies the compressed floating-point instructions.
*
- * These instructions are only legal if misa.C() and misa.F()
+ * These instructions are only legal if misa[C] and misa[F]
* are set.
*/
@@ -106,9 +44,9 @@ function clause execute (C_FSWSP(uimm, rs2)) = {
execute(STORE_FP(imm, rs2, sp, WORD))
}
-mapping clause assembly = C_FSWSP(uimm, rd)
+mapping clause assembly = C_FSWSP(uimm, rs2)
if sizeof(xlen) == 32
- <-> "c.fswsp" ^ spc() ^ reg_name(rd) ^ sep() ^ hex_bits_6(uimm)
+ <-> "c.fswsp" ^ spc() ^ reg_name(rs2) ^ sep() ^ hex_bits_6(uimm)
if sizeof(xlen) == 32
/* ****************************************************************** */
diff --git a/model/riscv_insts_dext.sail b/model/riscv_insts_dext.sail
index 573549a..58c5d5d 100644
--- a/model/riscv_insts_dext.sail
+++ b/model/riscv_insts_dext.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* **************************************************************** */
diff --git a/model/riscv_insts_end.sail b/model/riscv_insts_end.sail
index 6a1af88..d6a328d 100644
--- a/model/riscv_insts_end.sail
+++ b/model/riscv_insts_end.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Put the illegal instructions last to use their wildcard match. */
diff --git a/model/riscv_insts_fext.sail b/model/riscv_insts_fext.sail
index e0ea551..e4afb30 100644
--- a/model/riscv_insts_fext.sail
+++ b/model/riscv_insts_fext.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* **************************************************************** */
@@ -112,7 +50,7 @@ val select_instr_or_fcsr_rm : rounding_mode -> option(rounding_mode)
function select_instr_or_fcsr_rm instr_rm =
if (instr_rm == RM_DYN)
then {
- let fcsr_rm = fcsr.FRM();
+ let fcsr_rm = fcsr[FRM];
if (valid_rounding_mode(fcsr_rm) & fcsr_rm != encdec_rounding_mode(RM_DYN))
then Some(encdec_rounding_mode(fcsr_rm)) else None()
}
diff --git a/model/riscv_insts_hints.sail b/model/riscv_insts_hints.sail
index bc803fa..ceddcf2 100644
--- a/model/riscv_insts_hints.sail
+++ b/model/riscv_insts_hints.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ****************************************************************** */
diff --git a/model/riscv_insts_mext.sail b/model/riscv_insts_mext.sail
index 7cee337..c1da229 100644
--- a/model/riscv_insts_mext.sail
+++ b/model/riscv_insts_mext.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ****************************************************************** */
diff --git a/model/riscv_insts_next.sail b/model/riscv_insts_next.sail
index 584f1cc..dd9197a 100644
--- a/model/riscv_insts_next.sail
+++ b/model/riscv_insts_next.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* *****************************************************************/
diff --git a/model/riscv_insts_rmem.sail b/model/riscv_insts_rmem.sail
index 230a347..fb38446 100644
--- a/model/riscv_insts_rmem.sail
+++ b/model/riscv_insts_rmem.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ******************************************************************* */
diff --git a/model/riscv_insts_vext_arith.sail b/model/riscv_insts_vext_arith.sail
index 3183bb0..6104e7e 100644
--- a/model/riscv_insts_vext_arith.sail
+++ b/model/riscv_insts_vext_arith.sail
@@ -1,40 +1,10 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
/* ******************************************************************************* */
/* This file implements part of the vector extension. */
diff --git a/model/riscv_insts_vext_fp.sail b/model/riscv_insts_vext_fp.sail
index 05f36fd..0b36b01 100755
--- a/model/riscv_insts_vext_fp.sail
+++ b/model/riscv_insts_vext_fp.sail
@@ -1,40 +1,10 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
/* ******************************************************************************* */
/* This file implements part of the vector extension. */
@@ -61,7 +31,7 @@ mapping clause encdec = FVVTYPE(funct6, vm, vs2, vs1, vd) if haveVExt()
<-> encdec_fvvfunct6(funct6) @ vm @ vs2 @ vs1 @ 0b001 @ vd @ 0b1010111 if haveVExt()
function clause execute(FVVTYPE(funct6, vm, vs2, vs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -136,7 +106,7 @@ mapping clause encdec = FVVMATYPE(funct6, vm, vs2, vs1, vd) if haveVExt()
<-> encdec_fvvmafunct6(funct6) @ vm @ vs2 @ vs1 @ 0b001 @ vd @ 0b1010111 if haveVExt()
function clause execute(FVVMATYPE(funct6, vm, vs2, vs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -203,7 +173,7 @@ mapping clause encdec = FWVVTYPE(funct6, vm, vs2, vs1, vd) if haveVExt()
<-> encdec_fwvvfunct6(funct6) @ vm @ vs2 @ vs1 @ 0b001 @ vd @ 0b1010111 if haveVExt()
function clause execute(FWVVTYPE(funct6, vm, vs2, vs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -268,7 +238,7 @@ mapping clause encdec = FWVVMATYPE(funct6, vm, vs1, vs2, vd) if haveVExt()
<-> encdec_fwvvmafunct6(funct6) @ vm @ vs1 @ vs2 @ 0b001 @ vd @ 0b1010111 if haveVExt()
function clause execute(FWVVMATYPE(funct6, vm, vs1, vs2, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -332,7 +302,7 @@ mapping clause encdec = FWVTYPE(funct6, vm, vs2, vs1, vd) if haveVExt()
<-> encdec_fwvfunct6(funct6) @ vm @ vs2 @ vs1 @ 0b001 @ vd @ 0b1010111 if haveVExt()
function clause execute(FWVTYPE(funct6, vm, vs2, vs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -395,12 +365,13 @@ mapping clause encdec = VFUNARY0(vm, vs2, vfunary0, vd) if haveVExt()
<-> 0b010010 @ vm @ vs2 @ encdec_vfunary0_vs1(vfunary0) @ 0b001 @ vd @ 0b1010111 if haveVExt()
function clause execute(VFUNARY0(vm, vs2, vfunary0, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
if illegal_fp_normal(vd, vm, SEW, rm_3b) then { handle_illegal(); return RETIRE_FAIL };
+ assert(SEW != 8);
let 'n = num_elem;
let 'm = SEW;
@@ -508,7 +479,7 @@ mapping clause encdec = VFWUNARY0(vm, vs2, vfwunary0, vd) if haveVExt()
<-> 0b010010 @ vm @ vs2 @ encdec_vfwunary0_vs1(vfwunary0) @ 0b001 @ vd @ 0b1010111 if haveVExt()
function clause execute(VFWUNARY0(vm, vs2, vfwunary0, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -638,7 +609,7 @@ mapping clause encdec = VFNUNARY0(vm, vs2, vfnunary0, vd) if haveVExt()
<-> 0b010010 @ vm @ vs2 @ encdec_vfnunary0_vs1(vfnunary0) @ 0b001 @ vd @ 0b1010111 if haveVExt()
function clause execute(VFNUNARY0(vm, vs2, vfnunary0, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -648,6 +619,7 @@ function clause execute(VFNUNARY0(vm, vs2, vfnunary0, vd)) = {
if illegal_fp_variable_width(vd, vm, SEW, rm_3b, SEW_widen, LMUL_pow_widen) |
not(valid_reg_overlap(vs2, vd, LMUL_pow_widen, LMUL_pow))
then { handle_illegal(); return RETIRE_FAIL };
+ assert(SEW != 64);
let 'n = num_elem;
let 'm = SEW;
@@ -773,7 +745,7 @@ mapping clause encdec = VFUNARY1(vm, vs2, vfunary1, vd) if haveVExt()
<-> 0b010011 @ vm @ vs2 @ encdec_vfunary1_vs1(vfunary1) @ 0b001 @ vd @ 0b1010111 if haveVExt()
function clause execute(VFUNARY1(vm, vs2, vfunary1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -849,7 +821,7 @@ mapping clause encdec = VFMVFS(vs2, rd) if haveVExt()
<-> 0b010000 @ 0b1 @ vs2 @ 0b00000 @ 0b001 @ rd @ 0b1010111 if haveVExt()
function clause execute(VFMVFS(vs2, rd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let num_elem = get_num_elem(0, SEW);
@@ -897,7 +869,7 @@ mapping clause encdec = FVFTYPE(funct6, vm, vs2, rs1, vd) if haveVExt()
<-> encdec_fvffunct6(funct6) @ vm @ vs2 @ rs1 @ 0b101 @ vd @ 0b1010111 if haveVExt()
function clause execute(FVFTYPE(funct6, vm, vs2, rs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -987,7 +959,7 @@ mapping clause encdec = FVFMATYPE(funct6, vm, vs2, rs1, vd) if haveVExt()
<-> encdec_fvfmafunct6(funct6) @ vm @ vs2 @ rs1 @ 0b101 @ vd @ 0b1010111 if haveVExt()
function clause execute(FVFMATYPE(funct6, vm, vs2, rs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -1054,7 +1026,7 @@ mapping clause encdec = FWVFTYPE(funct6, vm, vs2, rs1, vd) if haveVExt()
<-> encdec_fwvffunct6(funct6) @ vm @ vs2 @ rs1 @ 0b101 @ vd @ 0b1010111 if haveVExt()
function clause execute(FWVFTYPE(funct6, vm, vs2, rs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -1118,7 +1090,7 @@ mapping clause encdec = FWVFMATYPE(funct6, vm, rs1, vs2, vd) if haveVExt()
<-> encdec_fwvfmafunct6(funct6) @ vm @ vs2 @ rs1 @ 0b101 @ vd @ 0b1010111 if haveVExt()
function clause execute(FWVFMATYPE(funct6, vm, rs1, vs2, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -1181,7 +1153,7 @@ mapping clause encdec = FWFTYPE(funct6, vm, vs2, rs1, vd) if haveVExt()
<-> encdec_fwffunct6(funct6) @ vm @ vs2 @ rs1 @ 0b101 @ vd @ 0b1010111 if haveVExt()
function clause execute(FWFTYPE(funct6, vm, vs2, rs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -1235,7 +1207,7 @@ mapping clause encdec = VFMERGE(vs2, rs1, vd) if haveVExt()
<-> 0b010111 @ 0b0 @ vs2 @ rs1 @ 0b101 @ vd @ 0b1010111 if haveVExt()
function clause execute(VFMERGE(vs2, rs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let start_element = get_start_element();
let end_element = get_end_element();
let SEW = get_sew();
@@ -1286,7 +1258,7 @@ mapping clause encdec = VFMV(rs1, vd) if haveVExt()
<-> 0b010111 @ 0b1 @ 0b00000 @ rs1 @ 0b101 @ vd @ 0b1010111 if haveVExt()
function clause execute(VFMV(rs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -1324,7 +1296,7 @@ mapping clause encdec = VFMVSF(rs1, vd) if haveVExt()
<-> 0b010000 @ 0b1 @ 0b00000 @ rs1 @ 0b101 @ vd @ 0b1010111 if haveVExt()
function clause execute(VFMVSF(rs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let num_elem = get_num_elem(0, SEW);
diff --git a/model/riscv_insts_vext_mask.sail b/model/riscv_insts_vext_mask.sail
index bb4594f..6528882 100755
--- a/model/riscv_insts_vext_mask.sail
+++ b/model/riscv_insts_vext_mask.sail
@@ -1,40 +1,10 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
/* ******************************************************************************* */
/* This file implements part of the vector extension. */
diff --git a/model/riscv_insts_vext_mem.sail b/model/riscv_insts_vext_mem.sail
index 292d98f..ce9cd62 100644
--- a/model/riscv_insts_vext_mem.sail
+++ b/model/riscv_insts_vext_mem.sail
@@ -1,47 +1,17 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
/* ******************************************************************************* */
/* This file implements part of the vector extension. */
/* Chapter 7: Vector Loads and Stores */
/* ******************************************************************************* */
-mapping nfields_int : bits(3) <-> {|1, 2, 3, 4, 5, 6, 7, 8|} = {
+mapping nfields_int : bits(3) <-> {1, 2, 3, 4, 5, 6, 7, 8} = {
0b000 <-> 1,
0b001 <-> 2,
0b010 <-> 3,
@@ -77,37 +47,30 @@ mapping encdec_vlewidth : vlewidth <-> bits(3) = {
VLE64 <-> 0b111
}
-mapping vlewidth_bytesnumber : vlewidth <-> {|1, 2, 4, 8|} = {
+mapping vlewidth_bytesnumber : vlewidth <-> {1, 2, 4, 8} = {
VLE8 <-> 1,
VLE16 <-> 2,
VLE32 <-> 4,
VLE64 <-> 8
}
-mapping vlewidth_pow : vlewidth <-> {|3, 4, 5, 6|} = {
+mapping vlewidth_pow : vlewidth <-> {3, 4, 5, 6} = {
VLE8 <-> 3,
VLE16 <-> 4,
VLE32 <-> 5,
VLE64 <-> 6
}
-mapping bytes_wordwidth : {|1, 2, 4, 8|} <-> word_width = {
- 1 <-> BYTE,
- 2 <-> HALF,
- 4 <-> WORD,
- 8 <-> DOUBLE
-}
-
/* ******************** Vector Load Unit-Stride Normal & Segment (mop=0b00, lumop=0b00000) ********************* */
union clause ast = VLSEGTYPE : (bits(3), bits(1), regidx, vlewidth, regidx)
mapping clause encdec = VLSEGTYPE(nf, vm, rs1, width, vd) if haveVExt()
<-> nf @ 0b0 @ 0b00 @ vm @ 0b00000 @ rs1 @ encdec_vlewidth(width) @ vd @ 0b0000111 if haveVExt()
-val process_vlseg : forall 'f 'b 'n 'p, (0 < 'f & 'f <= 8) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('b), regidx, int('p), int('n)) -> Retired effect {escape, rmem, rmemt, rreg, undef, wmv, wmvt, wreg}
+val process_vlseg : forall 'f 'b 'n 'p, (0 < 'f & 'f <= 8) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('b), regidx, int('p), int('n)) -> Retired
function process_vlseg (nf, vm, vd, load_width_bytes, rs1, EMUL_pow, num_elem) = {
let EMUL_reg : int = if EMUL_pow <= 0 then 1 else int_power(2, EMUL_pow);
- let width_type : word_width = bytes_wordwidth(load_width_bytes);
+ let width_type : word_width = size_bytes(load_width_bytes);
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vd_seg : vector('n, dec, bits('f * 'b * 8)) = read_vreg_seg(num_elem, load_width_bytes * 8, EMUL_pow, nf, vd);
@@ -170,10 +133,10 @@ union clause ast = VLSEGFFTYPE : (bits(3), bits(1), regidx, vlewidth, regidx)
mapping clause encdec = VLSEGFFTYPE(nf, vm, rs1, width, vd) if haveVExt()
<-> nf @ 0b0 @ 0b00 @ vm @ 0b10000 @ rs1 @ encdec_vlewidth(width) @ vd @ 0b0000111 if haveVExt()
-val process_vlsegff : forall 'f 'b 'n 'p, (0 < 'f & 'f <= 8) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('b), regidx, int('p), int('n)) -> Retired effect {escape, rmem, rmemt, rreg, undef, wmv, wmvt, wreg}
+val process_vlsegff : forall 'f 'b 'n 'p, (0 < 'f & 'f <= 8) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('b), regidx, int('p), int('n)) -> Retired
function process_vlsegff (nf, vm, vd, load_width_bytes, rs1, EMUL_pow, num_elem) = {
let EMUL_reg : int = if EMUL_pow <= 0 then 1 else int_power(2, EMUL_pow);
- let width_type : word_width = bytes_wordwidth(load_width_bytes);
+ let width_type : word_width = size_bytes(load_width_bytes);
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vd_seg : vector('n, dec, bits('f * 'b * 8)) = read_vreg_seg(num_elem, load_width_bytes * 8, EMUL_pow, nf, vd);
let tail_ag : agtype = get_vtype_vta();
@@ -275,10 +238,10 @@ union clause ast = VSSEGTYPE : (bits(3), bits(1), regidx, vlewidth, regidx)
mapping clause encdec = VSSEGTYPE(nf, vm, rs1, width, vs3) if haveVExt()
<-> nf @ 0b0 @ 0b00 @ vm @ 0b00000 @ rs1 @ encdec_vlewidth(width) @ vs3 @ 0b0100111 if haveVExt()
-val process_vsseg : forall 'f 'b 'n 'p, (0 < 'f & 'f <= 8) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('b), regidx, int('p), int('n)) -> Retired effect {eamem, escape, rmem, rmemt, rreg, undef, wmv, wmvt, wreg}
+val process_vsseg : forall 'f 'b 'n 'p, (0 < 'f & 'f <= 8) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('b), regidx, int('p), int('n)) -> Retired
function process_vsseg (nf, vm, vs3, load_width_bytes, rs1, EMUL_pow, num_elem) = {
let EMUL_reg : int = if EMUL_pow <= 0 then 1 else int_power(2, EMUL_pow);
- let width_type : word_width = bytes_wordwidth(load_width_bytes);
+ let width_type : word_width = size_bytes(load_width_bytes);
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs3_seg : vector('n, dec, bits('f * 'b * 8)) = read_vreg_seg(num_elem, load_width_bytes * 8, EMUL_pow, nf, vs3);
let mask : vector('n, dec, bool) = init_masked_source(num_elem, EMUL_pow, vm_val);
@@ -344,10 +307,10 @@ union clause ast = VLSSEGTYPE : (bits(3), bits(1), regidx, regidx, vlewidth, reg
mapping clause encdec = VLSSEGTYPE(nf, vm, rs2, rs1, width, vd) if haveVExt()
<-> nf @ 0b0 @ 0b10 @ vm @ rs2 @ rs1 @ encdec_vlewidth(width) @ vd @ 0b0000111 if haveVExt()
-val process_vlsseg : forall 'f 'b 'n 'p, (0 < 'f & 'f <= 8) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('b), regidx, regidx, int('p), int('n)) -> Retired effect {escape, rmem, rmemt, rreg, undef, wmv, wmvt, wreg}
+val process_vlsseg : forall 'f 'b 'n 'p, (0 < 'f & 'f <= 8) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('b), regidx, regidx, int('p), int('n)) -> Retired
function process_vlsseg (nf, vm, vd, load_width_bytes, rs1, rs2, EMUL_pow, num_elem) = {
let EMUL_reg : int = if EMUL_pow <= 0 then 1 else int_power(2, EMUL_pow);
- let width_type : word_width = bytes_wordwidth(load_width_bytes);
+ let width_type : word_width = size_bytes(load_width_bytes);
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vd_seg : vector('n, dec, bits('f * 'b * 8)) = read_vreg_seg(num_elem, load_width_bytes * 8, EMUL_pow, nf, vd);
let rs2_val : int = signed(get_scalar(rs2, sizeof(xlen)));
@@ -411,10 +374,10 @@ union clause ast = VSSSEGTYPE : (bits(3), bits(1), regidx, regidx, vlewidth, reg
mapping clause encdec = VSSSEGTYPE(nf, vm, rs2, rs1, width, vs3) if haveVExt()
<-> nf @ 0b0 @ 0b10 @ vm @ rs2 @ rs1 @ encdec_vlewidth(width) @ vs3 @ 0b0100111 if haveVExt()
-val process_vssseg : forall 'f 'b 'n 'p, (0 < 'f & 'f <= 8) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('b), regidx, regidx, int('p), int('n)) -> Retired effect {eamem, escape, rmem, rmemt, rreg, undef, wmv, wmvt, wreg}
+val process_vssseg : forall 'f 'b 'n 'p, (0 < 'f & 'f <= 8) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('b), regidx, regidx, int('p), int('n)) -> Retired
function process_vssseg (nf, vm, vs3, load_width_bytes, rs1, rs2, EMUL_pow, num_elem) = {
let EMUL_reg : int = if EMUL_pow <= 0 then 1 else int_power(2, EMUL_pow);
- let width_type : word_width = bytes_wordwidth(load_width_bytes);
+ let width_type : word_width = size_bytes(load_width_bytes);
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs3_seg : vector('n, dec, bits('f * 'b * 8)) = read_vreg_seg(num_elem, load_width_bytes * 8, EMUL_pow, nf, vs3);
let rs2_val : int = signed(get_scalar(rs2, sizeof(xlen)));
@@ -481,10 +444,10 @@ union clause ast = VLUXSEGTYPE : (bits(3), bits(1), regidx, regidx, vlewidth, re
mapping clause encdec = VLUXSEGTYPE(nf, vm, vs2, rs1, width, vd) if haveVExt()
<-> nf @ 0b0 @ 0b01 @ vm @ vs2 @ rs1 @ encdec_vlewidth(width) @ vd @ 0b0000111 if haveVExt()
-val process_vlxseg : forall 'f 'ib 'db 'ip 'dp 'n, (0 < 'f & 'f <= 8) & ('ib in {1, 2, 4, 8}) & ('db in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('ib), int('db), int('ip), int('dp), regidx, regidx, int('n), int) -> Retired effect {eamem, escape, rmem, rmemt, rreg, undef, wmv, wmvt, wreg}
+val process_vlxseg : forall 'f 'ib 'db 'ip 'dp 'n, (0 < 'f & 'f <= 8) & ('ib in {1, 2, 4, 8}) & ('db in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('ib), int('db), int('ip), int('dp), regidx, regidx, int('n), int) -> Retired
function process_vlxseg (nf, vm, vd, EEW_index_bytes, EEW_data_bytes, EMUL_index_pow, EMUL_data_pow, rs1, vs2, num_elem, mop) = {
let EMUL_data_reg : int = if EMUL_data_pow <= 0 then 1 else int_power(2, EMUL_data_pow);
- let width_type : word_width = bytes_wordwidth(EEW_data_bytes);
+ let width_type : word_width = size_bytes(EEW_data_bytes);
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vd_seg : vector('n, dec, bits('f * 'db * 8)) = read_vreg_seg(num_elem, EEW_data_bytes * 8, EMUL_data_pow, nf, vd);
let vs2_val : vector('n, dec, bits('ib * 8)) = read_vreg(num_elem, EEW_index_bytes * 8, EMUL_index_pow, vs2);
@@ -573,10 +536,10 @@ union clause ast = VSUXSEGTYPE : (bits(3), bits(1), regidx, regidx, vlewidth, re
mapping clause encdec = VSUXSEGTYPE(nf, vm, vs2, rs1, width, vs3) if haveVExt()
<-> nf @ 0b0 @ 0b01 @ vm @ vs2 @ rs1 @ encdec_vlewidth(width) @ vs3 @ 0b0100111 if haveVExt()
-val process_vsxseg : forall 'f 'ib 'db 'ip 'dp 'n, (0 < 'f & 'f <= 8) & ('ib in {1, 2, 4, 8}) & ('db in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('ib), int('db), int('ip), int('dp), regidx, regidx, int('n), int) -> Retired effect {eamem, escape, rmem, rmemt, rreg, undef, wmv, wmvt, wreg}
+val process_vsxseg : forall 'f 'ib 'db 'ip 'dp 'n, (0 < 'f & 'f <= 8) & ('ib in {1, 2, 4, 8}) & ('db in {1, 2, 4, 8}) & ('n >= 0). (int('f), bits(1), regidx, int('ib), int('db), int('ip), int('dp), regidx, regidx, int('n), int) -> Retired
function process_vsxseg (nf, vm, vs3, EEW_index_bytes, EEW_data_bytes, EMUL_index_pow, EMUL_data_pow, rs1, vs2, num_elem, mop) = {
let EMUL_data_reg : int = if EMUL_data_pow <= 0 then 1 else int_power(2, EMUL_data_pow);
- let width_type : word_width = bytes_wordwidth(EEW_data_bytes);
+ let width_type : word_width = size_bytes(EEW_data_bytes);
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs3_seg : vector('n, dec, bits('f * 'db * 8)) = read_vreg_seg(num_elem, EEW_data_bytes * 8, EMUL_data_pow, nf, vs3);
let vs2_val : vector('n, dec, bits('ib * 8)) = read_vreg(num_elem, EEW_index_bytes * 8, EMUL_index_pow, vs2);
@@ -668,9 +631,9 @@ union clause ast = VLRETYPE : (bits(3), regidx, vlewidth, regidx)
mapping clause encdec = VLRETYPE(nf, rs1, width, vd) if haveVExt()
<-> nf @ 0b0 @ 0b00 @ 0b1 @ 0b01000 @ rs1 @ encdec_vlewidth(width) @ vd @ 0b0000111 if haveVExt()
-val process_vlre : forall 'f 'b 'n, ('f in {1, 2, 4, 8}) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), regidx, int('b), regidx, int('n)) -> Retired effect {escape, rmem, rmemt, rreg, undef, wmv, wmvt, wreg}
+val process_vlre : forall 'f 'b 'n, ('f in {1, 2, 4, 8}) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), regidx, int('b), regidx, int('n)) -> Retired
function process_vlre (nf, vd, load_width_bytes, rs1, elem_per_reg) = {
- let width_type : word_width = bytes_wordwidth(load_width_bytes);
+ let width_type : word_width = size_bytes(load_width_bytes);
let start_element = get_start_element();
if start_element >= nf * elem_per_reg then return RETIRE_SUCCESS; /* no elements are written if vstart >= evl */
let elem_to_align : int = start_element % elem_per_reg;
@@ -750,7 +713,7 @@ union clause ast = VSRETYPE : (bits(3), regidx, regidx)
mapping clause encdec = VSRETYPE(nf, rs1, vs3) if haveVExt()
<-> nf @ 0b0 @ 0b00 @ 0b1 @ 0b01000 @ rs1 @ 0b000 @ vs3 @ 0b0100111 if haveVExt()
-val process_vsre : forall 'f 'b 'n, ('f in {1, 2, 4, 8}) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), int('b), regidx, regidx, int('n)) -> Retired effect {eamem, escape, rmem, rmemt, rreg, undef, wmv, wmvt, wreg}
+val process_vsre : forall 'f 'b 'n, ('f in {1, 2, 4, 8}) & ('b in {1, 2, 4, 8}) & ('n >= 0). (int('f), int('b), regidx, regidx, int('n)) -> Retired
function process_vsre (nf, load_width_bytes, rs1, vs3, elem_per_reg) = {
let width_type : word_width = BYTE;
let start_element = get_start_element();
@@ -855,7 +818,7 @@ mapping encdec_lsop : vmlsop <-> bits(7) = {
mapping clause encdec = VMTYPE(rs1, vd_or_vs3, op) if haveVExt()
<-> 0b000 @ 0b0 @ 0b00 @ 0b1 @ 0b01011 @ rs1 @ 0b000 @ vd_or_vs3 @ encdec_lsop(op) if haveVExt()
-val process_vm : forall 'n 'l, ('n >= 0 & 'l >= 0). (regidx, regidx, int('n), int('l), vmlsop) -> Retired effect {eamem, escape, rmem, rmemt, rreg, undef, wmv, wmvt, wreg}
+val process_vm : forall 'n 'l, ('n >= 0 & 'l >= 0). (regidx, regidx, int('n), int('l), vmlsop) -> Retired
function process_vm(vd_or_vs3, rs1, num_elem, evl, op) = {
let width_type : word_width = BYTE;
let start_element = get_start_element();
diff --git a/model/riscv_insts_vext_red.sail b/model/riscv_insts_vext_red.sail
index 6b756f1..358836b 100755
--- a/model/riscv_insts_vext_red.sail
+++ b/model/riscv_insts_vext_red.sail
@@ -1,40 +1,10 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
/* ******************************************************************************* */
/* This file implements part of the vector extension. */
@@ -188,9 +158,9 @@ mapping encdec_rfvvfunct6 : rfvvfunct6 <-> bits(6) = {
mapping clause encdec = RFVVTYPE(funct6, vm, vs2, vs1, vd) if haveVExt()
<-> encdec_rfvvfunct6(funct6) @ vm @ vs2 @ vs1 @ 0b001 @ vd @ 0b1010111 if haveVExt()
-val process_rfvv_single: forall 'n 'm 'p, 'n >= 0 & 'm in {8, 16, 32, 64}. (rfvvfunct6, bits(1), regidx, regidx, regidx, int('n), int('m), int('p)) -> Retired effect {escape, rreg, undef, wreg}
+val process_rfvv_single: forall 'n 'm 'p, 'n >= 0 & 'm in {8, 16, 32, 64}. (rfvvfunct6, bits(1), regidx, regidx, regidx, int('n), int('m), int('p)) -> Retired
function process_rfvv_single(funct6, vm, vs2, vs1, vd, num_elem_vs, SEW, LMUL_pow) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let num_elem_vd = get_num_elem(0, SEW); /* vd regardless of LMUL setting */
if illegal_fp_reduction(SEW, rm_3b) then { handle_illegal(); return RETIRE_FAIL };
@@ -215,7 +185,8 @@ function process_rfvv_single(funct6, vm, vs2, vs1, vd, num_elem_vs, SEW, LMUL_po
FVV_VFREDOSUM => fp_add(rm_3b, sum, vs2_val[i]),
FVV_VFREDUSUM => fp_add(rm_3b, sum, vs2_val[i]),
FVV_VFREDMAX => fp_max(sum, vs2_val[i]),
- FVV_VFREDMIN => fp_min(sum, vs2_val[i])
+ FVV_VFREDMIN => fp_min(sum, vs2_val[i]),
+ _ => internal_error(__FILE__, __LINE__, "Widening op unexpected")
}
}
};
@@ -227,9 +198,9 @@ function process_rfvv_single(funct6, vm, vs2, vs1, vd, num_elem_vs, SEW, LMUL_po
RETIRE_SUCCESS
}
-val process_rfvv_widen: forall 'n 'm 'p, 'n >= 0 & 'm in {8, 16, 32, 64}. (rfvvfunct6, bits(1), regidx, regidx, regidx, int('n), int('m), int('p)) -> Retired effect {escape, rreg, undef, wreg}
+val process_rfvv_widen: forall 'n 'm 'p, 'n >= 0 & 'm in {8, 16, 32, 64}. (rfvvfunct6, bits(1), regidx, regidx, regidx, int('n), int('m), int('p)) -> Retired
function process_rfvv_widen(funct6, vm, vs2, vs1, vd, num_elem_vs, SEW, LMUL_pow) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW_widen = SEW * 2;
let LMUL_pow_widen = LMUL_pow + 1;
let num_elem_vd = get_num_elem(0, SEW_widen); /* vd regardless of LMUL setting */
diff --git a/model/riscv_insts_vext_utils.sail b/model/riscv_insts_vext_utils.sail
index bef5b51..6796060 100755
--- a/model/riscv_insts_vext_utils.sail
+++ b/model/riscv_insts_vext_utils.sail
@@ -1,41 +1,10 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Lei Chen <lei.chen@rioslab.org> */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
/* ******************************************************************************* */
/* This file implements functions used by vector instructions. */
@@ -51,7 +20,7 @@ mapping maybe_vmask : string <-> bits(1) = {
* 1. vector widening/narrowing instructions
* 2. vector load/store instructions
*/
-val valid_eew_emul : (int, int) -> bool effect {rreg}
+val valid_eew_emul : (int, int) -> bool
function valid_eew_emul(EEW, EMUL_pow) = {
let ELEN = int_power(2, get_elen_pow());
EEW >= 8 & EEW <= ELEN & EMUL_pow >= -3 & EMUL_pow <= 3
@@ -61,13 +30,13 @@ function valid_eew_emul(EEW, EMUL_pow) = {
* 1. If the vill bit is set, then any attempt to execute a vector instruction that depends upon vtype will raise an illegal instruction exception.
* 2. vset{i}vl{i} and whole-register loads, stores, and moves do not depend upon vtype.
*/
-val valid_vtype : unit -> bool effect {rreg}
+val valid_vtype : unit -> bool
function valid_vtype() = {
- vtype.vill() == 0b0
+ vtype[vill] == 0b0
}
/* Check for vstart value */
-val assert_vstart : int -> bool effect {rreg}
+val assert_vstart : int -> bool
function assert_vstart(i) = {
unsigned(vstart) == i
}
@@ -76,7 +45,7 @@ function assert_vstart(i) = {
* 1. Valid element width of floating-point numbers
* 2. Valid floating-point rounding mode
*/
-val valid_fp_op : ({|8, 16, 32, 64|}, bits(3)) -> bool
+val valid_fp_op : ({8, 16, 32, 64}, bits(3)) -> bool
function valid_fp_op(SEW, rm_3b) = {
/* 128-bit floating-point values will be supported in future extensions */
let valid_sew = (SEW >= 16 & SEW <= 128);
@@ -177,38 +146,38 @@ function illegal_reduction_widen(SEW_widen, LMUL_pow_widen) = {
}
/* g. Normal check for floating-point instructions */
-val illegal_fp_normal : (regidx, bits(1), {|8, 16, 32, 64|}, bits(3)) -> bool
+val illegal_fp_normal : (regidx, bits(1), {8, 16, 32, 64}, bits(3)) -> bool
function illegal_fp_normal(vd, vm, SEW, rm_3b) = {
not(valid_vtype()) | not(valid_rd_mask(vd, vm)) | not(valid_fp_op(SEW, rm_3b))
}
/* h. Masked check for floating-point instructions encoded with vm = 0 */
-val illegal_fp_vd_masked : (regidx, {|8, 16, 32, 64|}, bits(3)) -> bool
+val illegal_fp_vd_masked : (regidx, {8, 16, 32, 64}, bits(3)) -> bool
function illegal_fp_vd_masked(vd, SEW, rm_3b) = {
not(valid_vtype()) | vd == 0b00000 | not(valid_fp_op(SEW, rm_3b))
}
/* i. Unmasked check for floating-point instructions encoded with vm = 1 */
-val illegal_fp_vd_unmasked : ({|8, 16, 32, 64|}, bits(3)) -> bool
+val illegal_fp_vd_unmasked : ({8, 16, 32, 64}, bits(3)) -> bool
function illegal_fp_vd_unmasked(SEW, rm_3b) = {
not(valid_vtype()) | not(valid_fp_op(SEW, rm_3b))
}
/* j. Variable width check for floating-point widening/narrowing instructions */
-val illegal_fp_variable_width : (regidx, bits(1), {|8, 16, 32, 64|}, bits(3), int, int) -> bool
+val illegal_fp_variable_width : (regidx, bits(1), {8, 16, 32, 64}, bits(3), int, int) -> bool
function illegal_fp_variable_width(vd, vm, SEW, rm_3b, SEW_new, LMUL_pow_new) = {
not(valid_vtype()) | not(valid_rd_mask(vd, vm)) | not(valid_fp_op(SEW, rm_3b)) |
not(valid_eew_emul(SEW_new, LMUL_pow_new))
}
/* k. Normal check for floating-point reduction instructions */
-val illegal_fp_reduction : ({|8, 16, 32, 64|}, bits(3)) -> bool
+val illegal_fp_reduction : ({8, 16, 32, 64}, bits(3)) -> bool
function illegal_fp_reduction(SEW, rm_3b) = {
not(valid_vtype()) | not(assert_vstart(0)) | not(valid_fp_op(SEW, rm_3b))
}
/* l. Variable width check for floating-point widening reduction instructions */
-val illegal_fp_reduction_widen : ({|8, 16, 32, 64|}, bits(3), int, int) -> bool
+val illegal_fp_reduction_widen : ({8, 16, 32, 64}, bits(3), int, int) -> bool
function illegal_fp_reduction_widen(SEW, rm_3b, SEW_widen, LMUL_pow_widen) = {
not(valid_vtype()) | not(assert_vstart(0)) | not(valid_fp_op(SEW, rm_3b)) |
not(valid_eew_emul(SEW_widen, LMUL_pow_widen))
@@ -242,7 +211,7 @@ function illegal_indexed_store(nf, EEW_index, EMUL_pow_index, EMUL_pow_data) = {
}
/* Scalar register shaping */
-val get_scalar : forall 'm, 'm >= 8. (regidx, int('m)) -> bits('m) effect {escape, rreg}
+val get_scalar : forall 'm, 'm >= 8. (regidx, int('m)) -> bits('m)
function get_scalar(rs1, SEW) = {
if SEW <= sizeof(xlen) then {
/* Least significant SEW bits */
@@ -254,7 +223,7 @@ function get_scalar(rs1, SEW) = {
}
/* Get the starting element index from csr vtype */
-val get_start_element : unit -> nat effect {escape, rreg, wreg}
+val get_start_element : unit -> nat
function get_start_element() = {
let start_element = unsigned(vstart);
let VLEN_pow = get_vlen_pow();
@@ -269,7 +238,7 @@ function get_start_element() = {
}
/* Get the ending element index from csr vl */
-val get_end_element : unit -> int effect {escape, rreg, wreg}
+val get_end_element : unit -> int
function get_end_element() = unsigned(vl) - 1
/* Mask handling; creates a pre-masked result vector for vstart, vl, vta/vma, and vm */
@@ -280,7 +249,7 @@ function get_end_element() = unsigned(vl) - 1
* vector2 is a "mask" vector that is true for an element if the corresponding element
* in the result vector should be updated by the calling instruction
*/
-val init_masked_result : forall 'n 'm 'p, 'n >= 0. (int('n), int('m), int('p), vector('n, dec, bits('m)), vector('n, dec, bool)) -> (vector('n, dec, bits('m)), vector('n, dec, bool)) effect {escape, rreg, undef}
+val init_masked_result : forall 'n 'm 'p, 'n >= 0. (int('n), int('m), int('p), vector('n, dec, bits('m)), vector('n, dec, bool)) -> (vector('n, dec, bits('m)), vector('n, dec, bool))
function init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val) = {
let start_element = get_start_element();
let end_element = get_end_element();
@@ -333,7 +302,7 @@ function init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val) = {
* (vs3 for store and vs2 for reduction). There's no destination register to be masked.
* In these cases, this function can be called to simply get the mask vector for vs (without the prepared vd result vector).
*/
-val init_masked_source : forall 'n 'p, 'n >= 0. (int('n), int('p), vector('n, dec, bool)) -> vector('n, dec, bool) effect {escape, rreg, undef}
+val init_masked_source : forall 'n 'p, 'n >= 0. (int('n), int('p), vector('n, dec, bool)) -> vector('n, dec, bool)
function init_masked_source(num_elem, LMUL_pow, vm_val) = {
let start_element = get_start_element();
let end_element = get_end_element();
@@ -367,7 +336,7 @@ function init_masked_source(num_elem, LMUL_pow, vm_val) = {
/* Mask handling for carry functions that use masks as input/output */
/* Only prestart and tail elements are masked in a mask value */
-val init_masked_result_carry : forall 'n 'm 'p, 'n >= 0. (int('n), int('m), int('p), vector('n, dec, bool)) -> (vector('n, dec, bool), vector('n, dec, bool)) effect {escape, rreg, undef}
+val init_masked_result_carry : forall 'n 'm 'p, 'n >= 0. (int('n), int('m), int('p), vector('n, dec, bool)) -> (vector('n, dec, bool), vector('n, dec, bool))
function init_masked_result_carry(num_elem, SEW, LMUL_pow, vd_val) = {
let start_element = get_start_element();
let end_element = get_end_element();
@@ -403,7 +372,7 @@ function init_masked_result_carry(num_elem, SEW, LMUL_pow, vd_val) = {
}
/* Mask handling for cmp functions that use masks as output */
-val init_masked_result_cmp : forall 'n 'm 'p, 'n >= 0. (int('n), int('m), int('p), vector('n, dec, bool), vector('n, dec, bool)) -> (vector('n, dec, bool), vector('n, dec, bool)) effect {escape, rreg, undef}
+val init_masked_result_cmp : forall 'n 'm 'p, 'n >= 0. (int('n), int('m), int('p), vector('n, dec, bool), vector('n, dec, bool)) -> (vector('n, dec, bool), vector('n, dec, bool))
function init_masked_result_cmp(num_elem, SEW, LMUL_pow, vd_val, vm_val) = {
let start_element = get_start_element();
let end_element = get_end_element();
@@ -450,7 +419,7 @@ function init_masked_result_cmp(num_elem, SEW, LMUL_pow, vd_val, vm_val) = {
* Read multiple register groups and concatenate them in parallel
* The whole segments with the same element index are combined together
*/
-val read_vreg_seg : forall 'n 'm 'p 'q, 'n >= 0 & 'q >= 0. (int('n), int('m), int('p), int('q), regidx) -> vector('n, dec, bits('q * 'm)) effect {escape, rreg, undef}
+val read_vreg_seg : forall 'n 'm 'p 'q, 'n >= 0 & 'q >= 0. (int('n), int('m), int('p), int('q), regidx) -> vector('n, dec, bits('q * 'm))
function read_vreg_seg(num_elem, SEW, LMUL_pow, nf, vrid) = {
assert('q * 'm > 0);
let LMUL_reg : int = if LMUL_pow <= 0 then 1 else int_power(2, LMUL_pow);
@@ -579,7 +548,7 @@ function f_is_NaN(xf) = {
}
/* Scalar register shaping for floating point operations */
-val get_scalar_fp : forall 'n, 'n in {16, 32, 64}. (regidx, int('n)) -> bits('n) effect {escape, rreg}
+val get_scalar_fp : forall 'n, 'n in {16, 32, 64}. (regidx, int('n)) -> bits('n)
function get_scalar_fp(rs1, SEW) = {
assert(sizeof(flen) >= SEW, "invalid vector floating-point type width: FLEN < SEW");
match SEW {
@@ -590,7 +559,7 @@ function get_scalar_fp(rs1, SEW) = {
}
/* Shift amounts */
-val get_shift_amount : forall 'n 'm, 0 <= 'n & 'm in {8, 16, 32, 64}. (bits('n), int('m)) -> nat effect {escape}
+val get_shift_amount : forall 'n 'm, 0 <= 'n & 'm in {8, 16, 32, 64}. (bits('n), int('m)) -> nat
function get_shift_amount(bit_val, SEW) = {
let lowlog2bits = log2(SEW);
assert(0 < lowlog2bits & lowlog2bits < 'n);
@@ -598,7 +567,7 @@ function get_shift_amount(bit_val, SEW) = {
}
/* Fixed point rounding increment */
-val get_fixed_rounding_incr : forall ('m 'n : Int), ('m > 0 & 'n >= 0). (bits('m), int('n)) -> bits(1) effect {rreg, undef}
+val get_fixed_rounding_incr : forall ('m 'n : Int), ('m > 0 & 'n >= 0). (bits('m), int('n)) -> bits(1)
function get_fixed_rounding_incr(vec_elem, shift_amount) = {
if shift_amount == 0 then 0b0
else {
@@ -615,7 +584,7 @@ function get_fixed_rounding_incr(vec_elem, shift_amount) = {
}
/* Fixed point unsigned saturation */
-val unsigned_saturation : forall ('m 'n: Int), ('n >= 'm > 1). (int('m), bits('n)) -> bits('m) effect {escape, rreg, undef, wreg}
+val unsigned_saturation : forall ('m 'n: Int), ('n >= 'm > 1). (int('m), bits('n)) -> bits('m)
function unsigned_saturation(len, elem) = {
if unsigned(elem) > unsigned(ones('m)) then {
vxsat = 0b1;
@@ -627,7 +596,7 @@ function unsigned_saturation(len, elem) = {
}
/* Fixed point signed saturation */
-val signed_saturation : forall ('m 'n: Int), ('n >= 'm > 1). (int('m), bits('n)) -> bits('m) effect {escape, rreg, undef, wreg}
+val signed_saturation : forall ('m 'n: Int), ('n >= 'm > 1). (int('m), bits('n)) -> bits('m)
function signed_saturation(len, elem) = {
if signed(elem) > signed(0b0 @ ones('m - 1)) then {
vxsat = 0b1;
@@ -642,8 +611,8 @@ function signed_saturation(len, elem) = {
}
/* Get the floating point rounding mode from csr fcsr */
-val get_fp_rounding_mode : unit -> rounding_mode effect {rreg}
-function get_fp_rounding_mode() = encdec_rounding_mode(fcsr.FRM())
+val get_fp_rounding_mode : unit -> rounding_mode
+function get_fp_rounding_mode() = encdec_rounding_mode(fcsr[FRM])
/* Negate a floating point number */
val negate_fp : forall 'm, 'm in {16, 32, 64}. bits('m) -> bits('m)
@@ -656,7 +625,7 @@ function negate_fp(xf) = {
}
/* Floating point functions using softfloat interface */
-val fp_add: forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m)) -> bits('m) effect {escape, rreg, undef, wreg}
+val fp_add: forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m)) -> bits('m)
function fp_add(rm_3b, op1, op2) = {
let (fflags, result_val) : (bits_fflags, bits('m)) = match 'm {
16 => riscv_f16Add(rm_3b, op1, op2),
@@ -667,7 +636,7 @@ function fp_add(rm_3b, op1, op2) = {
result_val
}
-val fp_sub: forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m)) -> bits('m) effect {escape, rreg, undef, wreg}
+val fp_sub: forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m)) -> bits('m)
function fp_sub(rm_3b, op1, op2) = {
let (fflags, result_val) : (bits_fflags, bits('m)) = match 'm {
16 => riscv_f16Sub(rm_3b, op1, op2),
@@ -678,7 +647,7 @@ function fp_sub(rm_3b, op1, op2) = {
result_val
}
-val fp_min : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bits('m) effect {escape, rreg, undef, wreg}
+val fp_min : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bits('m)
function fp_min(op1, op2) = {
let (fflags, op1_lt_op2) : (bits_fflags, bool) = match 'm {
16 => riscv_f16Lt_quiet(op1, op2),
@@ -697,7 +666,7 @@ function fp_min(op1, op2) = {
result_val
}
-val fp_max : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bits('m) effect {escape, rreg, undef, wreg}
+val fp_max : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bits('m)
function fp_max(op1, op2) = {
let (fflags, op1_lt_op2) : (bits_fflags, bool) = match 'm {
16 => riscv_f16Lt_quiet(op1, op2),
@@ -716,7 +685,7 @@ function fp_max(op1, op2) = {
result_val
}
-val fp_eq : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bool effect {escape, rreg, undef, wreg}
+val fp_eq : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bool
function fp_eq(op1, op2) = {
let (fflags, result_val) : (bits_fflags, bool) = match 'm {
16 => riscv_f16Eq(op1, op2),
@@ -727,7 +696,7 @@ function fp_eq(op1, op2) = {
result_val
}
-val fp_gt : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bool effect {escape, rreg, undef, wreg}
+val fp_gt : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bool
function fp_gt(op1, op2) = {
let (fflags, temp_val) : (bits_fflags, bool) = match 'm {
16 => riscv_f16Le(op1, op2),
@@ -739,7 +708,7 @@ function fp_gt(op1, op2) = {
result_val
}
-val fp_ge : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bool effect {escape, rreg, undef, wreg}
+val fp_ge : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bool
function fp_ge(op1, op2) = {
let (fflags, temp_val) : (bits_fflags, bool) = match 'm {
16 => riscv_f16Lt(op1, op2),
@@ -751,7 +720,7 @@ function fp_ge(op1, op2) = {
result_val
}
-val fp_lt : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bool effect {escape, rreg, undef, wreg}
+val fp_lt : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bool
function fp_lt(op1, op2) = {
let (fflags, result_val) : (bits_fflags, bool) = match 'm {
16 => riscv_f16Lt(op1, op2),
@@ -762,7 +731,7 @@ function fp_lt(op1, op2) = {
result_val
}
-val fp_le : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bool effect {escape, rreg, undef, wreg}
+val fp_le : forall 'm, 'm in {16, 32, 64}. (bits('m), bits('m)) -> bool
function fp_le(op1, op2) = {
let (fflags, result_val) : (bits_fflags, bool) = match 'm {
16 => riscv_f16Le(op1, op2),
@@ -773,7 +742,7 @@ function fp_le(op1, op2) = {
result_val
}
-val fp_mul : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m)) -> bits('m) effect {escape, rreg, undef, wreg}
+val fp_mul : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m)) -> bits('m)
function fp_mul(rm_3b, op1, op2) = {
let (fflags, result_val) : (bits_fflags, bits('m)) = match 'm {
16 => riscv_f16Mul(rm_3b, op1, op2),
@@ -784,7 +753,7 @@ function fp_mul(rm_3b, op1, op2) = {
result_val
}
-val fp_div : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m)) -> bits('m) effect {escape, rreg, undef, wreg}
+val fp_div : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m)) -> bits('m)
function fp_div(rm_3b, op1, op2) = {
let (fflags, result_val) : (bits_fflags, bits('m)) = match 'm {
16 => riscv_f16Div(rm_3b, op1, op2),
@@ -795,7 +764,7 @@ function fp_div(rm_3b, op1, op2) = {
result_val
}
-val fp_muladd : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m), bits('m)) -> bits('m) effect {escape, rreg, undef, wreg}
+val fp_muladd : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m), bits('m)) -> bits('m)
function fp_muladd(rm_3b, op1, op2, opadd) = {
let (fflags, result_val) : (bits_fflags, bits('m)) = match 'm {
16 => riscv_f16MulAdd(rm_3b, op1, op2, opadd),
@@ -806,7 +775,7 @@ function fp_muladd(rm_3b, op1, op2, opadd) = {
result_val
}
-val fp_nmuladd : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m), bits('m)) -> bits('m) effect {escape, rreg, undef, wreg}
+val fp_nmuladd : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m), bits('m)) -> bits('m)
function fp_nmuladd(rm_3b, op1, op2, opadd) = {
let op1 = negate_fp(op1);
let (fflags, result_val) : (bits_fflags, bits('m)) = match 'm {
@@ -818,7 +787,7 @@ function fp_nmuladd(rm_3b, op1, op2, opadd) = {
result_val
}
-val fp_mulsub : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m), bits('m)) -> bits('m) effect {escape, rreg, undef, wreg}
+val fp_mulsub : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m), bits('m)) -> bits('m)
function fp_mulsub(rm_3b, op1, op2, opsub) = {
let opsub = negate_fp(opsub);
let (fflags, result_val) : (bits_fflags, bits('m)) = match 'm {
@@ -830,7 +799,7 @@ function fp_mulsub(rm_3b, op1, op2, opsub) = {
result_val
}
-val fp_nmulsub : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m), bits('m)) -> bits('m) effect {escape, rreg, undef, wreg}
+val fp_nmulsub : forall 'm, 'm in {16, 32, 64}. (bits(3), bits('m), bits('m), bits('m)) -> bits('m)
function fp_nmulsub(rm_3b, op1, op2, opsub) = {
let opsub = negate_fp(opsub);
let op1 = negate_fp(op1);
@@ -861,9 +830,9 @@ function fp_class(xf) = {
zero_extend(result_val_10b)
}
-val fp_widen : forall 'm, 'm in {16, 32}. bits('m) -> bits('m * 2) effect {escape, rreg, undef, wreg}
+val fp_widen : forall 'm, 'm in {16, 32}. bits('m) -> bits('m * 2)
function fp_widen(nval) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let (fflags, wval) : (bits_fflags, bits('m * 2)) = match 'm {
16 => riscv_f16ToF32(rm_3b, nval),
32 => riscv_f32ToF64(rm_3b, nval)
@@ -873,7 +842,7 @@ function fp_widen(nval) = {
}
/* Floating point functions without softfloat support */
-val riscv_f16ToI16 : (bits_rm, bits_H) -> (bits_fflags, bits(16)) effect {rreg}
+val riscv_f16ToI16 : (bits_rm, bits_H) -> (bits_fflags, bits(16))
function riscv_f16ToI16 (rm, v) = {
let (_, sig32) = riscv_f16ToI32(rm, v);
if signed(sig32) > signed(0b0 @ ones(15)) then (nvFlag(), 0b0 @ ones(15))
@@ -881,7 +850,7 @@ function riscv_f16ToI16 (rm, v) = {
else (zeros(5), sig32[15 .. 0]);
}
-val riscv_f16ToI8 : (bits_rm, bits_H) -> (bits_fflags, bits(8)) effect {rreg}
+val riscv_f16ToI8 : (bits_rm, bits_H) -> (bits_fflags, bits(8))
function riscv_f16ToI8 (rm, v) = {
let (_, sig32) = riscv_f16ToI32(rm, v);
if signed(sig32) > signed(0b0 @ ones(7)) then (nvFlag(), 0b0 @ ones(7))
@@ -889,7 +858,7 @@ function riscv_f16ToI8 (rm, v) = {
else (zeros(5), sig32[7 .. 0]);
}
-val riscv_f32ToI16 : (bits_rm, bits_S) -> (bits_fflags, bits(16)) effect {rreg}
+val riscv_f32ToI16 : (bits_rm, bits_S) -> (bits_fflags, bits(16))
function riscv_f32ToI16 (rm, v) = {
let (_, sig32) = riscv_f32ToI32(rm, v);
if signed(sig32) > signed(0b0 @ ones(15)) then (nvFlag(), 0b0 @ ones(15))
@@ -897,21 +866,21 @@ function riscv_f32ToI16 (rm, v) = {
else (zeros(5), sig32[15 .. 0]);
}
-val riscv_f16ToUi16 : (bits_rm, bits_H) -> (bits_fflags, bits(16)) effect {rreg}
+val riscv_f16ToUi16 : (bits_rm, bits_H) -> (bits_fflags, bits(16))
function riscv_f16ToUi16 (rm, v) = {
let (_, sig32) = riscv_f16ToUi32(rm, v);
if unsigned(sig32) > unsigned(ones(16)) then (nvFlag(), ones(16))
else (zeros(5), sig32[15 .. 0]);
}
-val riscv_f16ToUi8 : (bits_rm, bits_H) -> (bits_fflags, bits(8)) effect {rreg}
+val riscv_f16ToUi8 : (bits_rm, bits_H) -> (bits_fflags, bits(8))
function riscv_f16ToUi8 (rm, v) = {
let (_, sig32) = riscv_f16ToUi32(rm, v);
if unsigned(sig32) > unsigned(ones(8)) then (nvFlag(), ones(8))
else (zeros(5), sig32[7 .. 0]);
}
-val riscv_f32ToUi16 : (bits_rm, bits_S) -> (bits_fflags, bits(16)) effect {rreg}
+val riscv_f32ToUi16 : (bits_rm, bits_S) -> (bits_fflags, bits(16))
function riscv_f32ToUi16 (rm, v) = {
let (_, sig32) = riscv_f32ToUi32(rm, v);
if unsigned(sig32) > unsigned(ones(16)) then (nvFlag(), ones(16))
@@ -974,10 +943,9 @@ function rsqrt7 (v, sub) = {
zero_extend(64, sign @ out_exp @ out_sig)
}
-val riscv_f16Rsqrte7 : (bits_rm, bits_H) -> (bits_fflags, bits_H) effect {rreg}
+val riscv_f16Rsqrte7 : (bits_rm, bits_H) -> (bits_fflags, bits_H)
function riscv_f16Rsqrte7 (rm, v) = {
- let class = fp_class(v);
- let (fflags, result) : (bits_fflags, bits_H)= match class {
+ match fp_class(v) {
0x0001 => (nvFlag(), 0x7e00),
0x0002 => (nvFlag(), 0x7e00),
0x0004 => (nvFlag(), 0x7e00),
@@ -988,14 +956,12 @@ function riscv_f16Rsqrte7 (rm, v) = {
0x0080 => (zeros(5), 0x0000),
0x0020 => (zeros(5), rsqrt7(v, true)[15 .. 0]),
_ => (zeros(5), rsqrt7(v, false)[15 .. 0])
- };
- (fflags, result)
+ }
}
-val riscv_f32Rsqrte7 : (bits_rm, bits_S) -> (bits_fflags, bits_S) effect {rreg}
+val riscv_f32Rsqrte7 : (bits_rm, bits_S) -> (bits_fflags, bits_S)
function riscv_f32Rsqrte7 (rm, v) = {
- let class = fp_class(v);
- let (fflags, result) : (bits_fflags, bits_S)= match class[15 .. 0] {
+ match fp_class(v)[15 .. 0] {
0x0001 => (nvFlag(), 0x7fc00000),
0x0002 => (nvFlag(), 0x7fc00000),
0x0004 => (nvFlag(), 0x7fc00000),
@@ -1006,14 +972,12 @@ function riscv_f32Rsqrte7 (rm, v) = {
0x0080 => (zeros(5), 0x00000000),
0x0020 => (zeros(5), rsqrt7(v, true)[31 .. 0]),
_ => (zeros(5), rsqrt7(v, false)[31 .. 0])
- };
- (fflags, result)
+ }
}
-val riscv_f64Rsqrte7 : (bits_rm, bits_D) -> (bits_fflags, bits_D) effect {rreg}
+val riscv_f64Rsqrte7 : (bits_rm, bits_D) -> (bits_fflags, bits_D)
function riscv_f64Rsqrte7 (rm, v) = {
- let class = fp_class(v);
- let (fflags, result) : (bits_fflags, bits_D)= match class[15 .. 0] {
+ match fp_class(v)[15 .. 0] {
0x0001 => (nvFlag(), 0x7ff8000000000000),
0x0002 => (nvFlag(), 0x7ff8000000000000),
0x0004 => (nvFlag(), 0x7ff8000000000000),
@@ -1024,8 +988,7 @@ function riscv_f64Rsqrte7 (rm, v) = {
0x0080 => (zeros(5), zeros(64)),
0x0020 => (zeros(5), rsqrt7(v, true)[63 .. 0]),
_ => (zeros(5), rsqrt7(v, false)[63 .. 0])
- };
- (fflags, result)
+ }
}
val recip7 : forall 'm, 'm in {16, 32, 64}. (bits('m), bits(3), bool) -> (bool, bits_D)
@@ -1087,12 +1050,11 @@ function recip7 (v, rm_3b, sub) = {
} else (false, zero_extend(64, sign @ out_exp @ out_sig))
}
-val riscv_f16Recip7 : (bits_rm, bits_H) -> (bits_fflags, bits_H) effect {rreg}
+val riscv_f16Recip7 : (bits_rm, bits_H) -> (bits_fflags, bits_H)
function riscv_f16Recip7 (rm, v) = {
- let class = fp_class(v);
let (round_abnormal_true, res_true) = recip7(v, rm, true);
let (round_abnormal_false, res_false) = recip7(v, rm, false);
- let (fflags, result) : (bits_fflags, bits_H) = match class {
+ match fp_class(v) {
0x0001 => (zeros(5), 0x8000),
0x0080 => (zeros(5), 0x0000),
0x0008 => (dzFlag(), 0xfc00),
@@ -1102,16 +1064,14 @@ function riscv_f16Recip7 (rm, v) = {
0x0004 => if round_abnormal_true then (nxFlag() | ofFlag(), res_true[15 .. 0]) else (zeros(5), res_true[15 .. 0]),
0x0020 => if round_abnormal_true then (nxFlag() | ofFlag(), res_true[15 .. 0]) else (zeros(5), res_true[15 .. 0]),
_ => if round_abnormal_false then (nxFlag() | ofFlag(), res_false[15 .. 0]) else (zeros(5), res_false[15 .. 0])
- };
- (fflags, result)
+ }
}
-val riscv_f32Recip7 : (bits_rm, bits_S) -> (bits_fflags, bits_S) effect {rreg}
+val riscv_f32Recip7 : (bits_rm, bits_S) -> (bits_fflags, bits_S)
function riscv_f32Recip7 (rm, v) = {
- let class = fp_class(v);
let (round_abnormal_true, res_true) = recip7(v, rm, true);
let (round_abnormal_false, res_false) = recip7(v, rm, false);
- let (fflags, result) : (bits_fflags, bits_S) = match class[15 .. 0] {
+ match fp_class(v)[15 .. 0] {
0x0001 => (zeros(5), 0x80000000),
0x0080 => (zeros(5), 0x00000000),
0x0008 => (dzFlag(), 0xff800000),
@@ -1121,16 +1081,14 @@ function riscv_f32Recip7 (rm, v) = {
0x0004 => if round_abnormal_true then (nxFlag() | ofFlag(), res_true[31 .. 0]) else (zeros(5), res_true[31 .. 0]),
0x0020 => if round_abnormal_true then (nxFlag() | ofFlag(), res_true[31 .. 0]) else (zeros(5), res_true[31 .. 0]),
_ => if round_abnormal_false then (nxFlag() | ofFlag(), res_false[31 .. 0]) else (zeros(5), res_false[31 .. 0])
- };
- (fflags, result)
+ }
}
-val riscv_f64Recip7 : (bits_rm, bits_D) -> (bits_fflags, bits_D) effect {rreg}
+val riscv_f64Recip7 : (bits_rm, bits_D) -> (bits_fflags, bits_D)
function riscv_f64Recip7 (rm, v) = {
- let class = fp_class(v);
let (round_abnormal_true, res_true) = recip7(v, rm, true);
let (round_abnormal_false, res_false) = recip7(v, rm, false);
- let (fflags, result) : (bits_fflags, bits_D) = match class[15 .. 0] {
+ match fp_class(v)[15 .. 0] {
0x0001 => (zeros(5), 0x8000000000000000),
0x0080 => (zeros(5), 0x0000000000000000),
0x0008 => (dzFlag(), 0xfff0000000000000),
@@ -1140,6 +1098,5 @@ function riscv_f64Recip7 (rm, v) = {
0x0004 => if round_abnormal_true then (nxFlag() | ofFlag(), res_true[63 .. 0]) else (zeros(5), res_true[63 .. 0]),
0x0020 => if round_abnormal_true then (nxFlag() | ofFlag(), res_true[63 .. 0]) else (zeros(5), res_true[63 .. 0]),
_ => if round_abnormal_false then (nxFlag() | ofFlag(), res_false[63 .. 0]) else (zeros(5), res_false[63 .. 0])
- };
- (fflags, result)
+ }
}
diff --git a/model/riscv_insts_vext_vm.sail b/model/riscv_insts_vext_vm.sail
index b75b079..1f963e7 100755
--- a/model/riscv_insts_vext_vm.sail
+++ b/model/riscv_insts_vext_vm.sail
@@ -1,40 +1,10 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
/* ******************************************************************************* */
/* This file implements part of the vector extension. */
@@ -767,7 +737,7 @@ mapping clause encdec = FVVMTYPE(funct6, vm, vs2, vs1, vd) if haveVExt()
<-> encdec_fvvmfunct6(funct6) @ vm @ vs2 @ vs1 @ 0b001 @ vd @ 0b1010111 if haveVExt()
function clause execute(FVVMTYPE(funct6, vm, vs2, vs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
@@ -831,7 +801,7 @@ mapping clause encdec = FVFMTYPE(funct6, vm, vs2, rs1, vd) if haveVExt()
<-> encdec_fvfmfunct6(funct6) @ vm @ vs2 @ rs1 @ 0b101 @ vd @ 0b1010111 if haveVExt()
function clause execute(FVFMTYPE(funct6, vm, vs2, rs1, vd)) = {
- let rm_3b = fcsr.FRM();
+ let rm_3b = fcsr[FRM];
let SEW = get_sew();
let LMUL_pow = get_lmul_pow();
let num_elem = get_num_elem(LMUL_pow, SEW);
diff --git a/model/riscv_insts_vext_vset.sail b/model/riscv_insts_vext_vset.sail
index 57fdef0..000b2f3 100644
--- a/model/riscv_insts_vext_vset.sail
+++ b/model/riscv_insts_vext_vset.sail
@@ -1,40 +1,10 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
/* ******************************************************************************* */
/* This file implements part of the vector extension. */
@@ -76,9 +46,9 @@ function handle_illegal_vtype() = {
/* Note: Implementations can set vill or trap if the vtype setting is not supported.
* TODO: configuration support for both solutions
*/
- vtype->bits() = 0b1 @ zeros(sizeof(xlen) - 1); /* set vtype.vill */
+ vtype.bits = 0b1 @ zeros(sizeof(xlen) - 1); /* set vtype.vill */
vl = zeros();
- print_reg("CSR vtype <- " ^ BitStr(vtype.bits()));
+ print_reg("CSR vtype <- " ^ BitStr(vtype.bits));
print_reg("CSR vl <- " ^ BitStr(vl))
}
@@ -104,14 +74,14 @@ function clause execute VSETVLI(ma, ta, sew, lmul, rs1, rd) = {
let ratio_pow_ori = SEW_pow_ori - LMUL_pow_ori;
/* set vtype */
- vtype->bits() = 0b0 @ zeros(sizeof(xlen) - 9) @ ma @ ta @ sew @ lmul;
+ vtype.bits = 0b0 @ zeros(sizeof(xlen) - 9) @ ma @ ta @ sew @ lmul;
/* check new SEW and LMUL are legal and calculate VLMAX */
let VLEN_pow = get_vlen_pow();
let ELEN_pow = get_elen_pow();
let LMUL_pow_new = get_lmul_pow();
let SEW_pow_new = get_sew_pow();
- if SEW_pow_new > LMUL_pow_new + ELEN_pow then { handle_illegal_vtype(); return RETIRE_SUCCESS };
+ if SEW_pow_new > (LMUL_pow_new + ELEN_pow) then { handle_illegal_vtype(); return RETIRE_SUCCESS };
let VLMAX = int_power(2, VLEN_pow + LMUL_pow_new - SEW_pow_new);
/* set vl according to VLMAX and AVL */
@@ -133,7 +103,7 @@ function clause execute VSETVLI(ma, ta, sew, lmul, rs1, rd) = {
/* reset vstart to 0 */
vstart = zeros();
- print_reg("CSR vtype <- " ^ BitStr(vtype.bits()));
+ print_reg("CSR vtype <- " ^ BitStr(vtype.bits));
print_reg("CSR vl <- " ^ BitStr(vl));
print_reg("CSR vstart <- " ^ BitStr(vstart));
@@ -155,14 +125,14 @@ function clause execute VSETVL(rs2, rs1, rd) = {
let ratio_pow_ori = SEW_pow_ori - LMUL_pow_ori;
/* set vtype */
- vtype->bits() = X(rs2);
+ vtype.bits = X(rs2);
/* check new SEW and LMUL are legal and calculate VLMAX */
let VLEN_pow = get_vlen_pow();
let ELEN_pow = get_elen_pow();
let LMUL_pow_new = get_lmul_pow();
let SEW_pow_new = get_sew_pow();
- if SEW_pow_new > LMUL_pow_new + ELEN_pow then { handle_illegal_vtype(); return RETIRE_SUCCESS };
+ if SEW_pow_new > (LMUL_pow_new + ELEN_pow) then { handle_illegal_vtype(); return RETIRE_SUCCESS };
let VLMAX = int_power(2, VLEN_pow + LMUL_pow_new - SEW_pow_new);
/* set vl according to VLMAX and AVL */
@@ -184,7 +154,7 @@ function clause execute VSETVL(rs2, rs1, rd) = {
/* reset vstart to 0 */
vstart = zeros();
- print_reg("CSR vtype <- " ^ BitStr(vtype.bits()));
+ print_reg("CSR vtype <- " ^ BitStr(vtype.bits));
print_reg("CSR vl <- " ^ BitStr(vl));
print_reg("CSR vstart <- " ^ BitStr(vstart));
@@ -202,14 +172,14 @@ mapping clause encdec = VSETIVLI(ma, ta, sew, lmul, uimm, rd) if haveVExt()
function clause execute VSETIVLI(ma, ta, sew, lmul, uimm, rd) = {
/* set vtype */
- vtype->bits() = 0b0 @ zeros(sizeof(xlen) - 9) @ ma @ ta @ sew @ lmul;
+ vtype.bits = 0b0 @ zeros(sizeof(xlen) - 9) @ ma @ ta @ sew @ lmul;
/* check new SEW and LMUL are legal and calculate VLMAX */
let VLEN_pow = get_vlen_pow();
let ELEN_pow = get_elen_pow();
let LMUL_pow_new = get_lmul_pow();
let SEW_pow_new = get_sew_pow();
- if SEW_pow_new > LMUL_pow_new + ELEN_pow then { handle_illegal_vtype(); return RETIRE_SUCCESS };
+ if SEW_pow_new > (LMUL_pow_new + ELEN_pow) then { handle_illegal_vtype(); return RETIRE_SUCCESS };
let VLMAX = int_power(2, VLEN_pow + LMUL_pow_new - SEW_pow_new);
/* set vl according to VLMAX and AVL */
@@ -220,7 +190,7 @@ function clause execute VSETIVLI(ma, ta, sew, lmul, uimm, rd) = {
/* reset vstart to 0 */
vstart = zeros();
- print_reg("CSR vtype <- " ^ BitStr(vtype.bits()));
+ print_reg("CSR vtype <- " ^ BitStr(vtype.bits));
print_reg("CSR vl <- " ^ BitStr(vl));
print_reg("CSR vstart <- " ^ BitStr(vstart));
diff --git a/model/riscv_insts_zba.sail b/model/riscv_insts_zba.sail
index 2e474de..4f078d3 100644
--- a/model/riscv_insts_zba.sail
+++ b/model/riscv_insts_zba.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ****************************************************************** */
diff --git a/model/riscv_insts_zbb.sail b/model/riscv_insts_zbb.sail
index 62e4567..c7671a6 100644
--- a/model/riscv_insts_zbb.sail
+++ b/model/riscv_insts_zbb.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ****************************************************************** */
diff --git a/model/riscv_insts_zbc.sail b/model/riscv_insts_zbc.sail
index e237c97..910db1b 100644
--- a/model/riscv_insts_zbc.sail
+++ b/model/riscv_insts_zbc.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ****************************************************************** */
diff --git a/model/riscv_insts_zbkb.sail b/model/riscv_insts_zbkb.sail
index 5983fe6..76190f0 100644
--- a/model/riscv_insts_zbkb.sail
+++ b/model/riscv_insts_zbkb.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ****************************************************************** */
diff --git a/model/riscv_insts_zbkx.sail b/model/riscv_insts_zbkx.sail
index 1d4d7ca..59a90c6 100644
--- a/model/riscv_insts_zbkx.sail
+++ b/model/riscv_insts_zbkx.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ****************************************************************** */
diff --git a/model/riscv_insts_zbs.sail b/model/riscv_insts_zbs.sail
index 75a12b3..b535701 100644
--- a/model/riscv_insts_zbs.sail
+++ b/model/riscv_insts_zbs.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ****************************************************************** */
diff --git a/model/riscv_insts_zcb.sail b/model/riscv_insts_zcb.sail
new file mode 100644
index 0000000..1320736
--- /dev/null
+++ b/model/riscv_insts_zcb.sail
@@ -0,0 +1,210 @@
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
+
+union clause ast = C_LBU : (bits(2), cregidx, cregidx)
+
+mapping clause encdec_compressed =
+ C_LBU(uimm1 @ uimm0, rdc, rs1c) if haveZcb()
+ <-> 0b100 @ 0b000 @ rs1c : cregidx @ uimm0 : bits(1) @ uimm1 : bits(1) @ rdc : cregidx @ 0b00 if haveZcb()
+
+mapping clause assembly = C_LBU(uimm, rdc, rs1c) <->
+ "c.lbu" ^ spc() ^ creg_name(rdc) ^ sep() ^ hex_bits_2(uimm) ^ opt_spc() ^ "(" ^ opt_spc() ^ creg_name(rs1c) ^ opt_spc() ^ ")"
+
+function clause execute C_LBU(uimm, rdc, rs1c) = {
+ let imm : bits(12) = zero_extend(uimm);
+ let rd = creg2reg_idx(rdc);
+ let rs1 = creg2reg_idx(rs1c);
+ execute(LOAD(imm, rs1, rd, true, BYTE, false, false))
+}
+
+/* ****************************************************************** */
+
+union clause ast = C_LHU : (bits(2), cregidx, cregidx)
+
+mapping clause encdec_compressed =
+ C_LHU(uimm1 @ 0b0, rdc, rs1c) if haveZcb()
+ <-> 0b100 @ 0b001 @ rs1c : cregidx @ 0b0 @ uimm1 : bits(1) @ rdc : cregidx @ 0b00 if haveZcb()
+
+mapping clause assembly = C_LHU(uimm, rdc, rs1c) <->
+ "c.lhu" ^ spc() ^ creg_name(rdc) ^ sep() ^ hex_bits_2(uimm) ^ opt_spc() ^ "(" ^ opt_spc() ^ creg_name(rs1c) ^ opt_spc() ^ ")"
+
+function clause execute C_LHU(uimm, rdc, rs1c) = {
+ let imm : bits(12) = zero_extend(uimm);
+ let rd = creg2reg_idx(rdc);
+ let rs1 = creg2reg_idx(rs1c);
+ execute(LOAD(imm, rs1, rd, true, HALF, false, false))
+}
+
+/* ****************************************************************** */
+
+union clause ast = C_LH : (bits(2), cregidx, cregidx)
+
+mapping clause encdec_compressed =
+ C_LH(uimm1 @ 0b0, rdc, rs1c) if haveZcb()
+ <-> 0b100 @ 0b001 @ rs1c : cregidx @ 0b1 @ uimm1 : bits(1) @ rdc : cregidx @ 0b00 if haveZcb()
+
+mapping clause assembly = C_LH(uimm, rdc, rs1c) <->
+ "c.lh" ^ spc() ^ creg_name(rdc) ^ sep() ^ hex_bits_2(uimm) ^ opt_spc() ^ "(" ^ opt_spc() ^ creg_name(rs1c) ^ opt_spc() ^ ")"
+
+function clause execute C_LH(uimm, rdc, rs1c) = {
+ let imm : bits(12) = zero_extend(uimm);
+ let rd = creg2reg_idx(rdc);
+ let rs1 = creg2reg_idx(rs1c);
+ execute(LOAD(imm, rs1, rd, false, HALF, false, false))
+}
+
+/* ****************************************************************** */
+
+union clause ast = C_SB : (bits(2), cregidx, cregidx)
+
+mapping clause encdec_compressed =
+ C_SB(uimm1 @ uimm0, rs1c, rs2c) if haveZcb()
+ <-> 0b100 @ 0b010 @ rs1c : cregidx @ uimm0 : bits(1) @ uimm1 : bits(1) @ rs2c @ 0b00 if haveZcb()
+
+mapping clause assembly = C_SB(uimm, rs1c, rs2c) <->
+ "c.sb" ^ spc() ^ creg_name(rs2c) ^ sep() ^ hex_bits_2(uimm) ^ opt_spc() ^ "(" ^ opt_spc() ^ creg_name(rs1c) ^ opt_spc() ^ ")"
+
+function clause execute C_SB(uimm, rs1c, rs2c) = {
+ let imm : bits(12) = zero_extend(uimm);
+ let rs1 = creg2reg_idx(rs1c);
+ let rs2 = creg2reg_idx(rs2c);
+ execute(STORE(imm, rs2, rs1, BYTE, false, false))
+}
+
+/* ****************************************************************** */
+
+union clause ast = C_SH : (bits(2), cregidx, cregidx)
+
+mapping clause encdec_compressed =
+ C_SH(uimm1 @ 0b0, rs1c, rs2c) if haveZcb()
+ <-> 0b100 @ 0b011 @ rs1c : cregidx @ 0b0 @ uimm1 : bits(1) @ rs2c : cregidx @ 0b00 if haveZcb()
+
+mapping clause assembly = C_SH(uimm, rs1c, rs2c) <->
+ "c.sh" ^ spc() ^ creg_name(rs1c) ^ sep() ^ hex_bits_2(uimm) ^ opt_spc() ^ "(" ^ opt_spc() ^ creg_name(rs2c) ^ opt_spc() ^ ")"
+
+function clause execute C_SH(uimm, rs1c, rs2c) = {
+ let imm : bits(12) = zero_extend(uimm);
+ let rs1 = creg2reg_idx(rs1c);
+ let rs2 = creg2reg_idx(rs2c);
+ execute(STORE(imm, rs2, rs1, HALF, false, false))
+}
+
+/* ****************************************************************** */
+
+union clause ast = C_ZEXT_B : (cregidx)
+
+mapping clause encdec_compressed =
+ C_ZEXT_B(rsdc) if haveZcb()
+ <-> 0b100 @ 0b111 @ rsdc : cregidx @ 0b11 @ 0b000 @ 0b01 if haveZcb()
+
+mapping clause assembly = C_ZEXT_B(rsdc) <->
+ "c.zext.b" ^ spc() ^ creg_name(rsdc)
+
+function clause execute C_ZEXT_B(rsdc) = {
+ let rsd = creg2reg_idx(rsdc);
+ X(rsd) = zero_extend(X(rsd)[7..0]);
+ RETIRE_SUCCESS
+}
+
+/* ****************************************************************** */
+
+union clause ast = C_SEXT_B : (cregidx)
+
+mapping clause encdec_compressed =
+ C_SEXT_B(rsdc) if haveZcb() & haveZbb()
+ <-> 0b100 @ 0b111 @ rsdc : cregidx @ 0b11 @ 0b001 @ 0b01 if haveZcb() & haveZbb()
+
+mapping clause assembly = C_SEXT_B(rsdc) <->
+ "c.sext.b" ^ spc() ^ creg_name(rsdc)
+
+function clause execute C_SEXT_B(rsdc) = {
+ let rsd = creg2reg_idx(rsdc);
+ execute(ZBB_EXTOP(rsd, rsd, RISCV_SEXTB))
+}
+
+/* ****************************************************************** */
+
+union clause ast = C_ZEXT_H : (cregidx)
+
+mapping clause encdec_compressed =
+ C_ZEXT_H(rsdc) if haveZcb() & haveZbb()
+ <-> 0b100 @ 0b111 @ rsdc : cregidx @ 0b11 @ 0b010 @ 0b01 if haveZcb() & haveZbb()
+
+mapping clause assembly = C_ZEXT_H(rsdc) <->
+ "c.zext.h" ^ spc() ^ creg_name(rsdc)
+
+function clause execute C_ZEXT_H(rsdc) = {
+ let rsd = creg2reg_idx(rsdc);
+ execute(ZBB_EXTOP(rsd, rsd, RISCV_ZEXTH))
+}
+
+/* ****************************************************************** */
+
+union clause ast = C_SEXT_H : (cregidx)
+
+mapping clause encdec_compressed =
+ C_SEXT_H(rsdc) if haveZcb() & haveZbb()
+ <-> 0b100 @ 0b111 @ rsdc : cregidx @ 0b11 @ 0b011 @ 0b01 if haveZcb() & haveZbb()
+
+mapping clause assembly = C_SEXT_H(rsdc) <->
+ "c.sext.h" ^ spc() ^ creg_name(rsdc)
+
+function clause execute C_SEXT_H(rsdc) = {
+ let rsd = creg2reg_idx(rsdc);
+ execute(ZBB_EXTOP(rsd, rsd, RISCV_SEXTH))
+}
+
+/* ****************************************************************** */
+
+union clause ast = C_ZEXT_W : (cregidx)
+
+mapping clause encdec_compressed =
+ C_ZEXT_W(rsdc) if haveZcb() & haveZba() & sizeof(xlen) == 64
+ <-> 0b100 @ 0b111 @ rsdc : cregidx @ 0b11 @ 0b100 @ 0b01 if haveZcb() & haveZba() & sizeof(xlen) == 64
+
+mapping clause assembly = C_ZEXT_W(rsdc) <->
+ "c.zext.w" ^ spc() ^ creg_name(rsdc)
+
+function clause execute C_ZEXT_W(rsdc) = {
+ let rsd = creg2reg_idx(rsdc);
+ execute (ZBA_RTYPEUW(0b00000, rsd, rsd, RISCV_ADDUW)) // Note 0b00000 is the regidx of the zero register
+}
+
+/* ****************************************************************** */
+
+union clause ast = C_NOT : (cregidx)
+
+mapping clause encdec_compressed =
+ C_NOT(rsdc) if haveZcb()
+ <-> 0b100 @ 0b111 @ rsdc : cregidx @ 0b11 @ 0b101 @ 0b01 if haveZcb()
+
+mapping clause assembly = C_NOT(rsdc) <->
+ "c.not" ^ spc() ^ creg_name(rsdc)
+
+function clause execute C_NOT(rsdc) = {
+ let r = creg2reg_idx(rsdc);
+ X(r) = ~(X(r));
+ RETIRE_SUCCESS
+}
+
+/* ****************************************************************** */
+
+union clause ast = C_MUL : (cregidx, cregidx)
+
+mapping clause encdec_compressed =
+ C_MUL(rsdc, rs2c) if haveZcb() & (haveMulDiv() | haveZmmul())
+ <-> 0b100 @ 0b111 @ rsdc : cregidx @ 0b10 @ rs2c : cregidx @ 0b01 if haveZcb() & (haveMulDiv() | haveZmmul())
+
+mapping clause assembly = C_MUL(rsdc, rs2c) <->
+ "c.mul" ^ spc() ^ creg_name(rsdc) ^ sep() ^ creg_name(rs2c)
+
+function clause execute C_MUL(rsdc, rs2c) = {
+ let rd = creg2reg_idx(rsdc);
+ let rs = creg2reg_idx(rs2c);
+ execute(MUL(rs, rd, rd, false, true, true))
+}
diff --git a/model/riscv_insts_zfa.sail b/model/riscv_insts_zfa.sail
index 286713f..9f1e199 100644
--- a/model/riscv_insts_zfa.sail
+++ b/model/riscv_insts_zfa.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* FLI.H */
@@ -348,8 +286,8 @@ mapping clause assembly = RISCV_FMINM_D(rs2, rs1, rd)
^ sep() ^ freg_name(rs2)
function clause execute (RISCV_FMINM_D(rs2, rs1, rd)) = {
- let rs1_val_D = F(rs1);
- let rs2_val_D = F(rs2);
+ let rs1_val_D = F_D(rs1);
+ let rs2_val_D = F_D(rs2);
let is_quiet = true;
let (rs1_lt_rs2, fflags) = fle_D (rs1_val_D, rs2_val_D, is_quiet);
@@ -361,7 +299,7 @@ function clause execute (RISCV_FMINM_D(rs2, rs1, rd)) = {
else rs2_val_D;
accrue_fflags(fflags);
- F(rd) = rd_val_D;
+ F_D(rd) = rd_val_D;
RETIRE_SUCCESS
}
@@ -378,8 +316,8 @@ mapping clause assembly = RISCV_FMAXM_D(rs2, rs1, rd)
^ sep() ^ freg_name(rs2)
function clause execute (RISCV_FMAXM_D(rs2, rs1, rd)) = {
- let rs1_val_D = F(rs1);
- let rs2_val_D = F(rs2);
+ let rs1_val_D = F_D(rs1);
+ let rs2_val_D = F_D(rs2);
let is_quiet = true;
let (rs2_lt_rs1, fflags) = fle_D (rs2_val_D, rs1_val_D, is_quiet);
@@ -391,7 +329,7 @@ function clause execute (RISCV_FMAXM_D(rs2, rs1, rd)) = {
else rs2_val_D;
accrue_fflags(fflags);
- F(rd) = rd_val_D;
+ F_D(rd) = rd_val_D;
RETIRE_SUCCESS
}
@@ -520,7 +458,7 @@ mapping clause assembly = RISCV_FROUND_D(rs1, rm, rd)
^ sep() ^ frm_mnemonic(rm)
function clause execute (RISCV_FROUND_D(rs1, rm, rd)) = {
- let rs1_val_D = F(rs1);
+ let rs1_val_D = F_D(rs1);
match (select_instr_or_fcsr_rm(rm)) {
None() => { handle_illegal(); RETIRE_FAIL },
@@ -529,7 +467,7 @@ function clause execute (RISCV_FROUND_D(rs1, rm, rd)) = {
let (fflags, rd_val_D) = riscv_f64roundToInt(rm_3b, rs1_val_D, false);
accrue_fflags(fflags);
- F(rd) = rd_val_D;
+ F_D(rd) = rd_val_D;
RETIRE_SUCCESS
}
}
diff --git a/model/riscv_insts_zfh.sail b/model/riscv_insts_zfh.sail
index 3cc8bec..5522bad 100644
--- a/model/riscv_insts_zfh.sail
+++ b/model/riscv_insts_zfh.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* **************************************************************** */
diff --git a/model/riscv_insts_zicond.sail b/model/riscv_insts_zicond.sail
index a1f4c02..d512603 100644
--- a/model/riscv_insts_zicond.sail
+++ b/model/riscv_insts_zicond.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
union clause ast = ZICOND_RTYPE : (regidx, regidx, regidx, zicondop)
diff --git a/model/riscv_insts_zicsr.sail b/model/riscv_insts_zicsr.sail
index 8953ad4..d106ad2 100644
--- a/model/riscv_insts_zicsr.sail
+++ b/model/riscv_insts_zicsr.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* ****************************************************************** */
@@ -91,45 +29,31 @@ function readCSR csr : csreg -> xlenbits = {
(0xF12, _) => marchid,
(0xF13, _) => mimpid,
(0xF14, _) => mhartid,
- (0x300, _) => mstatus.bits(),
- (0x301, _) => misa.bits(),
- (0x302, _) => medeleg.bits(),
- (0x303, _) => mideleg.bits(),
- (0x304, _) => mie.bits(),
+ (0x300, _) => mstatus.bits,
+ (0x301, _) => misa.bits,
+ (0x302, _) => medeleg.bits,
+ (0x303, _) => mideleg.bits,
+ (0x304, _) => mie.bits,
(0x305, _) => get_mtvec(),
- (0x306, _) => zero_extend(mcounteren.bits()),
- (0x30A, _) => menvcfg.bits()[sizeof(xlen) - 1 .. 0],
- (0x310, 32) => mstatush.bits(),
- (0x31A, 32) => menvcfg.bits()[63 .. 32],
- (0x320, _) => zero_extend(mcountinhibit.bits()),
+ (0x306, _) => zero_extend(mcounteren.bits),
+ (0x30A, _) => menvcfg.bits[sizeof(xlen) - 1 .. 0],
+ (0x310, 32) => mstatush.bits,
+ (0x31A, 32) => menvcfg.bits[63 .. 32],
+ (0x320, _) => zero_extend(mcountinhibit.bits),
(0x340, _) => mscratch,
(0x341, _) => get_xret_target(Machine) & pc_alignment_mask(),
- (0x342, _) => mcause.bits(),
+ (0x342, _) => mcause.bits,
(0x343, _) => mtval,
- (0x344, _) => mip.bits(),
-
- (0x3A0, _) => pmpReadCfgReg(0), // pmpcfg0
- (0x3A1, 32) => pmpReadCfgReg(1), // pmpcfg1
- (0x3A2, _) => pmpReadCfgReg(2), // pmpcfg2
- (0x3A3, 32) => pmpReadCfgReg(3), // pmpcfg3
+ (0x344, _) => mip.bits,
- (0x3B0, _) => pmpaddr0,
- (0x3B1, _) => pmpaddr1,
- (0x3B2, _) => pmpaddr2,
- (0x3B3, _) => pmpaddr3,
- (0x3B4, _) => pmpaddr4,
- (0x3B5, _) => pmpaddr5,
- (0x3B6, _) => pmpaddr6,
- (0x3B7, _) => pmpaddr7,
- (0x3B8, _) => pmpaddr8,
- (0x3B9, _) => pmpaddr9,
- (0x3BA, _) => pmpaddr10,
- (0x3BB, _) => pmpaddr11,
- (0x3BC, _) => pmpaddr12,
- (0x3BD, _) => pmpaddr13,
- (0x3BE, _) => pmpaddr14,
- (0x3BF, _) => pmpaddr15,
+ // pmpcfgN
+ (0x3A @ idx : bits(4), _) if idx[0] == bitzero | sizeof(xlen) == 32 => pmpReadCfgReg(unsigned(idx)),
+ // pmpaddrN. Unfortunately the PMP index does not nicely align with the CSR index bits.
+ (0x3B @ idx : bits(4), _) => pmpReadAddrReg(unsigned(0b00 @ idx)),
+ (0x3C @ idx : bits(4), _) => pmpReadAddrReg(unsigned(0b01 @ idx)),
+ (0x3D @ idx : bits(4), _) => pmpReadAddrReg(unsigned(0b10 @ idx)),
+ (0x3E @ idx : bits(4), _) => pmpReadAddrReg(unsigned(0b11 @ idx)),
/* machine mode counters */
(0xB00, _) => mcycle[(sizeof(xlen) - 1) .. 0],
@@ -141,27 +65,27 @@ function readCSR csr : csreg -> xlenbits = {
(0x008, _) => zero_extend(vstart),
(0x009, _) => zero_extend(vxsat),
(0x00A, _) => zero_extend(vxrm),
- (0x00F, _) => zero_extend(vcsr.bits()),
+ (0x00F, _) => zero_extend(vcsr.bits),
(0xC20, _) => vl,
- (0xC21, _) => vtype.bits(),
+ (0xC21, _) => vtype.bits,
(0xC22, _) => vlenb,
/* trigger/debug */
(0x7a0, _) => ~(tselect), /* this indicates we don't have any trigger support */
/* supervisor mode */
- (0x100, _) => lower_mstatus(mstatus).bits(),
- (0x102, _) => sedeleg.bits(),
- (0x103, _) => sideleg.bits(),
- (0x104, _) => lower_mie(mie, mideleg).bits(),
+ (0x100, _) => lower_mstatus(mstatus).bits,
+ (0x102, _) => sedeleg.bits,
+ (0x103, _) => sideleg.bits,
+ (0x104, _) => lower_mie(mie, mideleg).bits,
(0x105, _) => get_stvec(),
- (0x106, _) => zero_extend(scounteren.bits()),
- (0x10A, _) => senvcfg.bits()[sizeof(xlen) - 1 .. 0],
+ (0x106, _) => zero_extend(scounteren.bits),
+ (0x10A, _) => senvcfg.bits[sizeof(xlen) - 1 .. 0],
(0x140, _) => sscratch,
(0x141, _) => get_xret_target(Supervisor) & pc_alignment_mask(),
- (0x142, _) => scause.bits(),
+ (0x142, _) => scause.bits,
(0x143, _) => stval,
- (0x144, _) => lower_mip(mip, mideleg).bits(),
+ (0x144, _) => lower_mip(mip, mideleg).bits,
(0x180, _) => satp,
/* user mode counters */
@@ -191,46 +115,35 @@ function writeCSR (csr : csreg, value : xlenbits) -> unit = {
let res : option(xlenbits) =
match (csr, sizeof(xlen)) {
/* machine mode */
- (0x300, _) => { mstatus = legalize_mstatus(mstatus, value); Some(mstatus.bits()) },
- (0x301, _) => { misa = legalize_misa(misa, value); Some(misa.bits()) },
- (0x302, _) => { medeleg = legalize_medeleg(medeleg, value); Some(medeleg.bits()) },
- (0x303, _) => { mideleg = legalize_mideleg(mideleg, value); Some(mideleg.bits()) },
- (0x304, _) => { mie = legalize_mie(mie, value); Some(mie.bits()) },
+ (0x300, _) => { mstatus = legalize_mstatus(mstatus, value); Some(mstatus.bits) },
+ (0x301, _) => { misa = legalize_misa(misa, value); Some(misa.bits) },
+ (0x302, _) => { medeleg = legalize_medeleg(medeleg, value); Some(medeleg.bits) },
+ (0x303, _) => { mideleg = legalize_mideleg(mideleg, value); Some(mideleg.bits) },
+ (0x304, _) => { mie = legalize_mie(mie, value); Some(mie.bits) },
(0x305, _) => { Some(set_mtvec(value)) },
- (0x306, _) => { mcounteren = legalize_mcounteren(mcounteren, value); Some(zero_extend(mcounteren.bits())) },
- (0x30A, 32) => { menvcfg = legalize_envcfg(menvcfg, menvcfg.bits()[63 .. 32] @ value); Some(menvcfg.bits()[31 .. 0]) },
- (0x30A, 64) => { menvcfg = legalize_envcfg(menvcfg, value); Some(menvcfg.bits()) },
- (0x310, 32) => { Some(mstatush.bits()) }, // ignore writes for now
- (0x31A, 32) => { menvcfg = legalize_envcfg(menvcfg, value @ menvcfg.bits()[31 .. 0]); Some(menvcfg.bits()[63 .. 32]) },
- (0x320, _) => { mcountinhibit = legalize_mcountinhibit(mcountinhibit, value); Some(zero_extend(mcountinhibit.bits())) },
+ (0x306, _) => { mcounteren = legalize_mcounteren(mcounteren, value); Some(zero_extend(mcounteren.bits)) },
+ (0x30A, 32) => { menvcfg = legalize_menvcfg(menvcfg, menvcfg.bits[63 .. 32] @ value); Some(menvcfg.bits[31 .. 0]) },
+ (0x30A, 64) => { menvcfg = legalize_menvcfg(menvcfg, value); Some(menvcfg.bits) },
+ (0x310, 32) => { Some(mstatush.bits) }, // ignore writes for now
+ (0x31A, 32) => { menvcfg = legalize_menvcfg(menvcfg, value @ menvcfg.bits[31 .. 0]); Some(menvcfg.bits[63 .. 32]) },
+ (0x320, _) => { mcountinhibit = legalize_mcountinhibit(mcountinhibit, value); Some(zero_extend(mcountinhibit.bits)) },
(0x340, _) => { mscratch = value; Some(mscratch) },
(0x341, _) => { Some(set_xret_target(Machine, value)) },
- (0x342, _) => { mcause->bits() = value; Some(mcause.bits()) },
+ (0x342, _) => { mcause.bits = value; Some(mcause.bits) },
(0x343, _) => { mtval = value; Some(mtval) },
- (0x344, _) => { mip = legalize_mip(mip, value); Some(mip.bits()) },
+ (0x344, _) => { mip = legalize_mip(mip, value); Some(mip.bits) },
- // Note: Some(value) returned below is not the legalized value due to locked entries
- (0x3A0, _) => { pmpWriteCfgReg(0, value); Some(pmpReadCfgReg(0)) }, // pmpcfg0
- (0x3A1, 32) => { pmpWriteCfgReg(1, value); Some(pmpReadCfgReg(1)) }, // pmpcfg1
- (0x3A2, _) => { pmpWriteCfgReg(2, value); Some(pmpReadCfgReg(2)) }, // pmpcfg2
- (0x3A3, 32) => { pmpWriteCfgReg(3, value); Some(pmpReadCfgReg(3)) }, // pmpcfg3
+ // pmpcfgN
+ (0x3A @ idx : bits(4), _) if idx[0] == bitzero | sizeof(xlen) == 32 => {
+ let idx = unsigned(idx);
+ pmpWriteCfgReg(idx, value); Some(pmpReadCfgReg(idx))
+ },
- (0x3B0, _) => { pmpaddr0 = pmpWriteAddr(pmpLocked(pmp0cfg), pmpTORLocked(pmp1cfg), pmpaddr0, value); Some(pmpaddr0) },
- (0x3B1, _) => { pmpaddr1 = pmpWriteAddr(pmpLocked(pmp1cfg), pmpTORLocked(pmp2cfg), pmpaddr1, value); Some(pmpaddr1) },
- (0x3B2, _) => { pmpaddr2 = pmpWriteAddr(pmpLocked(pmp2cfg), pmpTORLocked(pmp3cfg), pmpaddr2, value); Some(pmpaddr2) },
- (0x3B3, _) => { pmpaddr3 = pmpWriteAddr(pmpLocked(pmp3cfg), pmpTORLocked(pmp4cfg), pmpaddr3, value); Some(pmpaddr3) },
- (0x3B4, _) => { pmpaddr4 = pmpWriteAddr(pmpLocked(pmp4cfg), pmpTORLocked(pmp5cfg), pmpaddr4, value); Some(pmpaddr4) },
- (0x3B5, _) => { pmpaddr5 = pmpWriteAddr(pmpLocked(pmp5cfg), pmpTORLocked(pmp6cfg), pmpaddr5, value); Some(pmpaddr5) },
- (0x3B6, _) => { pmpaddr6 = pmpWriteAddr(pmpLocked(pmp6cfg), pmpTORLocked(pmp7cfg), pmpaddr6, value); Some(pmpaddr6) },
- (0x3B7, _) => { pmpaddr7 = pmpWriteAddr(pmpLocked(pmp7cfg), pmpTORLocked(pmp8cfg), pmpaddr7, value); Some(pmpaddr7) },
- (0x3B8, _) => { pmpaddr8 = pmpWriteAddr(pmpLocked(pmp8cfg), pmpTORLocked(pmp9cfg), pmpaddr8, value); Some(pmpaddr8) },
- (0x3B9, _) => { pmpaddr9 = pmpWriteAddr(pmpLocked(pmp9cfg), pmpTORLocked(pmp10cfg), pmpaddr9, value); Some(pmpaddr9) },
- (0x3BA, _) => { pmpaddr10 = pmpWriteAddr(pmpLocked(pmp10cfg), pmpTORLocked(pmp11cfg), pmpaddr10, value); Some(pmpaddr10) },
- (0x3BB, _) => { pmpaddr11 = pmpWriteAddr(pmpLocked(pmp11cfg), pmpTORLocked(pmp12cfg), pmpaddr11, value); Some(pmpaddr11) },
- (0x3BC, _) => { pmpaddr12 = pmpWriteAddr(pmpLocked(pmp12cfg), pmpTORLocked(pmp13cfg), pmpaddr12, value); Some(pmpaddr12) },
- (0x3BD, _) => { pmpaddr13 = pmpWriteAddr(pmpLocked(pmp13cfg), pmpTORLocked(pmp14cfg), pmpaddr13, value); Some(pmpaddr13) },
- (0x3BE, _) => { pmpaddr14 = pmpWriteAddr(pmpLocked(pmp14cfg), pmpTORLocked(pmp15cfg), pmpaddr14, value); Some(pmpaddr14) },
- (0x3BF, _) => { pmpaddr15 = pmpWriteAddr(pmpLocked(pmp15cfg), false, pmpaddr15, value); Some(pmpaddr15) },
+ // pmpaddrN. Unfortunately the PMP index does not nicely align with the CSR index bits.
+ (0x3B @ idx : bits(4), _) => { let idx = unsigned(0b00 @ idx); pmpWriteAddrReg(idx, value); Some(pmpReadAddrReg(idx)) },
+ (0x3C @ idx : bits(4), _) => { let idx = unsigned(0b01 @ idx); pmpWriteAddrReg(idx, value); Some(pmpReadAddrReg(idx)) },
+ (0x3D @ idx : bits(4), _) => { let idx = unsigned(0b10 @ idx); pmpWriteAddrReg(idx, value); Some(pmpReadAddrReg(idx)) },
+ (0x3E @ idx : bits(4), _) => { let idx = unsigned(0b11 @ idx); pmpWriteAddrReg(idx, value); Some(pmpReadAddrReg(idx)) },
/* machine mode counters */
(0xB00, _) => { mcycle[(sizeof(xlen) - 1) .. 0] = value; Some(value) },
@@ -242,18 +155,18 @@ function writeCSR (csr : csreg, value : xlenbits) -> unit = {
(0x7a0, _) => { tselect = value; Some(tselect) },
/* supervisor mode */
- (0x100, _) => { mstatus = legalize_sstatus(mstatus, value); Some(mstatus.bits()) },
- (0x102, _) => { sedeleg = legalize_sedeleg(sedeleg, value); Some(sedeleg.bits()) },
- (0x103, _) => { sideleg->bits() = value; Some(sideleg.bits()) }, /* TODO: does this need legalization? */
- (0x104, _) => { mie = legalize_sie(mie, mideleg, value); Some(mie.bits()) },
+ (0x100, _) => { mstatus = legalize_sstatus(mstatus, value); Some(mstatus.bits) },
+ (0x102, _) => { sedeleg = legalize_sedeleg(sedeleg, value); Some(sedeleg.bits) },
+ (0x103, _) => { sideleg.bits = value; Some(sideleg.bits) }, /* TODO: does this need legalization? */
+ (0x104, _) => { mie = legalize_sie(mie, mideleg, value); Some(mie.bits) },
(0x105, _) => { Some(set_stvec(value)) },
- (0x106, _) => { scounteren = legalize_scounteren(scounteren, value); Some(zero_extend(scounteren.bits())) },
- (0x10A, _) => { senvcfg = legalize_envcfg(senvcfg, zero_extend(value)); Some(senvcfg.bits()[sizeof(xlen) - 1 .. 0]) },
+ (0x106, _) => { scounteren = legalize_scounteren(scounteren, value); Some(zero_extend(scounteren.bits)) },
+ (0x10A, _) => { senvcfg = legalize_senvcfg(senvcfg, zero_extend(value)); Some(senvcfg.bits[sizeof(xlen) - 1 .. 0]) },
(0x140, _) => { sscratch = value; Some(sscratch) },
(0x141, _) => { Some(set_xret_target(Supervisor, value)) },
- (0x142, _) => { scause->bits() = value; Some(scause.bits()) },
+ (0x142, _) => { scause.bits = value; Some(scause.bits) },
(0x143, _) => { stval = value; Some(stval) },
- (0x144, _) => { mip = legalize_sip(mip, mideleg, value); Some(mip.bits()) },
+ (0x144, _) => { mip = legalize_sip(mip, mideleg, value); Some(mip.bits) },
(0x180, _) => { satp = legalize_satp(cur_Architecture(), satp, value); Some(satp) },
/* user mode: seed (entropy source). writes are ignored */
@@ -263,9 +176,9 @@ function writeCSR (csr : csreg, value : xlenbits) -> unit = {
(0x008, _) => { let vstart_length = get_vlen_pow(); vstart = zero_extend(16, value[(vstart_length - 1) .. 0]); Some(zero_extend(vstart)) },
(0x009, _) => { vxsat = value[0 .. 0]; Some(zero_extend(vxsat)) },
(0x00A, _) => { vxrm = value[1 .. 0]; Some(zero_extend(vxrm)) },
- (0x00F, _) => { vcsr->bits() = value[2 ..0]; Some(zero_extend(vcsr.bits())) },
+ (0x00F, _) => { vcsr.bits = value[2 ..0]; Some(zero_extend(vcsr.bits)) },
(0xC20, _) => { vl = value; Some(vl) },
- (0xC21, _) => { vtype->bits() = value; Some(vtype.bits()) },
+ (0xC21, _) => { vtype.bits = value; Some(vtype.bits) },
(0xC22, _) => { vlenb = value; Some(vlenb) },
_ => ext_write_CSR(csr, value)
diff --git a/model/riscv_insts_zkn.sail b/model/riscv_insts_zkn.sail
index 43256ed..160d6e4 100644
--- a/model/riscv_insts_zkn.sail
+++ b/model/riscv_insts_zkn.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/*
@@ -328,8 +266,8 @@ mapping clause encdec = AES64DSM (rs2, rs1, rd) if haveZknd() & sizeof(xlen) ==
mapping clause encdec = AES64DS (rs2, rs1, rd) if haveZknd() & sizeof(xlen) == 64
<-> 0b00 @ 0b11101 @ rs2 @ rs1 @ 0b000 @ rd @ 0b0110011
-mapping clause assembly = AES64KS1I (rcon, rs1, rd)
- <-> "aes64ks1i" ^ spc() ^ reg_name(rd) ^ sep() ^ reg_name(rs1) ^ sep() ^ hex_bits_4(rcon)
+mapping clause assembly = AES64KS1I (rnum, rs1, rd)
+ <-> "aes64ks1i" ^ spc() ^ reg_name(rd) ^ sep() ^ reg_name(rs1) ^ sep() ^ hex_bits_4(rnum)
mapping clause assembly = AES64KS2 (rs2, rs1, rd)
<-> "aes64ks2" ^ spc() ^ reg_name(rd) ^ sep() ^ reg_name(rs1) ^ sep() ^ reg_name(rs2)
diff --git a/model/riscv_insts_zks.sail b/model/riscv_insts_zks.sail
index 1c29d3a..002857a 100644
--- a/model/riscv_insts_zks.sail
+++ b/model/riscv_insts_zks.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/*
diff --git a/model/riscv_jalr_rmem.sail b/model/riscv_jalr_rmem.sail
index 216cbfd..d628630 100644
--- a/model/riscv_jalr_rmem.sail
+++ b/model/riscv_jalr_rmem.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* The definition for the memory model. */
diff --git a/model/riscv_jalr_seq.sail b/model/riscv_jalr_seq.sail
index 35d370b..497a441 100644
--- a/model/riscv_jalr_seq.sail
+++ b/model/riscv_jalr_seq.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* The definition for the sequential model. */
diff --git a/model/riscv_mem.sail b/model/riscv_mem.sail
index 0f36dee..ccf4d2f 100644
--- a/model/riscv_mem.sail
+++ b/model/riscv_mem.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Physical memory model.
@@ -97,7 +35,7 @@
* per the platform memory map.
*/
-function is_aligned_addr forall 'n. (addr : xlenbits, width : atom('n)) -> bool =
+function is_aligned_addr forall 'n. (addr : xlenbits, width : int('n)) -> bool =
unsigned(addr) % width == 0
function read_kind_of_flags (aq : bool, rl : bool, res : bool) -> option(read_kind) =
@@ -112,8 +50,21 @@ function read_kind_of_flags (aq : bool, rl : bool, res : bool) -> option(read_ki
(false, true, true) => None()
}
+function write_kind_of_flags (aq : bool, rl : bool, con : bool) -> write_kind =
+ match (aq, rl, con) {
+ (false, false, false) => Write_plain,
+ (false, true, false) => Write_RISCV_release,
+ (false, false, true) => Write_RISCV_conditional,
+ (false, true , true) => Write_RISCV_conditional_release,
+ (true, true, false) => Write_RISCV_strong_release,
+ (true, true , true) => Write_RISCV_conditional_strong_release,
+ // throw an illegal instruction here?
+ (true, false, false) => throw(Error_not_implemented("store.aq")),
+ (true, false, true) => throw(Error_not_implemented("sc.aq"))
+ }
+
// only used for actual memory regions, to avoid MMIO effects
-function phys_mem_read forall 'n, 0 < 'n <= max_mem_access . (t : AccessType(ext_access_type), paddr : xlenbits, width : atom('n), aq : bool, rl: bool, res : bool, meta : bool) -> MemoryOpResult((bits(8 * 'n), mem_meta)) = {
+function phys_mem_read forall 'n, 0 < 'n <= max_mem_access . (t : AccessType(ext_access_type), paddr : xlenbits, width : int('n), aq : bool, rl: bool, res : bool, meta : bool) -> MemoryOpResult((bits(8 * 'n), mem_meta)) = {
let result = (match read_kind_of_flags(aq, rl, res) {
Some(rk) => Some(read_ram(rk, paddr, width, meta)),
None() => None()
@@ -128,63 +79,74 @@ function phys_mem_read forall 'n, 0 < 'n <= max_mem_access . (t : AccessType(ext
}
}
-/* dispatches to MMIO regions or physical memory regions depending on physical memory map */
-function checked_mem_read forall 'n, 0 < 'n <= max_mem_access . (t : AccessType(ext_access_type), paddr : xlenbits, width : atom('n), aq : bool, rl : bool, res: bool, meta : bool) -> MemoryOpResult((bits(8 * 'n), mem_meta)) =
- if within_mmio_readable(paddr, width)
- then MemoryOpResult_add_meta(mmio_read(t, paddr, width), default_meta)
- else if within_phys_mem(paddr, width)
- then match ext_check_phys_mem_read(t, paddr, width, aq, rl, res, meta) {
- Ext_PhysAddr_OK() => phys_mem_read(t, paddr, width, aq, rl, res, meta),
- Ext_PhysAddr_Error(e) => MemException(e)
- } else match t {
- Execute() => MemException(E_Fetch_Access_Fault()),
- Read(Data) => MemException(E_Load_Access_Fault()),
- _ => MemException(E_SAMO_Access_Fault())
- }
+// Check if access is permitted according to PMPs and PMAs.
+val phys_access_check : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), Privilege, xlenbits, int('n)) -> option(ExceptionType)
+function phys_access_check (t, p, paddr, width) = {
+ let pmpError : option(ExceptionType) = if sys_pmp_count() == 0 then None() else pmpCheck(paddr, width, t, p);
+ // TODO: Also check PMAs and select the highest priority fault.
+ pmpError
+}
-/* PMP checks if enabled */
-function pmp_mem_read forall 'n, 0 < 'n <= max_mem_access . (t : AccessType(ext_access_type), p : Privilege, paddr : xlenbits, width : atom('n), aq : bool, rl : bool, res: bool, meta : bool) -> MemoryOpResult((bits(8 * 'n), mem_meta)) =
- if not(plat_enable_pmp())
- then checked_mem_read(t, paddr, width, aq, rl, res, meta)
- else {
- match pmpCheck(paddr, width, t, p) {
- None() => checked_mem_read(t, paddr, width, aq, rl, res, meta),
- Some(e) => MemException(e)
+/* dispatches to MMIO regions or physical memory regions depending on physical memory map */
+function checked_mem_read forall 'n, 0 < 'n <= max_mem_access . (
+ t : AccessType(ext_access_type),
+ priv : Privilege,
+ paddr : xlenbits,
+ width : int('n),
+ aq : bool,
+ rl : bool,
+ res: bool,
+ meta : bool,
+) -> MemoryOpResult((bits(8 * 'n), mem_meta)) =
+ match phys_access_check(t, priv, paddr, width) {
+ Some(e) => MemException(e),
+ None() => {
+ if within_mmio_readable(paddr, width)
+ then MemoryOpResult_add_meta(mmio_read(t, paddr, width), default_meta)
+ else if within_phys_mem(paddr, width)
+ then match ext_check_phys_mem_read(t, paddr, width, aq, rl, res, meta) {
+ Ext_PhysAddr_OK() => phys_mem_read(t, paddr, width, aq, rl, res, meta),
+ Ext_PhysAddr_Error(e) => MemException(e)
+ } else match t {
+ Execute() => MemException(E_Fetch_Access_Fault()),
+ Read(Data) => MemException(E_Load_Access_Fault()),
+ _ => MemException(E_SAMO_Access_Fault())
+ }
}
}
/* Atomic accesses can be done to MMIO regions, e.g. in kernel access to device registers. */
$ifdef RVFI_DII
-val rvfi_read : forall 'n, 'n > 0. (xlenbits, atom('n), MemoryOpResult((bits(8 * 'n), mem_meta))) -> unit
+val rvfi_read : forall 'n, 'n > 0. (xlenbits, int('n), MemoryOpResult((bits(8 * 'n), mem_meta))) -> unit
function rvfi_read (addr, width, result) = {
- rvfi_mem_data->rvfi_mem_addr() = zero_extend(addr);
+ rvfi_mem_data[rvfi_mem_addr] = zero_extend(addr);
rvfi_mem_data_present = true;
match result {
/* TODO: report tag bit for capability writes and extend mask by one bit. */
MemValue(v, _) => if width <= 16
- then { rvfi_mem_data->rvfi_mem_rdata() = sail_zero_extend(v, 256);
- rvfi_mem_data->rvfi_mem_rmask() = rvfi_encode_width_mask(width) }
+ then { rvfi_mem_data[rvfi_mem_rdata] = sail_zero_extend(v, 256);
+ rvfi_mem_data[rvfi_mem_rmask] = rvfi_encode_width_mask(width) }
else { internal_error(__FILE__, __LINE__, "Expected at most 16 bytes here!") },
MemException(_) => ()
};
}
$else
-val rvfi_read : forall 'n, 'n > 0. (xlenbits, atom('n), MemoryOpResult((bits(8 * 'n), mem_meta))) -> unit
+val rvfi_read : forall 'n, 'n > 0. (xlenbits, int('n), MemoryOpResult((bits(8 * 'n), mem_meta))) -> unit
function rvfi_read (addr, width, result) = ()
$endif
/* NOTE: The rreg effect is due to MMIO. */
$ifdef RVFI_DII
-val mem_read : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), xlenbits, atom('n), bool, bool, bool) -> MemoryOpResult(bits(8 * 'n))
-val mem_read_priv : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), Privilege, xlenbits, atom('n), bool, bool, bool) -> MemoryOpResult(bits(8 * 'n))
-val mem_read_meta : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), xlenbits, atom('n), bool, bool, bool, bool) -> MemoryOpResult((bits(8 * 'n), mem_meta))
-val mem_read_priv_meta : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), Privilege, xlenbits, atom('n), bool, bool, bool, bool) -> MemoryOpResult((bits(8 * 'n), mem_meta))
+val mem_read : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), xlenbits, int('n), bool, bool, bool) -> MemoryOpResult(bits(8 * 'n))
+val mem_read_priv : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), Privilege, xlenbits, int('n), bool, bool, bool) -> MemoryOpResult(bits(8 * 'n))
+val mem_read_meta : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), xlenbits, int('n), bool, bool, bool, bool) -> MemoryOpResult((bits(8 * 'n), mem_meta))
+val mem_read_priv_meta : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), Privilege, xlenbits, int('n), bool, bool, bool, bool) -> MemoryOpResult((bits(8 * 'n), mem_meta))
$else
-val mem_read : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), xlenbits, atom('n), bool, bool, bool) -> MemoryOpResult(bits(8 * 'n))
-val mem_read_priv : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), Privilege, xlenbits, atom('n), bool, bool, bool) -> MemoryOpResult(bits(8 * 'n))
-val mem_read_meta : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), xlenbits, atom('n), bool, bool, bool, bool) -> MemoryOpResult((bits(8 * 'n), mem_meta))
-val mem_read_priv_meta : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), Privilege, xlenbits, atom('n), bool, bool, bool, bool) -> MemoryOpResult((bits(8 * 'n), mem_meta))
+val mem_read : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), xlenbits, int('n), bool, bool, bool) -> MemoryOpResult(bits(8 * 'n))
+val mem_read_priv : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), Privilege, xlenbits, int('n), bool, bool, bool) -> MemoryOpResult(bits(8 * 'n))
+val mem_read_meta : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), xlenbits, int('n), bool, bool, bool, bool) -> MemoryOpResult((bits(8 * 'n), mem_meta))
+val mem_read_priv_meta : forall 'n, 0 < 'n <= max_mem_access . (AccessType(ext_access_type), Privilege, xlenbits, int('n), bool, bool, bool, bool) -> MemoryOpResult((bits(8 * 'n), mem_meta))
$endif
/* The most generic memory read operation */
@@ -195,7 +157,7 @@ function mem_read_priv_meta (typ, priv, paddr, width, aq, rl, res, meta) = {
else match (aq, rl, res) {
(false, true, false) => throw(Error_not_implemented("load.rl")),
(false, true, true) => throw(Error_not_implemented("lr.rl")),
- (_, _, _) => pmp_mem_read(typ, priv, paddr, width, aq, rl, res, meta)
+ (_, _, _) => checked_mem_read(typ, priv, paddr, width, aq, rl, res, meta)
};
rvfi_read(paddr, width, result);
result
@@ -212,34 +174,23 @@ function mem_read_priv (typ, priv, paddr, width, aq, rl, res) =
function mem_read (typ, paddr, width, aq, rel, res) =
mem_read_priv(typ, effectivePrivilege(typ, mstatus, cur_privilege), paddr, width, aq, rel, res)
-val mem_write_ea : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, atom('n), bool, bool, bool) -> MemoryOpResult(unit)
-
-function mem_write_ea (addr, width, aq, rl, con) = {
+val mem_write_ea : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, int('n), bool, bool, bool) -> MemoryOpResult(unit)
+function mem_write_ea (addr, width, aq, rl, con) =
if (rl | con) & not(is_aligned_addr(addr, width))
then MemException(E_SAMO_Addr_Align())
- else match (aq, rl, con) {
- (false, false, false) => MemValue(write_ram_ea(Write_plain, addr, width)),
- (false, true, false) => MemValue(write_ram_ea(Write_RISCV_release, addr, width)),
- (false, false, true) => MemValue(write_ram_ea(Write_RISCV_conditional, addr, width)),
- (false, true , true) => MemValue(write_ram_ea(Write_RISCV_conditional_release, addr, width)),
- (true, false, false) => throw(Error_not_implemented("store.aq")),
- (true, true, false) => MemValue(write_ram_ea(Write_RISCV_strong_release, addr, width)),
- (true, false, true) => throw(Error_not_implemented("sc.aq")),
- (true, true , true) => MemValue(write_ram_ea(Write_RISCV_conditional_strong_release, addr, width))
- }
-}
+ else MemValue(write_ram_ea(write_kind_of_flags(aq, rl, con), addr, width))
$ifdef RVFI_DII
-val rvfi_write : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, atom('n), bits(8 * 'n), mem_meta, MemoryOpResult(bool)) -> unit
+val rvfi_write : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, int('n), bits(8 * 'n), mem_meta, MemoryOpResult(bool)) -> unit
function rvfi_write (addr, width, value, meta, result) = {
- rvfi_mem_data->rvfi_mem_addr() = zero_extend(addr);
+ rvfi_mem_data[rvfi_mem_addr] = zero_extend(addr);
rvfi_mem_data_present = true;
match result {
/* Log only the memory address (without the value) if the write fails. */
MemValue(_) => if width <= 16 then {
/* TODO: report tag bit for capability writes and extend mask by one bit. */
- rvfi_mem_data->rvfi_mem_wdata() = sail_zero_extend(value,256);
- rvfi_mem_data->rvfi_mem_wmask() = rvfi_encode_width_mask(width);
+ rvfi_mem_data[rvfi_mem_wdata] = sail_zero_extend(value,256);
+ rvfi_mem_data[rvfi_mem_wmask] = rvfi_encode_width_mask(width);
} else {
internal_error(__FILE__, __LINE__, "Expected at most 16 bytes here!");
},
@@ -247,12 +198,12 @@ function rvfi_write (addr, width, value, meta, result) = {
}
}
$else
-val rvfi_write : forall 'n, 'n > 0. (xlenbits, atom('n), bits(8 * 'n), mem_meta, MemoryOpResult(bool)) -> unit
+val rvfi_write : forall 'n, 'n > 0. (xlenbits, int('n), bits(8 * 'n), mem_meta, MemoryOpResult(bool)) -> unit
function rvfi_write (addr, width, value, meta, result) = ()
$endif
// only used for actual memory regions, to avoid MMIO effects
-function phys_mem_write forall 'n, 0 < 'n <= max_mem_access . (wk : write_kind, paddr : xlenbits, width : atom('n), data : bits(8 * 'n), meta : mem_meta) -> MemoryOpResult(bool) = {
+function phys_mem_write forall 'n, 0 < 'n <= max_mem_access . (wk : write_kind, paddr : xlenbits, width : int('n), data : bits(8 * 'n), meta : mem_meta) -> MemoryOpResult(bool) = {
let result = MemValue(write_ram(wk, paddr, width, data, meta));
if get_config_print_mem()
then print_mem("mem[" ^ BitStr(paddr) ^ "] <- " ^ BitStr(data));
@@ -260,24 +211,30 @@ function phys_mem_write forall 'n, 0 < 'n <= max_mem_access . (wk : write_kind,
}
/* dispatches to MMIO regions or physical memory regions depending on physical memory map */
-function checked_mem_write forall 'n, 0 < 'n <= max_mem_access . (wk : write_kind, paddr : xlenbits, width : atom('n), data: bits(8 * 'n), meta: mem_meta) -> MemoryOpResult(bool) =
- if within_mmio_writable(paddr, width)
- then mmio_write(paddr, width, data)
- else if within_phys_mem(paddr, width)
- then match ext_check_phys_mem_write (wk, paddr, width, data, meta) {
- Ext_PhysAddr_OK() => phys_mem_write(wk, paddr, width, data, meta),
- Ext_PhysAddr_Error(e) => MemException(e)
- }
- else MemException(E_SAMO_Access_Fault())
-
-/* PMP checks if enabled */
-function pmp_mem_write forall 'n, 0 < 'n <= max_mem_access . (wk: write_kind, paddr : xlenbits, width : atom('n), data: bits(8 * 'n), typ: AccessType(ext_access_type), priv: Privilege, meta: mem_meta) -> MemoryOpResult(bool) =
- if not(plat_enable_pmp())
- then checked_mem_write(wk, paddr, width, data, meta)
- else {
- match pmpCheck(paddr, width, typ, priv) {
- None() => checked_mem_write(wk, paddr, width, data, meta),
- Some(e) => MemException(e)
+function checked_mem_write forall 'n, 0 < 'n <= max_mem_access . (
+ paddr : xlenbits,
+ width : int('n),
+ data: bits(8 * 'n),
+ typ : AccessType(ext_access_type),
+ priv : Privilege,
+ meta: mem_meta,
+ aq : bool,
+ rl : bool,
+ con : bool,
+) -> MemoryOpResult(bool) =
+ match phys_access_check(typ, priv, paddr, width) {
+ Some(e) => MemException(e),
+ None() => {
+ if within_mmio_writable(paddr, width)
+ then mmio_write(paddr, width, data)
+ else if within_phys_mem(paddr, width)
+ then {
+ let wk = write_kind_of_flags(aq, rl, con);
+ match ext_check_phys_mem_write (wk, paddr, width, data, meta) {
+ Ext_PhysAddr_OK() => phys_mem_write(wk, paddr, width, data, meta),
+ Ext_PhysAddr_Error(e) => MemException(e),
+ }
+ } else MemException(E_SAMO_Access_Fault())
}
}
@@ -288,35 +245,24 @@ function pmp_mem_write forall 'n, 0 < 'n <= max_mem_access . (wk: write_kind, pa
* data.
* NOTE: The wreg effect is due to MMIO, the rreg is due to checking mtime.
*/
-val mem_write_value_priv_meta : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, atom('n), bits(8 * 'n), AccessType(ext_access_type), Privilege, mem_meta, bool, bool, bool) -> MemoryOpResult(bool)
+val mem_write_value_priv_meta : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, int('n), bits(8 * 'n), AccessType(ext_access_type), Privilege, mem_meta, bool, bool, bool) -> MemoryOpResult(bool)
function mem_write_value_priv_meta (paddr, width, value, typ, priv, meta, aq, rl, con) = {
if (rl | con) & not(is_aligned_addr(paddr, width))
then MemException(E_SAMO_Addr_Align())
else {
- let wk : write_kind = match (aq, rl, con) {
- (false, false, false) => Write_plain,
- (false, true, false) => Write_RISCV_release,
- (false, false, true) => Write_RISCV_conditional,
- (false, true , true) => Write_RISCV_conditional_release,
- (true, true, false) => Write_RISCV_strong_release,
- (true, true , true) => Write_RISCV_conditional_strong_release,
- // throw an illegal instruction here?
- (true, false, false) => throw(Error_not_implemented("store.aq")),
- (true, false, true) => throw(Error_not_implemented("sc.aq"))
- };
- let result = pmp_mem_write(wk, paddr, width, value, typ, priv, meta);
+ let result = checked_mem_write(paddr, width, value, typ, priv, meta, aq, rl, con);
rvfi_write(paddr, width, value, meta, result);
result
}
}
/* Memory write with explicit Privilege, implicit AccessType and metadata */
-val mem_write_value_priv : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, atom('n), bits(8 * 'n), Privilege, bool, bool, bool) -> MemoryOpResult(bool)
+val mem_write_value_priv : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, int('n), bits(8 * 'n), Privilege, bool, bool, bool) -> MemoryOpResult(bool)
function mem_write_value_priv (paddr, width, value, priv, aq, rl, con) =
mem_write_value_priv_meta(paddr, width, value, Write(default_write_acc), priv, default_meta, aq, rl, con)
/* Memory write with explicit metadata and AccessType, implicit and Privilege */
-val mem_write_value_meta : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, atom('n), bits(8 * 'n), ext_access_type, mem_meta, bool, bool, bool) -> MemoryOpResult(bool)
+val mem_write_value_meta : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, int('n), bits(8 * 'n), ext_access_type, mem_meta, bool, bool, bool) -> MemoryOpResult(bool)
function mem_write_value_meta (paddr, width, value, ext_acc, meta, aq, rl, con) = {
let typ = Write(ext_acc);
let ep = effectivePrivilege(typ, mstatus, cur_privilege);
@@ -324,7 +270,7 @@ function mem_write_value_meta (paddr, width, value, ext_acc, meta, aq, rl, con)
}
/* Memory write with default AccessType, Privilege, and metadata */
-val mem_write_value : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, atom('n), bits(8 * 'n), bool, bool, bool) -> MemoryOpResult(bool)
+val mem_write_value : forall 'n, 0 < 'n <= max_mem_access . (xlenbits, int('n), bits(8 * 'n), bool, bool, bool) -> MemoryOpResult(bool)
function mem_write_value (paddr, width, value, aq, rl, con) = {
mem_write_value_meta(paddr, width, value, default_write_acc, default_meta, aq, rl, con)
}
diff --git a/model/riscv_misa_ext.sail b/model/riscv_misa_ext.sail
index f7b124c..5d14b53 100644
--- a/model/riscv_misa_ext.sail
+++ b/model/riscv_misa_ext.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
function ext_veto_disable_C () = false
diff --git a/model/riscv_next_control.sail b/model/riscv_next_control.sail
index 432fd0d..688d16d 100644
--- a/model/riscv_next_control.sail
+++ b/model/riscv_next_control.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Functional specification for the 'N' user-level interrupts standard extension. */
@@ -79,24 +17,24 @@ function clause ext_is_CSR_defined(0x042, _) = haveUsrMode() & haveNExt() // uca
function clause ext_is_CSR_defined(0x043, _) = haveUsrMode() & haveNExt() // utval
function clause ext_is_CSR_defined(0x044, _) = haveUsrMode() & haveNExt() // uip
-function clause ext_read_CSR(0x000) = Some(lower_sstatus(lower_mstatus(mstatus)).bits())
-function clause ext_read_CSR(0x004) = Some(lower_sie(lower_mie(mie, mideleg), sideleg).bits())
+function clause ext_read_CSR(0x000) = Some(lower_sstatus(lower_mstatus(mstatus)).bits)
+function clause ext_read_CSR(0x004) = Some(lower_sie(lower_mie(mie, mideleg), sideleg).bits)
function clause ext_read_CSR(0x005) = Some(get_utvec())
function clause ext_read_CSR(0x040) = Some(uscratch)
function clause ext_read_CSR(0x041) = Some(get_xret_target(User) & pc_alignment_mask())
-function clause ext_read_CSR(0x042) = Some(ucause.bits())
+function clause ext_read_CSR(0x042) = Some(ucause.bits)
function clause ext_read_CSR(0x043) = Some(utval)
-function clause ext_read_CSR(0x044) = Some(lower_sip(lower_mip(mip, mideleg), sideleg).bits())
+function clause ext_read_CSR(0x044) = Some(lower_sip(lower_mip(mip, mideleg), sideleg).bits)
-function clause ext_write_CSR(0x000, value) = { mstatus = legalize_ustatus(mstatus, value); Some(mstatus.bits()) }
+function clause ext_write_CSR(0x000, value) = { mstatus = legalize_ustatus(mstatus, value); Some(mstatus.bits) }
function clause ext_write_CSR(0x004, value) = { let sie = legalize_uie(lower_mie(mie, mideleg), sideleg, value);
mie = lift_sie(mie, mideleg, sie);
- Some(mie.bits()) }
+ Some(mie.bits) }
function clause ext_write_CSR(0x005, value) = { Some(set_utvec(value)) }
function clause ext_write_CSR(0x040, value) = { uscratch = value; Some(uscratch) }
function clause ext_write_CSR(0x041, value) = { Some(set_xret_target(User, value)) }
-function clause ext_write_CSR(0x042, value) = { ucause->bits() = value; Some(ucause.bits()) }
+function clause ext_write_CSR(0x042, value) = { ucause.bits = value; Some(ucause.bits) }
function clause ext_write_CSR(0x043, value) = { utval = value; Some(utval) }
function clause ext_write_CSR(0x044, value) = { let sip = legalize_uip(lower_mip(mip, mideleg), sideleg, value);
mip = lift_sip(mip, mideleg, sip);
- Some(mip.bits()) }
+ Some(mip.bits) }
diff --git a/model/riscv_next_regs.sail b/model/riscv_next_regs.sail
index b078bf8..6f25447 100644
--- a/model/riscv_next_regs.sail
+++ b/model/riscv_next_regs.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Architectural state for the 'N' user-level interrupts standard extension. */
@@ -79,14 +17,14 @@ bitfield Ustatus : xlenbits = {
/* This is a view, so there is no register defined. */
function lower_sstatus(s : Sstatus) -> Ustatus = {
let u = Mk_Ustatus(zero_extend(0b0));
- let u = update_UPIE(u, s.UPIE());
- let u = update_UIE(u, s.UIE());
+ let u = [u with UPIE = s[UPIE]];
+ let u = [u with UIE = s[UIE]];
u
}
function lift_ustatus(s : Sstatus, u : Ustatus) -> Sstatus = {
- let s = update_UPIE(s, u.UPIE());
- let s = update_UIE(s, u.UIE());
+ let s = [s with UPIE = u[UPIE]];
+ let s = [s with UIE = u[UIE]];
s
}
@@ -107,25 +45,25 @@ bitfield Uinterrupts : xlenbits = {
/* Provides the uip read view of sip (s) as delegated by sideleg (d). */
function lower_sip(s : Sinterrupts, d : Sinterrupts) -> Uinterrupts = {
let u : Uinterrupts = Mk_Uinterrupts(zero_extend(0b0));
- let u = update_UEI(u, s.UEI() & d.UEI());
- let u = update_UTI(u, s.UTI() & d.UTI());
- let u = update_USI(u, s.USI() & d.USI());
+ let u = [u with UEI = s[UEI] & d[UEI]];
+ let u = [u with UTI = s[UTI] & d[UTI]];
+ let u = [u with USI = s[USI] & d[USI]];
u
}
/* Provides the uie read view of sie as delegated by sideleg. */
function lower_sie(s : Sinterrupts, d : Sinterrupts) -> Uinterrupts = {
let u : Uinterrupts = Mk_Uinterrupts(zero_extend(0b0));
- let u = update_UEI(u, s.UEI() & d.UEI());
- let u = update_UTI(u, s.UTI() & d.UTI());
- let u = update_USI(u, s.USI() & d.USI());
+ let u = [u with UEI = s[UEI] & d[UEI]];
+ let u = [u with UTI = s[UTI] & d[UTI]];
+ let u = [u with USI = s[USI] & d[USI]];
u
}
/* Returns the new value of sip from the previous sip (o) and the written uip (u) as delegated by sideleg (d). */
function lift_uip(o : Sinterrupts, d : Sinterrupts, u : Uinterrupts) -> Sinterrupts = {
let s : Sinterrupts = o;
- let s = if d.USI() == 0b1 then update_USI(s, u.USI()) else s;
+ let s = if d[USI] == 0b1 then [s with USI = u[USI]] else s;
s
}
@@ -136,9 +74,9 @@ function legalize_uip(s : Sinterrupts, d : Sinterrupts, v : xlenbits) -> Sinterr
/* Returns the new value of sie from the previous sie (o) and the written uie (u) as delegated by sideleg (d). */
function lift_uie(o : Sinterrupts, d : Sinterrupts, u : Uinterrupts) -> Sinterrupts = {
let s : Sinterrupts = o;
- let s = if d.UEI() == 0b1 then update_UEI(s, u.UEI()) else s;
- let s = if d.UTI() == 0b1 then update_UTI(s, u.UTI()) else s;
- let s = if d.USI() == 0b1 then update_USI(s, u.USI()) else s;
+ let s = if d[UEI] == 0b1 then [s with UEI = u[UEI]] else s;
+ let s = if d[UTI] == 0b1 then [s with UTI = u[UTI]] else s;
+ let s = if d[USI] == 0b1 then [s with USI = u[USI]] else s;
s
}
diff --git a/model/riscv_pc_access.sail b/model/riscv_pc_access.sail
index dee566a..d3e54e5 100644
--- a/model/riscv_pc_access.sail
+++ b/model/riscv_pc_access.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* accessors for default architectural addresses, for use from within instructions */
diff --git a/model/riscv_platform.sail b/model/riscv_platform.sail
index 579a118..19e3d30 100644
--- a/model/riscv_platform.sail
+++ b/model/riscv_platform.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Platform-specific definitions, and basic MMIO devices. */
@@ -92,12 +30,6 @@ val elf_entry = {
val plat_ram_base = {c: "plat_ram_base", ocaml: "Platform.dram_base", interpreter: "Platform.dram_base", lem: "plat_ram_base"} : unit -> xlenbits
val plat_ram_size = {c: "plat_ram_size", ocaml: "Platform.dram_size", interpreter: "Platform.dram_size", lem: "plat_ram_size"} : unit -> xlenbits
-/* whether the platform supports PMP configurations */
-val plat_enable_pmp = {ocaml: "Platform.enable_pmp",
- interpreter: "Platform.enable_pmp",
- c: "plat_enable_pmp",
- lem: "plat_enable_pmp"} : unit -> bool
-
/* whether the MMU should update dirty bits in PTEs */
val plat_enable_dirty_update = {ocaml: "Platform.enable_dirty_update",
interpreter: "Platform.enable_dirty_update",
@@ -139,7 +71,7 @@ function phys_mem_segments() =
/* Physical memory map predicates */
-function within_phys_mem forall 'n, 'n <= max_mem_access. (addr : xlenbits, width : atom('n)) -> bool = {
+function within_phys_mem forall 'n, 'n <= max_mem_access. (addr : xlenbits, width : int('n)) -> bool = {
/* To avoid overflow issues when physical memory extends to the end
* of the addressable range, we need to perform address bound checks
* on unsigned unbounded integers.
@@ -167,7 +99,7 @@ function within_phys_mem forall 'n, 'n <= max_mem_access. (addr : xlenbits, widt
}
}
-function within_clint forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : atom('n)) -> bool = {
+function within_clint forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : int('n)) -> bool = {
/* To avoid overflow issues when physical memory extends to the end
* of the addressable range, we need to perform address bound checks
* on unsigned unbounded integers.
@@ -179,10 +111,10 @@ function within_clint forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, wi
& (addr_int + sizeof('n)) <= (clint_base_int + clint_size_int)
}
-function within_htif_writable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : atom('n)) -> bool =
+function within_htif_writable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : int('n)) -> bool =
plat_htif_tohost() == addr | (plat_htif_tohost() + 4 == addr & width == 4)
-function within_htif_readable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : atom('n)) -> bool =
+function within_htif_readable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : int('n)) -> bool =
plat_htif_tohost() == addr | (plat_htif_tohost() + 4 == addr & width == 4)
/* CLINT (Core Local Interruptor), based on Spike. */
@@ -219,8 +151,8 @@ function clint_load(t, addr, width) = {
if addr == MSIP_BASE & ('n == 8 | 'n == 4)
then {
if get_config_print_platform()
- then print_platform("clint[" ^ BitStr(addr) ^ "] -> " ^ BitStr(mip.MSI()));
- MemValue(sail_zero_extend(mip.MSI(), sizeof(8 * 'n)))
+ then print_platform("clint[" ^ BitStr(addr) ^ "] -> " ^ BitStr(mip[MSI]));
+ MemValue(sail_zero_extend(mip[MSI], sizeof(8 * 'n)))
}
else if addr == MTIMECMP_BASE & ('n == 4)
then {
@@ -275,11 +207,11 @@ function clint_load(t, addr, width) = {
function clint_dispatch() -> unit = {
if get_config_print_platform()
then print_platform("clint::tick mtime <- " ^ BitStr(mtime));
- mip->MTI() = 0b0;
+ mip[MTI] = 0b0;
if mtimecmp <=_u mtime then {
if get_config_print_platform()
then print_platform(" clint timer pending at mtime " ^ BitStr(mtime));
- mip->MTI() = 0b1
+ mip[MTI] = 0b1
}
}
@@ -290,7 +222,7 @@ function clint_store(addr, width, data) = {
if addr == MSIP_BASE & ('n == 8 | 'n == 4) then {
if get_config_print_platform()
then print_platform("clint[" ^ BitStr(addr) ^ "] <- " ^ BitStr(data) ^ " (mip.MSI <- " ^ BitStr(data[0]) ^ ")");
- mip->MSI() = [data[0]];
+ mip[MSI] = [data[0]];
clint_dispatch();
MemValue(true)
} else if addr == MTIMECMP_BASE & 'n == 8 then {
@@ -320,7 +252,7 @@ function clint_store(addr, width, data) = {
val tick_clock : unit -> unit
function tick_clock() = {
- if mcountinhibit.CY() == 0b0
+ if mcountinhibit[CY] == 0b0
then mcycle = mcycle + 1;
mtime = mtime + 1;
@@ -416,23 +348,23 @@ function htif_store(paddr, width, data) = {
| (unsigned(htif_payload_writes) > 2))
then {
let cmd = Mk_htif_cmd(htif_tohost);
- match cmd.device() {
+ match cmd[device] {
0x00 => { /* syscall-proxy */
if get_config_print_platform()
- then print_platform("htif-syscall-proxy cmd: " ^ BitStr(cmd.payload()));
- if cmd.payload()[0] == bitone
+ then print_platform("htif-syscall-proxy cmd: " ^ BitStr(cmd[payload]));
+ if cmd[payload][0] == bitone
then {
htif_done = true;
- htif_exit_code = (sail_zero_extend(cmd.payload(), 64) >> 1)
+ htif_exit_code = (sail_zero_extend(cmd[payload], 64) >> 1)
}
else ()
},
0x01 => { /* terminal */
if get_config_print_platform()
- then print_platform("htif-term cmd: " ^ BitStr(cmd.payload()));
- match cmd.cmd() {
+ then print_platform("htif-term cmd: " ^ BitStr(cmd[payload]));
+ match cmd[cmd] {
0x00 => /* TODO: terminal input handling */ (),
- 0x01 => plat_term_write(cmd.payload()[7..0]),
+ 0x01 => plat_term_write(cmd[payload][7..0]),
c => print("Unknown term cmd: " ^ BitStr(c))
};
/* reset to ack */
@@ -453,20 +385,20 @@ function htif_tick() = {
/* Top-level MMIO dispatch */
$ifndef RVFI_DII
-function within_mmio_readable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : atom('n)) -> bool =
+function within_mmio_readable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : int('n)) -> bool =
within_clint(addr, width) | (within_htif_readable(addr, width) & 1 <= 'n)
$else
-function within_mmio_readable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : atom('n)) -> bool = false
+function within_mmio_readable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : int('n)) -> bool = false
$endif
$ifndef RVFI_DII
-function within_mmio_writable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : atom('n)) -> bool =
+function within_mmio_writable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : int('n)) -> bool =
within_clint(addr, width) | (within_htif_writable(addr, width) & 'n <= 8)
$else
-function within_mmio_writable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : atom('n)) -> bool = false
+function within_mmio_writable forall 'n, 0 < 'n <= max_mem_access . (addr : xlenbits, width : int('n)) -> bool = false
$endif
-function mmio_read forall 'n, 0 < 'n <= max_mem_access . (t : AccessType(ext_access_type), paddr : xlenbits, width : atom('n)) -> MemoryOpResult(bits(8 * 'n)) =
+function mmio_read forall 'n, 0 < 'n <= max_mem_access . (t : AccessType(ext_access_type), paddr : xlenbits, width : int('n)) -> MemoryOpResult(bits(8 * 'n)) =
if within_clint(paddr, width)
then clint_load(t, paddr, width)
else if within_htif_readable(paddr, width) & (1 <= 'n)
@@ -477,7 +409,7 @@ function mmio_read forall 'n, 0 < 'n <= max_mem_access . (t : AccessType(ext_acc
_ => MemException(E_SAMO_Access_Fault())
}
-function mmio_write forall 'n, 0 <'n <= max_mem_access . (paddr : xlenbits, width : atom('n), data: bits(8 * 'n)) -> MemoryOpResult(bool) =
+function mmio_write forall 'n, 0 <'n <= max_mem_access . (paddr : xlenbits, width : int('n), data: bits(8 * 'n)) -> MemoryOpResult(bool) =
if within_clint(paddr, width)
then clint_store(paddr, width, data)
else if within_htif_writable(paddr, width) & 'n <= 8
diff --git a/model/riscv_pmp_control.sail b/model/riscv_pmp_control.sail
index 998fb92..1e4cb77 100644
--- a/model/riscv_pmp_control.sail
+++ b/model/riscv_pmp_control.sail
@@ -1,93 +1,37 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* address ranges */
-// TODO: handle PMP grain > 4 (i.e. G > 0).
// TODO: handle the 34-bit paddr32 on RV32
/* [min, max) of the matching range. */
type pmp_addr_range = option((xlenbits, xlenbits))
function pmpAddrRange(cfg: Pmpcfg_ent, pmpaddr: xlenbits, prev_pmpaddr: xlenbits) -> pmp_addr_range = {
- match pmpAddrMatchType_of_bits(cfg.A()) {
+ match pmpAddrMatchType_of_bits(cfg[A]) {
OFF => None(),
TOR => { Some ((prev_pmpaddr << 2, pmpaddr << 2)) },
- NA4 => { // TODO: I find the spec unclear for entries marked NA4 and G = 1.
- // (for G >= 2, it is the same as NAPOT). In particular, it affects
- // whether pmpaddr[0] is always read as 0.
+ NA4 => {
+ // NA4 is not selectable when the PMP grain G >= 1. See pmpWriteCfg().
+ assert(sys_pmp_grain() < 1, "NA4 cannot be selected when PMP grain G >= 1.");
let lo = pmpaddr << 2;
Some((lo, lo + 4))
},
- NAPOT => { let mask = pmpaddr ^ (pmpaddr + 1); // generate 1s in signifying bits
+ NAPOT => {
+ // Example pmpaddr: 0b00010101111
+ // ^--- last 0 dictates region size & alignment
+ let mask = pmpaddr ^ (pmpaddr + 1);
+ // pmpaddr + 1: 0b00010110000
+ // mask: 0b00000011111
+ // ~mask: 0b11111100000
let lo = pmpaddr & (~ (mask));
+ // mask + 1: 0b00000100000
let len = mask + 1;
Some((lo << 2, (lo + len) << 2))
}
@@ -99,10 +43,10 @@ function pmpAddrRange(cfg: Pmpcfg_ent, pmpaddr: xlenbits, prev_pmpaddr: xlenbits
val pmpCheckRWX: (Pmpcfg_ent, AccessType(ext_access_type)) -> bool
function pmpCheckRWX(ent, acc) = {
match acc {
- Read(_) => ent.R() == 0b1,
- Write(_) => ent.W() == 0b1,
- ReadWrite(_) => ent.R() == 0b1 & ent.W() == 0b1,
- Execute() => ent.X() == 0b1
+ Read(_) => ent[R] == 0b1,
+ Write(_) => ent[W] == 0b1,
+ ReadWrite(_) => ent[R] == 0b1 & ent[W] == 0b1,
+ Execute() => ent[X] == 0b1
}
}
@@ -152,104 +96,38 @@ function pmpMatchEntry(addr: xlenbits, width: xlenbits, acc: AccessType(ext_acce
/* priority checks */
-function pmpCheck forall 'n, 'n > 0. (addr: xlenbits, width: atom('n), acc: AccessType(ext_access_type), priv: Privilege)
+function accessToFault(acc : AccessType(ext_access_type)) -> ExceptionType =
+ match acc {
+ Read(_) => E_Load_Access_Fault(),
+ Write(_) => E_SAMO_Access_Fault(),
+ ReadWrite(_) => E_SAMO_Access_Fault(),
+ Execute() => E_Fetch_Access_Fault(),
+ }
+
+function pmpCheck forall 'n, 'n > 0. (addr: xlenbits, width: int('n), acc: AccessType(ext_access_type), priv: Privilege)
-> option(ExceptionType) = {
let width : xlenbits = to_bits(sizeof(xlen), width);
- let check : bool =
- match pmpMatchEntry(addr, width, acc, priv, pmp0cfg, pmpaddr0, zeros()) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp1cfg, pmpaddr1, pmpaddr0) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp2cfg, pmpaddr2, pmpaddr1) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp3cfg, pmpaddr3, pmpaddr2) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp4cfg, pmpaddr4, pmpaddr3) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp5cfg, pmpaddr5, pmpaddr4) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp6cfg, pmpaddr6, pmpaddr5) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp7cfg, pmpaddr7, pmpaddr6) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp8cfg, pmpaddr8, pmpaddr7) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp9cfg, pmpaddr9, pmpaddr8) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp10cfg, pmpaddr10, pmpaddr9) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp11cfg, pmpaddr11, pmpaddr10) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp12cfg, pmpaddr12, pmpaddr11) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp13cfg, pmpaddr13, pmpaddr12) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp14cfg, pmpaddr14, pmpaddr13) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue =>
- match pmpMatchEntry(addr, width, acc, priv, pmp15cfg, pmpaddr15, pmpaddr14) {
- PMP_Success => true,
- PMP_Fail => false,
- PMP_Continue => match priv {
- Machine => true,
- _ => false
- }
- }}}}}}}}}}}}}}}};
-
- if check
- then None()
- else match acc {
- Read(_) => Some(E_Load_Access_Fault()),
- Write(_) => Some(E_SAMO_Access_Fault()),
- ReadWrite(_) => Some(E_SAMO_Access_Fault()),
- Execute() => Some(E_Fetch_Access_Fault())
- }
+
+ foreach (i from 0 to 63) {
+ let prev_pmpaddr = (if i > 0 then pmpReadAddrReg(i - 1) else zeros());
+ match pmpMatchEntry(addr, width, acc, priv, pmpcfg_n[i], pmpReadAddrReg(i), prev_pmpaddr) {
+ PMP_Success => { return None(); },
+ PMP_Fail => { return Some(accessToFault(acc)); },
+ PMP_Continue => (),
+ }
+ };
+ if priv == Machine then None() else Some(accessToFault(acc))
}
function init_pmp() -> unit = {
- pmp0cfg = update_A(pmp0cfg, pmpAddrMatchType_to_bits(OFF));
- pmp1cfg = update_A(pmp1cfg, pmpAddrMatchType_to_bits(OFF));
- pmp2cfg = update_A(pmp2cfg, pmpAddrMatchType_to_bits(OFF));
- pmp3cfg = update_A(pmp3cfg, pmpAddrMatchType_to_bits(OFF));
- pmp4cfg = update_A(pmp4cfg, pmpAddrMatchType_to_bits(OFF));
- pmp5cfg = update_A(pmp5cfg, pmpAddrMatchType_to_bits(OFF));
- pmp6cfg = update_A(pmp6cfg, pmpAddrMatchType_to_bits(OFF));
- pmp7cfg = update_A(pmp7cfg, pmpAddrMatchType_to_bits(OFF));
- pmp8cfg = update_A(pmp8cfg, pmpAddrMatchType_to_bits(OFF));
- pmp9cfg = update_A(pmp9cfg, pmpAddrMatchType_to_bits(OFF));
- pmp10cfg = update_A(pmp10cfg, pmpAddrMatchType_to_bits(OFF));
- pmp11cfg = update_A(pmp11cfg, pmpAddrMatchType_to_bits(OFF));
- pmp12cfg = update_A(pmp12cfg, pmpAddrMatchType_to_bits(OFF));
- pmp13cfg = update_A(pmp13cfg, pmpAddrMatchType_to_bits(OFF));
- pmp14cfg = update_A(pmp14cfg, pmpAddrMatchType_to_bits(OFF));
- pmp15cfg = update_A(pmp15cfg, pmpAddrMatchType_to_bits(OFF))
+ assert(
+ sys_pmp_count() == 0 | sys_pmp_count() == 16 | sys_pmp_count() == 64,
+ "sys_pmp_count() must be 0, 16, or 64"
+ );
+
+ foreach (i from 0 to 63) {
+ // On reset the PMP register's A and L bits are set to 0 unless the plaform
+ // mandates a different value.
+ pmpcfg_n[i] = [pmpcfg_n[i] with A = pmpAddrMatchType_to_bits(OFF), L = 0b0];
+ };
}
diff --git a/model/riscv_pmp_regs.sail b/model/riscv_pmp_regs.sail
index 9b6355c..a9e4676 100644
--- a/model/riscv_pmp_regs.sail
+++ b/model/riscv_pmp_regs.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* PMP configuration entries */
@@ -102,123 +40,109 @@ bitfield Pmpcfg_ent : bits(8) = {
R : 0 /* read */
}
-register pmp0cfg : Pmpcfg_ent
-register pmp1cfg : Pmpcfg_ent
-register pmp2cfg : Pmpcfg_ent
-register pmp3cfg : Pmpcfg_ent
-register pmp4cfg : Pmpcfg_ent
-register pmp5cfg : Pmpcfg_ent
-register pmp6cfg : Pmpcfg_ent
-register pmp7cfg : Pmpcfg_ent
-register pmp8cfg : Pmpcfg_ent
-register pmp9cfg : Pmpcfg_ent
-register pmp10cfg : Pmpcfg_ent
-register pmp11cfg : Pmpcfg_ent
-register pmp12cfg : Pmpcfg_ent
-register pmp13cfg : Pmpcfg_ent
-register pmp14cfg : Pmpcfg_ent
-register pmp15cfg : Pmpcfg_ent
-
-/* PMP address configuration */
-
-register pmpaddr0 : xlenbits
-register pmpaddr1 : xlenbits
-register pmpaddr2 : xlenbits
-register pmpaddr3 : xlenbits
-register pmpaddr4 : xlenbits
-register pmpaddr5 : xlenbits
-register pmpaddr6 : xlenbits
-register pmpaddr7 : xlenbits
-register pmpaddr8 : xlenbits
-register pmpaddr9 : xlenbits
-register pmpaddr10 : xlenbits
-register pmpaddr11 : xlenbits
-register pmpaddr12 : xlenbits
-register pmpaddr13 : xlenbits
-register pmpaddr14 : xlenbits
-register pmpaddr15 : xlenbits
+register pmpcfg_n : vector(64, dec, Pmpcfg_ent)
+register pmpaddr_n : vector(64, dec, xlenbits)
/* Packing and unpacking pmpcfg regs for xlen-width accesses */
-val pmpReadCfgReg : forall 'n, 0 <= 'n < 4 . (atom('n)) -> xlenbits
-function pmpReadCfgReg(n) = {
- if sizeof(xlen) == 32
- then match n {
- 0 => append(pmp3cfg.bits(), append(pmp2cfg.bits(), append(pmp1cfg.bits(), pmp0cfg.bits()))),
- 1 => append(pmp7cfg.bits(), append(pmp6cfg.bits(), append(pmp5cfg.bits(), pmp4cfg.bits()))),
- 2 => append(pmp11cfg.bits(), append(pmp10cfg.bits(), append(pmp9cfg.bits(), pmp8cfg.bits()))),
- 3 => append(pmp15cfg.bits(), append(pmp14cfg.bits(), append(pmp13cfg.bits(), pmp12cfg.bits()))),
- _ => internal_error(__FILE__, __LINE__, "Unexpected pmp config reg read")
- }
- else match n { // sizeof(xlen) >= 64
- 0 => append(pmp7cfg.bits(), append(pmp6cfg.bits(), append(pmp5cfg.bits(), append(pmp4cfg.bits(), append(pmp3cfg.bits(), append(pmp2cfg.bits(), append(pmp1cfg.bits(), pmp0cfg.bits()))))))),
- 2 => append(pmp15cfg.bits(), append(pmp14cfg.bits(), append(pmp13cfg.bits(), append(pmp12cfg.bits(), append(pmp11cfg.bits(), append(pmp10cfg.bits(), append(pmp9cfg.bits(), pmp8cfg.bits()))))))),
- _ => internal_error(__FILE__, __LINE__, "Unexpected pmp config reg read")
- }
+function pmpReadCfgReg(n : range(0, 15)) -> xlenbits = {
+ if sizeof(xlen) == 32
+ then {
+ pmpcfg_n[n*4 + 3].bits @
+ pmpcfg_n[n*4 + 2].bits @
+ pmpcfg_n[n*4 + 1].bits @
+ pmpcfg_n[n*4 + 0].bits
+ }
+ else {
+ assert(n % 2 == 0, "Unexpected pmp config reg read");
+ pmpcfg_n[n*4 + 7].bits @
+ pmpcfg_n[n*4 + 6].bits @
+ pmpcfg_n[n*4 + 5].bits @
+ pmpcfg_n[n*4 + 4].bits @
+ pmpcfg_n[n*4 + 3].bits @
+ pmpcfg_n[n*4 + 2].bits @
+ pmpcfg_n[n*4 + 1].bits @
+ pmpcfg_n[n*4 + 0].bits
+ }
+}
+
+function pmpReadAddrReg(n : range(0, 63)) -> xlenbits = {
+ let G = sys_pmp_grain();
+ let match_type = pmpcfg_n[n].A();
+ let addr = pmpaddr_n[n];
+
+ match match_type[1] {
+ bitone if G >= 2 => {
+ // [G-2..0] read as all ones to form mask, therefore we need G-1 bits.
+ let mask : xlenbits = zero_extend(ones(min(G - 1, sizeof(xlen))));
+ addr | mask
+ },
+
+ bitzero if G >= 1 => {
+ // [G-1..0] read as all zeros to form mask, therefore we need G bits.
+ let mask : xlenbits = zero_extend(ones(min(G , sizeof(xlen))));
+ addr & ~(mask)
+ },
+
+ _ => addr,
+ }
}
/* Helpers to handle locked entries */
function pmpLocked(cfg: Pmpcfg_ent) -> bool =
- cfg.L() == 0b1
+ cfg[L] == 0b1
function pmpTORLocked(cfg: Pmpcfg_ent) -> bool =
- (cfg.L() == 0b1) & (pmpAddrMatchType_of_bits(cfg.A()) == TOR)
+ (cfg[L] == 0b1) & (pmpAddrMatchType_of_bits(cfg[A]) == TOR)
-function pmpWriteCfg(cfg: Pmpcfg_ent, v: bits(8)) -> Pmpcfg_ent =
+function pmpWriteCfg(n: range(0, 63), cfg: Pmpcfg_ent, v: bits(8)) -> Pmpcfg_ent =
if pmpLocked(cfg) then cfg
- else Mk_Pmpcfg_ent(v & 0x9f) // Bits 5 and 6 are zero.
+ else {
+ // Bits 5 and 6 are zero.
+ let cfg = Mk_Pmpcfg_ent(v & 0x9f);
+
+ // "The R, W, and X fields form a collective WARL field for which the combinations with R=0 and W=1 are reserved."
+ // In this implementation if R=0 and W=1 then R, W and X are all set to 0.
+ // This is the least risky option from a security perspective.
+ let cfg = if cfg.W() == 0b1 & cfg.R() == 0b0 then [cfg with X = 0b0, W = 0b0, R = 0b0] else cfg;
+
+ // "When G >= 1, the NA4 mode is not selectable."
+ // In this implementation we set it to OFF if NA4 is selected.
+ // This is the least risky option from a security perspective.
+ let cfg = if sys_pmp_grain() >= 1 & pmpAddrMatchType_of_bits(cfg.A()) == NA4
+ then [cfg with A = pmpAddrMatchType_to_bits(OFF)]
+ else cfg;
+
+ cfg
+ }
-val pmpWriteCfgReg : forall 'n, 0 <= 'n < 4 . (atom('n), xlenbits) -> unit
-function pmpWriteCfgReg(n, v) = {
- if sizeof(xlen) == 32
- then match n {
- 0 => { pmp0cfg = pmpWriteCfg(pmp0cfg, v[7 ..0]);
- pmp1cfg = pmpWriteCfg(pmp1cfg, v[15..8]);
- pmp2cfg = pmpWriteCfg(pmp2cfg, v[23..16]);
- pmp3cfg = pmpWriteCfg(pmp3cfg, v[31..24]);
- },
- 1 => { pmp4cfg = pmpWriteCfg(pmp4cfg, v[7 ..0]);
- pmp5cfg = pmpWriteCfg(pmp5cfg, v[15..8]);
- pmp6cfg = pmpWriteCfg(pmp6cfg, v[23..16]);
- pmp7cfg = pmpWriteCfg(pmp7cfg, v[31..24]);
- },
- 2 => { pmp8cfg = pmpWriteCfg(pmp8cfg, v[7 ..0]);
- pmp9cfg = pmpWriteCfg(pmp9cfg, v[15..8]);
- pmp10cfg = pmpWriteCfg(pmp10cfg, v[23..16]);
- pmp11cfg = pmpWriteCfg(pmp11cfg, v[31..24]);
- },
- 3 => { pmp12cfg = pmpWriteCfg(pmp12cfg, v[7 ..0]);
- pmp13cfg = pmpWriteCfg(pmp13cfg, v[15..8]);
- pmp14cfg = pmpWriteCfg(pmp14cfg, v[23..16]);
- pmp15cfg = pmpWriteCfg(pmp15cfg, v[31..24]);
- },
- _ => internal_error(__FILE__, __LINE__, "Unexpected pmp config reg write")
- }
- else if sizeof(xlen) >= 64
- then match n {
- 0 => { pmp0cfg = pmpWriteCfg(pmp0cfg, v[7 ..0]);
- pmp1cfg = pmpWriteCfg(pmp1cfg, v[15..8]);
- pmp2cfg = pmpWriteCfg(pmp2cfg, v[23..16]);
- pmp3cfg = pmpWriteCfg(pmp3cfg, v[31..24]);
- pmp4cfg = pmpWriteCfg(pmp4cfg, v[39..32]);
- pmp5cfg = pmpWriteCfg(pmp5cfg, v[47..40]);
- pmp6cfg = pmpWriteCfg(pmp6cfg, v[55..48]);
- pmp7cfg = pmpWriteCfg(pmp7cfg, v[63..56])
- },
- 2 => { pmp8cfg = pmpWriteCfg(pmp8cfg, v[7 ..0]);
- pmp9cfg = pmpWriteCfg(pmp9cfg, v[15..8]);
- pmp10cfg = pmpWriteCfg(pmp10cfg, v[23..16]);
- pmp11cfg = pmpWriteCfg(pmp11cfg, v[31..24]);
- pmp12cfg = pmpWriteCfg(pmp12cfg, v[39..32]);
- pmp13cfg = pmpWriteCfg(pmp13cfg, v[47..40]);
- pmp14cfg = pmpWriteCfg(pmp14cfg, v[55..48]);
- pmp15cfg = pmpWriteCfg(pmp15cfg, v[63..56])
- },
- _ => internal_error(__FILE__, __LINE__, "Unexpected pmp config reg write")
- }
+function pmpWriteCfgReg(n : range(0, 15), v : xlenbits) -> unit = {
+ if sizeof(xlen) == 32
+ then {
+ foreach (i from 0 to 3) {
+ let idx = n*4 + i;
+ pmpcfg_n[idx] = pmpWriteCfg(idx, pmpcfg_n[idx], v[8*i+7 .. 8*i]);
+ }
+ }
+ else {
+ assert(n % 2 == 0, "Unexpected pmp config reg write");
+ foreach (i from 0 to 7) {
+ let idx = n*4 + i;
+ pmpcfg_n[idx] = pmpWriteCfg(idx, pmpcfg_n[idx], v[8*i+7 .. 8*i]);
+ }
+ }
}
function pmpWriteAddr(locked: bool, tor_locked: bool, reg: xlenbits, v: xlenbits) -> xlenbits =
if sizeof(xlen) == 32
then { if (locked | tor_locked) then reg else v }
else { if (locked | tor_locked) then reg else zero_extend(v[53..0]) }
+
+function pmpWriteAddrReg(n : range(0, 63), v : xlenbits) -> unit = {
+ pmpaddr_n[n] = pmpWriteAddr(
+ pmpLocked(pmpcfg_n[n]),
+ if n + 1 < 64 then pmpTORLocked(pmpcfg_n[n + 1]) else false,
+ pmpaddr_n[n],
+ v,
+ );
+}
diff --git a/model/riscv_pte.sail b/model/riscv_pte.sail
deleted file mode 100644
index 90345cc..0000000
--- a/model/riscv_pte.sail
+++ /dev/null
@@ -1,154 +0,0 @@
-/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
-/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=======================================================================================*/
-
-/* PTE attributes, permission checks and updates */
-
-type pteAttribs = bits(8)
-
-/* Reserved PTE bits could be used by extensions on RV64. There are
- * no such available bits on RV32, so these bits will be zeros on RV32.
- */
-type extPte = bits(10)
-
-/*
- * On SV32, there are no reserved bits available to extensions. Therefore, by
- * default, we initialize the PTE extension field with all zeros. However,
- * extensions may wish, on SV39/48/56, to put flags in the reserved region of
- * those PTEs. To avoid the need for "inhibit" bits in extensions (i.e., so
- * that extensions can use the more common and more RISC-V flavored "enable"
- * disposition), we allow extensions to use any constant value by overriding
- * this default_sv32_ext_pte value.
- */
-let default_sv32_ext_pte : extPte = zeros()
-
-bitfield PTE_Bits : pteAttribs = {
- D : 7,
- A : 6,
- G : 5,
- U : 4,
- X : 3,
- W : 2,
- R : 1,
- V : 0
-}
-
-function isPTEPtr(p : pteAttribs, ext : extPte) -> bool = {
- let a = Mk_PTE_Bits(p);
- a.R() == 0b0 & a.W() == 0b0 & a.X() == 0b0
-}
-
-function isInvalidPTE(p : pteAttribs, ext : extPte) -> bool = {
- let a = Mk_PTE_Bits(p);
- a.V() == 0b0 | (a.W() == 0b1 & a.R() == 0b0)
-}
-
-union PTE_Check = {
- PTE_Check_Success : ext_ptw,
- PTE_Check_Failure : (ext_ptw, ext_ptw_fail)
-}
-
-function to_pte_check(b : bool) -> PTE_Check =
- if b then PTE_Check_Success(()) else PTE_Check_Failure((), ())
-
-/* For extensions: this function gets the extension-available bits of the PTE in extPte,
- * and the accumulated information of the page-table-walk in ext_ptw. It should return
- * the updated ext_ptw in both the success and failure cases.
- */
-function checkPTEPermission(ac : AccessType(ext_access_type), priv : Privilege, mxr : bool, do_sum : bool, p : PTE_Bits, ext : extPte, ext_ptw : ext_ptw) -> PTE_Check = {
- match (ac, priv) {
- (Read(_), User) => to_pte_check(p.U() == 0b1 & (p.R() == 0b1 | (p.X() == 0b1 & mxr))),
- (Write(_), User) => to_pte_check(p.U() == 0b1 & p.W() == 0b1),
- (ReadWrite(_, _), User) => to_pte_check(p.U() == 0b1 & p.W() == 0b1 & (p.R() == 0b1 | (p.X() == 0b1 & mxr))),
- (Execute(), User) => to_pte_check(p.U() == 0b1 & p.X() == 0b1),
-
- (Read(_), Supervisor) => to_pte_check((p.U() == 0b0 | do_sum) & (p.R() == 0b1 | (p.X() == 0b1 & mxr))),
- (Write(_), Supervisor) => to_pte_check((p.U() == 0b0 | do_sum) & p.W() == 0b1),
- (ReadWrite(_, _), Supervisor) => to_pte_check((p.U() == 0b0 | do_sum) & p.W() == 0b1 & (p.R() == 0b1 | (p.X() == 0b1 & mxr))),
- (Execute(), Supervisor) => to_pte_check(p.U() == 0b0 & p.X() == 0b1),
-
- (_, Machine) => internal_error(__FILE__, __LINE__, "m-mode mem perm check")
- }
-}
-
-function update_PTE_Bits(p : PTE_Bits, a : AccessType(ext_access_type), ext : extPte) -> option((PTE_Bits, extPte)) = {
- let update_d = p.D() == 0b0 & (match a { // dirty-bit
- Execute() => false,
- Read() => false,
- Write(_) => true,
- ReadWrite(_,_) => true
- });
-
- let update_a = p.A() == 0b0; // accessed-bit
- if update_d | update_a then {
- let np = update_A(p, 0b1);
- let np = if update_d then update_D(np, 0b1) else np;
- Some(np, ext)
- } else None()
-}
diff --git a/model/riscv_ptw.sail b/model/riscv_ptw.sail
deleted file mode 100644
index 2b7ef45..0000000
--- a/model/riscv_ptw.sail
+++ /dev/null
@@ -1,121 +0,0 @@
-/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
-/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=======================================================================================*/
-
-/* failure modes for address-translation/page-table-walks */
-
-union PTW_Error = {
- PTW_Invalid_Addr : unit, /* invalid source address */
- PTW_Access : unit, /* physical memory access error for a PTE */
- PTW_Invalid_PTE : unit,
- PTW_No_Permission : unit,
- PTW_Misaligned : unit, /* misaligned superpage */
- PTW_PTE_Update : unit, /* PTE update needed but not enabled */
- PTW_Ext_Error : ext_ptw_error /* parameterized for errors from extensions */
-}
-
-val ptw_error_to_str : PTW_Error -> string
-function ptw_error_to_str(e) =
- match (e) {
- PTW_Invalid_Addr() => "invalid-source-addr",
- PTW_Access() => "mem-access-error",
- PTW_Invalid_PTE() => "invalid-pte",
- PTW_No_Permission() => "no-permission",
- PTW_Misaligned() => "misaligned-superpage",
- PTW_PTE_Update() => "pte-update-needed",
- PTW_Ext_Error(e) => "extension-error"
- }
-
-overload to_str = {ptw_error_to_str}
-
-/* hook for extensions to customize errors reported by page-table
- * walks during address translation; it typically works in conjunction
- * with any customization to checkPTEPermission().
- */
-function ext_get_ptw_error(eptwf : ext_ptw_fail) -> PTW_Error =
- PTW_No_Permission()
-
-/* conversion of these translation/PTW failures into architectural exceptions */
-function translationException(a : AccessType(ext_access_type), f : PTW_Error) -> ExceptionType = {
- let e : ExceptionType =
- match (a, f) {
- (_, PTW_Ext_Error(e)) => E_Extension(ext_translate_exception(e)),
- (ReadWrite(_), PTW_Access()) => E_SAMO_Access_Fault(),
- (ReadWrite(_), _) => E_SAMO_Page_Fault(),
- (Read(_), PTW_Access()) => E_Load_Access_Fault(),
- (Read(_), _) => E_Load_Page_Fault(),
- (Write(_), PTW_Access()) => E_SAMO_Access_Fault(),
- (Write(_), _) => E_SAMO_Page_Fault(),
- (Execute(), PTW_Access()) => E_Fetch_Access_Fault(),
- (Execute(), _) => E_Fetch_Page_Fault()
- } in {
-/* print_mem("translationException(" ^ a ^ ", " ^ f ^ ") -> " ^ e); */
- e
- }
-}
diff --git a/model/riscv_reg_type.sail b/model/riscv_reg_type.sail
index d338207..b4a9a08 100644
--- a/model/riscv_reg_type.sail
+++ b/model/riscv_reg_type.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* default register type */
diff --git a/model/riscv_regs.sail b/model/riscv_regs.sail
index 15e7613..64002fa 100644
--- a/model/riscv_regs.sail
+++ b/model/riscv_regs.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* program counter */
@@ -154,8 +92,8 @@ function rX r = {
$ifdef RVFI_DII
val rvfi_wX : forall 'n, 0 <= 'n < 32. (regno('n), xlenbits) -> unit
function rvfi_wX (r,v) = {
- rvfi_int_data->rvfi_rd_wdata() = zero_extend(v);
- rvfi_int_data->rvfi_rd_addr() = to_bits(8,r);
+ rvfi_int_data[rvfi_rd_wdata] = zero_extend(v);
+ rvfi_int_data[rvfi_rd_addr] = to_bits(8,r);
rvfi_int_data_present = true;
}
$else
@@ -204,7 +142,7 @@ function wX (r, in_v) = {
if (r != 0) then {
rvfi_wX(r, in_v);
if get_config_print_reg()
- then print_reg("x" ^ string_of_int(r) ^ " <- " ^ RegStr(v));
+ then print_reg("x" ^ dec_str(r) ^ " <- " ^ RegStr(v));
}
}
diff --git a/model/riscv_softfloat_interface.sail b/model/riscv_softfloat_interface.sail
index 3e5e7e0..3a673fe 100644
--- a/model/riscv_softfloat_interface.sail
+++ b/model/riscv_softfloat_interface.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* **************************************************************** */
diff --git a/model/riscv_step.sail b/model/riscv_step.sail
index 550f11a..012f63b 100644
--- a/model/riscv_step.sail
+++ b/model/riscv_step.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* The emulator fetch-execute-interrupt dispatch loop. */
@@ -83,7 +21,7 @@ function step(step_no : int) -> bool = {
* written. See the note near the minstret declaration for more
* information.
*/
- minstret_increment = mcountinhibit.IR() == 0b0;
+ minstret_increment = mcountinhibit[IR] == 0b0;
let (retired, stepped) : (Retired, bool) =
match dispatchInterrupt(cur_privilege) {
@@ -113,7 +51,7 @@ function step(step_no : int) -> bool = {
let ast = ext_decode_compressed(h);
if get_config_print_instr()
then {
- print_instr("[" ^ string_of_int(step_no) ^ "] [" ^ to_str(cur_privilege) ^ "]: " ^ BitStr(PC) ^ " (" ^ BitStr(h) ^ ") " ^ to_str(ast));
+ print_instr("[" ^ dec_str(step_no) ^ "] [" ^ to_str(cur_privilege) ^ "]: " ^ BitStr(PC) ^ " (" ^ BitStr(h) ^ ") " ^ to_str(ast));
};
/* check for RVC once here instead of every RVC execute clause. */
if haveRVC() then {
@@ -129,7 +67,7 @@ function step(step_no : int) -> bool = {
let ast = ext_decode(w);
if get_config_print_instr()
then {
- print_instr("[" ^ string_of_int(step_no) ^ "] [" ^ to_str(cur_privilege) ^ "]: " ^ BitStr(PC) ^ " (" ^ BitStr(w) ^ ") " ^ to_str(ast));
+ print_instr("[" ^ dec_str(step_no) ^ "] [" ^ to_str(cur_privilege) ^ "]: " ^ BitStr(PC) ^ " (" ^ BitStr(w) ^ ") " ^ to_str(ast));
};
nextPC = PC + 4;
(execute(ast), true)
diff --git a/model/riscv_step_common.sail b/model/riscv_step_common.sail
index 2e81035..5384e5b 100644
--- a/model/riscv_step_common.sail
+++ b/model/riscv_step_common.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* The result of a fetch, which includes any possible error
diff --git a/model/riscv_step_ext.sail b/model/riscv_step_ext.sail
index 2232c72..b8c82b7 100644
--- a/model/riscv_step_ext.sail
+++ b/model/riscv_step_ext.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* The default implementation of hooks for the step() and main() functions. */
diff --git a/model/riscv_step_rvfi.sail b/model/riscv_step_rvfi.sail
index d23a679..caa0d8d 100644
--- a/model/riscv_step_rvfi.sail
+++ b/model/riscv_step_rvfi.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Step hooks for rvfi. */
diff --git a/model/riscv_sync_exception.sail b/model/riscv_sync_exception.sail
index 65ce95f..48efdb7 100644
--- a/model/riscv_sync_exception.sail
+++ b/model/riscv_sync_exception.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* model context for synchronous exceptions, parameterized for extensions */
diff --git a/model/riscv_sys_control.sail b/model/riscv_sys_control.sail
index 3830725..ecc53ae 100644
--- a/model/riscv_sys_control.sail
+++ b/model/riscv_sys_control.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Machine-mode and supervisor-mode functionality. */
@@ -102,29 +40,14 @@ function is_CSR_defined (csr : csreg, p : Privilege) -> bool =
0x343 => p == Machine, // mtval
0x344 => p == Machine, // mip
- 0x3A0 => p == Machine, // pmpcfg0
- 0x3A1 => p == Machine & (sizeof(xlen) == 32), // pmpcfg1
- 0x3A2 => p == Machine, // pmpcfg2
- 0x3A3 => p == Machine & (sizeof(xlen) == 32), // pmpcfg3
-
- 0x3B0 => p == Machine, // pmpaddr0
- 0x3B1 => p == Machine, // pmpaddr1
- 0x3B2 => p == Machine, // pmpaddr2
- 0x3B3 => p == Machine, // pmpaddr3
- 0x3B4 => p == Machine, // pmpaddr4
- 0x3B5 => p == Machine, // pmpaddr5
- 0x3B6 => p == Machine, // pmpaddr6
- 0x3B7 => p == Machine, // pmpaddr7
- 0x3B8 => p == Machine, // pmpaddr8
- 0x3B9 => p == Machine, // pmpaddr9
- 0x3BA => p == Machine, // pmpaddrA
- 0x3BB => p == Machine, // pmpaddrB
- 0x3BC => p == Machine, // pmpaddrC
- 0x3BD => p == Machine, // pmpaddrD
- 0x3BE => p == Machine, // pmpaddrE
- 0x3BF => p == Machine, // pmpaddrF
-
- /* counters */
+ // pmpcfgN
+ 0x3A @ idx : bits(4) => p == Machine & sys_pmp_count() > unsigned(idx) & (idx[0] == bitzero | sizeof(xlen) == 32),
+
+ // pmpaddrN. Unfortunately the PMP index does not nicely align with the CSR index bits.
+ 0x3B @ idx : bits(4) => p == Machine & sys_pmp_count() > unsigned(0b00 @ idx),
+ 0x3C @ idx : bits(4) => p == Machine & sys_pmp_count() > unsigned(0b01 @ idx),
+ 0x3D @ idx : bits(4) => p == Machine & sys_pmp_count() > unsigned(0b10 @ idx),
+ 0x3E @ idx : bits(4) => p == Machine & sys_pmp_count() > unsigned(0b11 @ idx),
0xB00 => p == Machine, // mcycle
0xB02 => p == Machine, // minstret
@@ -175,17 +98,17 @@ function check_CSR_access(csrrw, csrpr, p, isWrite) =
& (privLevel_to_bits(p) >=_u csrpr) /* privilege */
function check_TVM_SATP(csr : csreg, p : Privilege) -> bool =
- not(csr == 0x180 & p == Supervisor & mstatus.TVM() == 0b1)
+ not(csr == 0x180 & p == Supervisor & mstatus[TVM] == 0b1)
function check_Counteren(csr : csreg, p : Privilege) -> bool =
match(csr, p) {
- (0xC00, Supervisor) => mcounteren.CY() == 0b1,
- (0xC01, Supervisor) => mcounteren.TM() == 0b1,
- (0xC02, Supervisor) => mcounteren.IR() == 0b1,
+ (0xC00, Supervisor) => mcounteren[CY] == 0b1,
+ (0xC01, Supervisor) => mcounteren[TM] == 0b1,
+ (0xC02, Supervisor) => mcounteren[IR] == 0b1,
- (0xC00, User) => mcounteren.CY() == 0b1 & (not(haveSupMode()) | scounteren.CY() == 0b1),
- (0xC01, User) => mcounteren.TM() == 0b1 & (not(haveSupMode()) | scounteren.TM() == 0b1),
- (0xC02, User) => mcounteren.IR() == 0b1 & (not(haveSupMode()) | scounteren.IR() == 0b1),
+ (0xC00, User) => mcounteren[CY] == 0b1 & (not(haveSupMode()) | scounteren[CY] == 0b1),
+ (0xC01, User) => mcounteren[TM] == 0b1 & (not(haveSupMode()) | scounteren[TM] == 0b1),
+ (0xC02, User) => mcounteren[IR] == 0b1 & (not(haveSupMode()) | scounteren[IR] == 0b1),
(_, _) => /* no HPM counters for now */
if 0xC03 <=_u csr & csr <=_u 0xC1F
@@ -242,10 +165,10 @@ val cancel_reservation = {ocaml: "Platform.cancel_reservation", interpreter: "Pl
*/
function exception_delegatee(e : ExceptionType, p : Privilege) -> Privilege = {
let idx = num_of_ExceptionType(e);
- let super = bit_to_bool(medeleg.bits()[idx]);
+ let super = bit_to_bool(medeleg.bits[idx]);
/* if S-mode is absent, medeleg delegates to U-mode if 'N' is supported. */
let user = if haveSupMode()
- then super & haveNExt() & bit_to_bool(sedeleg.bits()[idx])
+ then super & haveNExt() & bit_to_bool(sedeleg.bits[idx])
else super & haveNExt();
let deleg = if haveUsrMode() & user then User
else if haveSupMode() & super then Supervisor
@@ -260,15 +183,15 @@ function exception_delegatee(e : ExceptionType, p : Privilege) -> Privilege = {
*/
function findPendingInterrupt(ip : xlenbits) -> option(InterruptType) = {
let ip = Mk_Minterrupts(ip);
- if ip.MEI() == 0b1 then Some(I_M_External)
- else if ip.MSI() == 0b1 then Some(I_M_Software)
- else if ip.MTI() == 0b1 then Some(I_M_Timer)
- else if ip.SEI() == 0b1 then Some(I_S_External)
- else if ip.SSI() == 0b1 then Some(I_S_Software)
- else if ip.STI() == 0b1 then Some(I_S_Timer)
- else if ip.UEI() == 0b1 then Some(I_U_External)
- else if ip.USI() == 0b1 then Some(I_U_Software)
- else if ip.UTI() == 0b1 then Some(I_U_Timer)
+ if ip[MEI] == 0b1 then Some(I_M_External)
+ else if ip[MSI] == 0b1 then Some(I_M_Software)
+ else if ip[MTI] == 0b1 then Some(I_M_Timer)
+ else if ip[SEI] == 0b1 then Some(I_S_External)
+ else if ip[SSI] == 0b1 then Some(I_S_Software)
+ else if ip[STI] == 0b1 then Some(I_S_Timer)
+ else if ip[UEI] == 0b1 then Some(I_U_External)
+ else if ip[USI] == 0b1 then Some(I_U_Software)
+ else if ip[UTI] == 0b1 then Some(I_U_Timer)
else None()
}
@@ -285,9 +208,9 @@ union interrupt_set = {
function processPending(xip : Minterrupts, xie : Minterrupts, xideleg : xlenbits,
priv_enabled : bool) -> interrupt_set = {
/* interrupts that are enabled but not delegated are pending */
- let effective_pend = xip.bits() & xie.bits() & (~ (xideleg));
+ let effective_pend = xip.bits & xie.bits & (~ (xideleg));
/* the others are delegated */
- let effective_delg = xip.bits() & xideleg;
+ let effective_delg = xip.bits & xideleg;
/* we have pending interrupts if this privilege is enabled */
if priv_enabled & (effective_pend != zero_extend(0b0))
then Ints_Pending(effective_pend)
@@ -305,17 +228,17 @@ function processPending(xip : Minterrupts, xie : Minterrupts, xideleg : xlenbits
*/
function getPendingSet(priv : Privilege) -> option((xlenbits, Privilege)) = {
assert(haveUsrMode(), "no user mode: M/U or M/S/U system required");
- let effective_pending = mip.bits() & mie.bits();
+ let effective_pending = mip.bits & mie.bits;
if effective_pending == zero_extend(0b0) then None() /* fast path */
else {
/* Higher privileges than the current one are implicitly enabled,
* while lower privileges are blocked. An unsupported privilege is
* considered blocked.
*/
- let mIE = priv != Machine | (priv == Machine & mstatus.MIE() == 0b1);
- let sIE = haveSupMode() & (priv == User | (priv == Supervisor & mstatus.SIE() == 0b1));
- let uIE = haveNExt() & (priv == User & mstatus.UIE() == 0b1);
- match processPending(mip, mie, mideleg.bits(), mIE) {
+ let mIE = priv != Machine | (priv == Machine & mstatus[MIE] == 0b1);
+ let sIE = haveSupMode() & (priv == User | (priv == Supervisor & mstatus[SIE] == 0b1));
+ let uIE = haveNExt() & (priv == User & mstatus[UIE] == 0b1);
+ match processPending(mip, mie, mideleg.bits, mIE) {
Ints_Empty() => None(),
Ints_Pending(p) => let r = (p, Machine) in Some(r),
Ints_Delegated(d) =>
@@ -324,7 +247,7 @@ function getPendingSet(priv : Privilege) -> option((xlenbits, Privilege)) = {
else None()
} else {
/* the delegated bits are pending for S-mode */
- match processPending(Mk_Minterrupts(d), mie, sideleg.bits(), sIE) {
+ match processPending(Mk_Minterrupts(d), mie, sideleg.bits, sIE) {
Ints_Empty() => None(),
Ints_Pending(p) => let r = (p, Supervisor) in Some(r),
Ints_Delegated(d) => if uIE
@@ -345,7 +268,7 @@ function dispatchInterrupt(priv : Privilege) -> option((InterruptType, Privilege
*/
if not(haveUsrMode()) | (not(haveSupMode()) & not(haveNExt())) then {
assert(priv == Machine, "invalid current privilege");
- let enabled_pending = mip.bits() & mie.bits();
+ let enabled_pending = mip.bits & mie.bits;
match findPendingInterrupt(enabled_pending) {
Some(i) => let r = (i, Machine) in Some(r),
None() => None()
@@ -383,7 +306,7 @@ $ifdef RVFI_DII
val rvfi_trap : unit -> unit
// TODO: record rvfi_trap_data
function rvfi_trap () =
- rvfi_inst_data->rvfi_trap() = 0x01
+ rvfi_inst_data[rvfi_trap] = 0x01
$else
val rvfi_trap : unit -> unit
function rvfi_trap () = ()
@@ -403,12 +326,12 @@ function trap_handler(del_priv : Privilege, intr : bool, c : exc_code, pc : xlen
match (del_priv) {
Machine => {
- mcause->IsInterrupt() = bool_to_bits(intr);
- mcause->Cause() = zero_extend(c);
+ mcause[IsInterrupt] = bool_to_bits(intr);
+ mcause[Cause] = zero_extend(c);
- mstatus->MPIE() = mstatus.MIE();
- mstatus->MIE() = 0b0;
- mstatus->MPP() = privLevel_to_bits(cur_privilege);
+ mstatus[MPIE] = mstatus[MIE];
+ mstatus[MIE] = 0b0;
+ mstatus[MPP] = privLevel_to_bits(cur_privilege);
mtval = tval(info);
mepc = pc;
@@ -417,19 +340,19 @@ function trap_handler(del_priv : Privilege, intr : bool, c : exc_code, pc : xlen
handle_trap_extension(del_priv, pc, ext);
if get_config_print_reg()
- then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits()));
+ then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits));
prepare_trap_vector(del_priv, mcause)
},
Supervisor => {
assert (haveSupMode(), "no supervisor mode present for delegation");
- scause->IsInterrupt() = bool_to_bits(intr);
- scause->Cause() = zero_extend(c);
+ scause[IsInterrupt] = bool_to_bits(intr);
+ scause[Cause] = zero_extend(c);
- mstatus->SPIE() = mstatus.SIE();
- mstatus->SIE() = 0b0;
- mstatus->SPP() = match cur_privilege {
+ mstatus[SPIE] = mstatus[SIE];
+ mstatus[SIE] = 0b0;
+ mstatus[SPP] = match cur_privilege {
User => 0b0,
Supervisor => 0b1,
Machine => internal_error(__FILE__, __LINE__, "invalid privilege for s-mode trap")
@@ -442,18 +365,18 @@ function trap_handler(del_priv : Privilege, intr : bool, c : exc_code, pc : xlen
handle_trap_extension(del_priv, pc, ext);
if get_config_print_reg()
- then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits()));
+ then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits));
prepare_trap_vector(del_priv, scause)
},
User => {
assert(haveUsrMode(), "no user mode present for delegation");
- ucause->IsInterrupt() = bool_to_bits(intr);
- ucause->Cause() = zero_extend(c);
+ ucause[IsInterrupt] = bool_to_bits(intr);
+ ucause[Cause] = zero_extend(c);
- mstatus->UPIE() = mstatus.UIE();
- mstatus->UIE() = 0b0;
+ mstatus[UPIE] = mstatus[UIE];
+ mstatus[UIE] = 0b0;
utval = tval(info);
uepc = pc;
@@ -462,7 +385,7 @@ function trap_handler(del_priv : Privilege, intr : bool, c : exc_code, pc : xlen
handle_trap_extension(del_priv, pc, ext);
if get_config_print_reg()
- then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits()));
+ then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits));
prepare_trap_vector(del_priv, ucause)
}
@@ -481,15 +404,15 @@ function exception_handler(cur_priv : Privilege, ctl : ctl_result,
},
(_, CTL_MRET()) => {
let prev_priv = cur_privilege;
- mstatus->MIE() = mstatus.MPIE();
- mstatus->MPIE() = 0b1;
- cur_privilege = privLevel_of_bits(mstatus.MPP());
- mstatus->MPP() = privLevel_to_bits(if haveUsrMode() then User else Machine);
+ mstatus[MIE] = mstatus[MPIE];
+ mstatus[MPIE] = 0b1;
+ cur_privilege = privLevel_of_bits(mstatus[MPP]);
+ mstatus[MPP] = privLevel_to_bits(if haveUsrMode() then User else Machine);
if cur_privilege != Machine
- then mstatus->MPRV() = 0b0;
+ then mstatus[MPRV] = 0b0;
if get_config_print_reg()
- then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits()));
+ then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits));
if get_config_print_platform()
then print_platform("ret-ing from " ^ to_str(prev_priv) ^ " to " ^ to_str(cur_privilege));
@@ -498,15 +421,15 @@ function exception_handler(cur_priv : Privilege, ctl : ctl_result,
},
(_, CTL_SRET()) => {
let prev_priv = cur_privilege;
- mstatus->SIE() = mstatus.SPIE();
- mstatus->SPIE() = 0b1;
- cur_privilege = if mstatus.SPP() == 0b1 then Supervisor else User;
- mstatus->SPP() = 0b0;
+ mstatus[SIE] = mstatus[SPIE];
+ mstatus[SPIE] = 0b1;
+ cur_privilege = if mstatus[SPP] == 0b1 then Supervisor else User;
+ mstatus[SPP] = 0b0;
if cur_privilege != Machine
- then mstatus->MPRV() = 0b0;
+ then mstatus[MPRV] = 0b0;
if get_config_print_reg()
- then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits()));
+ then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits));
if get_config_print_platform()
then print_platform("ret-ing from " ^ to_str(prev_priv)
^ " to " ^ to_str(cur_privilege));
@@ -516,12 +439,12 @@ function exception_handler(cur_priv : Privilege, ctl : ctl_result,
},
(_, CTL_URET()) => {
let prev_priv = cur_privilege;
- mstatus->UIE() = mstatus.UPIE();
- mstatus->UPIE() = 0b1;
+ mstatus[UIE] = mstatus[UPIE];
+ mstatus[UPIE] = 0b1;
cur_privilege = User;
if get_config_print_reg()
- then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits()));
+ then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits));
if get_config_print_platform()
then print_platform("ret-ing from " ^ to_str(prev_priv) ^ " to " ^ to_str(cur_privilege));
@@ -555,40 +478,40 @@ function init_sys() -> unit = {
mhartid = zero_extend(0b0);
- misa->MXL() = arch_to_bits(if sizeof(xlen) == 32 then RV32 else RV64);
- misa->A() = 0b1; /* atomics */
- misa->C() = bool_to_bits(sys_enable_rvc()); /* RVC */
- misa->I() = 0b1; /* base integer ISA */
- misa->M() = 0b1; /* integer multiply/divide */
- misa->U() = 0b1; /* user-mode */
- misa->S() = 0b1; /* supervisor-mode */
- misa->V() = bool_to_bits(sys_enable_vext()); /* vector extension */
+ misa[MXL] = arch_to_bits(if sizeof(xlen) == 32 then RV32 else RV64);
+ misa[A] = 0b1; /* atomics */
+ misa[C] = bool_to_bits(sys_enable_rvc()); /* RVC */
+ misa[I] = 0b1; /* base integer ISA */
+ misa[M] = 0b1; /* integer multiply/divide */
+ misa[U] = 0b1; /* user-mode */
+ misa[S] = 0b1; /* supervisor-mode */
+ misa[V] = bool_to_bits(sys_enable_vext()); /* vector extension */
if sys_enable_fdext() & sys_enable_zfinx()
then internal_error(__FILE__, __LINE__, "F and Zfinx cannot both be enabled!");
/* We currently support both F and D */
- misa->F() = bool_to_bits(sys_enable_fdext()); /* single-precision */
- misa->D() = if sizeof(flen) >= 64
+ misa[F] = bool_to_bits(sys_enable_fdext()); /* single-precision */
+ misa[D] = if sizeof(flen) >= 64
then bool_to_bits(sys_enable_fdext()) /* double-precision */
else 0b0;
- mstatus = set_mstatus_SXL(mstatus, misa.MXL());
- mstatus = set_mstatus_UXL(mstatus, misa.MXL());
- mstatus->SD() = 0b0;
+ mstatus = set_mstatus_SXL(mstatus, misa[MXL]);
+ mstatus = set_mstatus_UXL(mstatus, misa[MXL]);
+ mstatus[SD] = 0b0;
/* set to little-endian mode */
if sizeof(xlen) == 64 then {
- mstatus = Mk_Mstatus([mstatus.bits() with 37 .. 36 = 0b00])
+ mstatus = Mk_Mstatus([mstatus.bits with 37 .. 36 = 0b00])
};
- mstatush->bits() = zero_extend(0b0);
-
- mip->bits() = zero_extend(0b0);
- mie->bits() = zero_extend(0b0);
- mideleg->bits() = zero_extend(0b0);
- medeleg->bits() = zero_extend(0b0);
- mtvec->bits() = zero_extend(0b0);
- mcause->bits() = zero_extend(0b0);
+ mstatush.bits = zero_extend(0b0);
+
+ mip.bits = zero_extend(0b0);
+ mie.bits = zero_extend(0b0);
+ mideleg.bits = zero_extend(0b0);
+ medeleg.bits = zero_extend(0b0);
+ mtvec.bits = zero_extend(0b0);
+ mcause.bits = zero_extend(0b0);
mepc = zero_extend(0b0);
mtval = zero_extend(0b0);
mscratch = zero_extend(0b0);
@@ -596,13 +519,13 @@ function init_sys() -> unit = {
mcycle = zero_extend(0b0);
mtime = zero_extend(0b0);
- mcounteren->bits() = zero_extend(0b0);
+ mcounteren.bits = zero_extend(0b0);
minstret = zero_extend(0b0);
minstret_increment = true;
- menvcfg->bits() = zero_extend(0b0);
- senvcfg->bits() = zero_extend(0b0);
+ menvcfg.bits = zero_extend(0b0);
+ senvcfg.bits = zero_extend(0b0);
/* initialize vector csrs */
elen = 0b1; /* ELEN=64 as the common case */
vlen = 0b0100; /* VLEN=512 as a default value */
@@ -613,21 +536,22 @@ function init_sys() -> unit = {
vstart = zero_extend(0b0);
vxsat = 0b0;
vxrm = 0b00;
- vcsr->vxrm() = vxrm;
- vcsr->vxsat() = vxsat;
+ vcsr[vxrm] = vxrm;
+ vcsr[vxsat] = vxsat;
vl = zero_extend(0b0);
- vtype->vill() = 0b1;
- vtype->reserved() = zero_extend(0b0);
- vtype->vma() = 0b0;
- vtype->vta() = 0b0;
- vtype->vsew() = 0b000;
- vtype->vlmul() = 0b000;
-
+ vtype[vill] = 0b1;
+ vtype[reserved] = zero_extend(0b0);
+ vtype[vma] = 0b0;
+ vtype[vta] = 0b0;
+ vtype[vsew] = 0b000;
+ vtype[vlmul] = 0b000;
+
+ // PMP's L and A fields are set to 0 on reset.
init_pmp();
// log compatibility with spike
if get_config_print_reg()
- then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits()) ^ " (input: " ^ BitStr(zero_extend(0b0) : xlenbits) ^ ")")
+ then print_reg("CSR mstatus <- " ^ BitStr(mstatus.bits) ^ " (input: " ^ BitStr(zero_extend(0b0) : xlenbits) ^ ")")
}
/* memory access exceptions, defined here for use by the platform model. */
diff --git a/model/riscv_sys_exceptions.sail b/model/riscv_sys_exceptions.sail
index 14cc05c..0059e2a 100644
--- a/model/riscv_sys_exceptions.sail
+++ b/model/riscv_sys_exceptions.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* default exception model */
@@ -125,25 +63,25 @@ function prepare_xret_target(p) =
/* other trap-related CSRs */
function get_mtvec() -> xlenbits =
- mtvec.bits()
+ mtvec.bits
function get_stvec() -> xlenbits =
- stvec.bits()
+ stvec.bits
function get_utvec() -> xlenbits =
- utvec.bits()
+ utvec.bits
function set_mtvec(value : xlenbits) -> xlenbits = {
mtvec = legalize_tvec(mtvec, value);
- mtvec.bits()
+ mtvec.bits
}
function set_stvec(value : xlenbits) -> xlenbits = {
stvec = legalize_tvec(stvec, value);
- stvec.bits()
+ stvec.bits
}
function set_utvec(value : xlenbits) -> xlenbits = {
utvec = legalize_tvec(utvec, value);
- utvec.bits()
+ utvec.bits
}
diff --git a/model/riscv_sys_regs.sail b/model/riscv_sys_regs.sail
index f472ca2..3e198b4 100644
--- a/model/riscv_sys_regs.sail
+++ b/model/riscv_sys_regs.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Machine-mode and supervisor-mode state definitions. */
@@ -146,6 +84,8 @@ val sys_enable_writable_misa = {c: "sys_enable_writable_misa", ocaml: "Platform.
val sys_enable_rvc = {c: "sys_enable_rvc", ocaml: "Platform.enable_rvc", _: "sys_enable_rvc"} : unit -> bool
/* whether misa.{f,d} were enabled at boot */
val sys_enable_fdext = {c: "sys_enable_fdext", ocaml: "Platform.enable_fdext", _: "sys_enable_fdext"} : unit -> bool
+/* whether Zcb was enabled at boot */
+val sys_enable_zcb = {c: "sys_enable_zcb", ocaml: "Platform.enable_zcb", _: "sys_enable_zcb"} : unit -> bool
/* whether zfinx was enabled at boot */
val sys_enable_zfinx = {c: "sys_enable_zfinx", ocaml: "Platform.enable_zfinx", _: "sys_enable_zfinx"} : unit -> bool
/* whether the N extension was enabled at boot */
@@ -153,6 +93,13 @@ val sys_enable_next = {c: "sys_enable_next", ocaml: "Platform.enable_next", _: "
/* Whether FIOM bit of menvcfg/senvcfg is enabled. It must be enabled if
supervisor mode is implemented and non-bare addressing modes are supported. */
val sys_enable_writable_fiom = {c: "sys_enable_writable_fiom", ocaml: "Platform.enable_writable_fiom", _: "sys_enable_writable_fiom"} : unit -> bool
+
+/* How many PMP entries are implemented. This must be 0, 16 or 64 (this is checked at runtime). */
+val sys_pmp_count = {c: "sys_pmp_count", ocaml: "Platform.pmp_count", _: "sys_pmp_count"} : unit -> range(0, 64)
+/* G parameter that specifies the PMP grain size. The grain size is 2^(G+2), e.g.
+ G=0 -> 4 bytes, G=10 -> 4096 bytes. */
+val sys_pmp_grain = {c: "sys_pmp_grain", ocaml: "Platform.pmp_grain", _: "sys_pmp_grain"} : unit -> range(0, 63)
+
/* whether misa.v was enabled at boot */
val sys_enable_vext = {c: "sys_enable_vext", ocaml: "Platform.enable_vext", _: "sys_enable_vext"} : unit -> bool
@@ -164,26 +111,26 @@ val ext_veto_disable_C : unit -> bool
function legalize_misa(m : Misa, v : xlenbits) -> Misa = {
let v = Mk_Misa(v);
/* Suppress updates to MISA if MISA is not writable or if by disabling C next PC would become misaligned or an extension vetoes */
- if not(sys_enable_writable_misa()) | (v.C() == 0b0 & (nextPC[1] == bitone | ext_veto_disable_C()))
+ if not(sys_enable_writable_misa()) | (v[C] == 0b0 & (nextPC[1] == bitone | ext_veto_disable_C()))
then m
else {
/* Suppress enabling C if C was disabled at boot (i.e. not supported) */
- let m = if not(sys_enable_rvc()) then m else update_C(m, v.C());
+ let m = if not(sys_enable_rvc()) then m else [m with C = v[C]];
/* Suppress updates to misa.{f,d} if disabled at boot */
if not(sys_enable_fdext())
then m
- else update_D(update_F(m, v.F()), v.D() & v.F())
+ else [m with F = v[F], D = v[D] & v[F]]
}
}
/* helpers to check support for various extensions. */
/* we currently don't model 'E', so always assume 'I'. */
-function haveAtomics() -> bool = misa.A() == 0b1
-function haveRVC() -> bool = misa.C() == 0b1
-function haveMulDiv() -> bool = misa.M() == 0b1
-function haveSupMode() -> bool = misa.S() == 0b1
-function haveUsrMode() -> bool = misa.U() == 0b1
-function haveNExt() -> bool = misa.N() == 0b1
+function haveAtomics() -> bool = misa[A] == 0b1
+function haveRVC() -> bool = misa[C] == 0b1
+function haveMulDiv() -> bool = misa[M] == 0b1
+function haveSupMode() -> bool = misa[S] == 0b1
+function haveUsrMode() -> bool = misa[U] == 0b1
+function haveNExt() -> bool = misa[N] == 0b1
/* see below for F and D (and Z*inx counterparts) extension tests */
/* BitManip extension support. */
@@ -260,21 +207,21 @@ bitfield Mstatus : xlenbits = {
register mstatus : Mstatus
function effectivePrivilege(t : AccessType(ext_access_type), m : Mstatus, priv : Privilege) -> Privilege =
- if t != Execute() & m.MPRV() == 0b1
- then privLevel_of_bits(m.MPP())
+ if t != Execute() & m[MPRV] == 0b1
+ then privLevel_of_bits(m[MPP])
else priv
function get_mstatus_SXL(m : Mstatus) -> arch_xlen = {
if sizeof(xlen) == 32
then arch_to_bits(RV32)
- else m.bits()[35 .. 34]
+ else m.bits[35 .. 34]
}
function set_mstatus_SXL(m : Mstatus, a : arch_xlen) -> Mstatus = {
if sizeof(xlen) == 32
then m
else {
- let m = vector_update_subrange(m.bits(), 35, 34, a);
+ let m = vector_update_subrange(m.bits, 35, 34, a);
Mk_Mstatus(m)
}
}
@@ -282,14 +229,14 @@ function set_mstatus_SXL(m : Mstatus, a : arch_xlen) -> Mstatus = {
function get_mstatus_UXL(m : Mstatus) -> arch_xlen = {
if sizeof(xlen) == 32
then arch_to_bits(RV32)
- else m.bits()[33 .. 32]
+ else m.bits[33 .. 32]
}
function set_mstatus_UXL(m : Mstatus, a : arch_xlen) -> Mstatus = {
if sizeof(xlen) == 32
then m
else {
- let m = vector_update_subrange(m.bits(), 33, 32, a);
+ let m = vector_update_subrange(m.bits, 33, 32, a);
Mk_Mstatus(m)
}
}
@@ -303,17 +250,17 @@ function legalize_mstatus(o : Mstatus, v : xlenbits) -> Mstatus = {
let m : Mstatus = Mk_Mstatus(zero_extend(v[22 .. 7] @ 0b0 @ v[5 .. 3] @ 0b0 @ v[1 .. 0]));
/* We don't have any extension context yet. */
- let m = update_XS(m, extStatus_to_bits(Off));
+ let m = [m with XS = extStatus_to_bits(Off)];
/* FS is WARL, and making FS writable can support the M-mode emulation of an FPU
* to support code running in S/U-modes. Spike does this, and for now, we match it,
* but only if Zfinx isn't enabled.
* FIXME: This should be made a platform parameter.
*/
- let m = if sys_enable_zfinx() then update_FS(m, extStatus_to_bits(Off)) else m;
- let dirty = extStatus_of_bits(m.FS()) == Dirty | extStatus_of_bits(m.XS()) == Dirty |
- extStatus_of_bits(m.VS()) == Dirty;
- let m = update_SD(m, bool_to_bits(dirty));
+ let m = if sys_enable_zfinx() then [m with FS = extStatus_to_bits(Off)] else m;
+ let dirty = extStatus_of_bits(m[FS]) == Dirty | extStatus_of_bits(m[XS]) == Dirty |
+ extStatus_of_bits(m[VS]) == Dirty;
+ let m = [m with SD = bool_to_bits(dirty)];
/* We don't support dynamic changes to SXL and UXL. */
let m = set_mstatus_SXL(m, get_mstatus_SXL(o));
@@ -321,18 +268,18 @@ function legalize_mstatus(o : Mstatus, v : xlenbits) -> Mstatus = {
/* We don't currently support changing MBE and SBE. */
let m = if sizeof(xlen) == 64 then {
- Mk_Mstatus([m.bits() with 37 .. 36 = 0b00])
+ Mk_Mstatus([m.bits with 37 .. 36 = 0b00])
} else m;
/* Hardwired to zero in the absence of 'U' or 'N'. */
let m = if not(haveNExt()) then {
- let m = update_UPIE(m, 0b0);
- let m = update_UIE(m, 0b0);
+ let m = [m with UPIE = 0b0];
+ let m = [m with UIE = 0b0];
m
} else m;
if not(haveUsrMode()) then {
- let m = update_MPRV(m, 0b0);
+ let m = [m with MPRV = 0b0];
m
} else m
}
@@ -342,7 +289,7 @@ function legalize_mstatus(o : Mstatus, v : xlenbits) -> Mstatus = {
function cur_Architecture() -> Architecture = {
let a : arch_xlen =
match (cur_privilege) {
- Machine => misa.MXL(),
+ Machine => misa[MXL],
Supervisor => get_mstatus_SXL(mstatus),
User => get_mstatus_UXL(mstatus)
};
@@ -357,12 +304,15 @@ function in32BitMode() -> bool = {
}
/* F and D extensions have to enabled both via misa.{FD} as well as mstatus.FS */
-function haveFExt() -> bool = (misa.F() == 0b1) & (mstatus.FS() != 0b00)
-function haveDExt() -> bool = (misa.D() == 0b1) & (mstatus.FS() != 0b00)
+function haveFExt() -> bool = (misa[F] == 0b1) & (mstatus[FS] != 0b00)
+function haveDExt() -> bool = (misa[D] == 0b1) & (mstatus[FS] != 0b00) & sizeof(flen) >= 64
/* Zfh (half-precision) extension depends on misa.F and mstatus.FS */
-function haveZfh() -> bool = (misa.F() == 0b1) & (mstatus.FS() != 0b00)
+function haveZfh() -> bool = (misa[F] == 0b1) & (mstatus[FS] != 0b00)
/* V extension has to enable both via misa.V as well as mstatus.VS */
-function haveVExt() -> bool = (misa.V() == 0b1) & (mstatus.VS() != 0b00)
+function haveVExt() -> bool = (misa[V] == 0b1) & (mstatus[VS] != 0b00)
+
+/* Zcb has simple code-size saving instructions. (The Zcb extension depends on the Zca extension.) */
+function haveZcb() -> bool = sys_enable_zcb()
/* Zhinx, Zfinx and Zdinx extensions (TODO: gate FCSR access on [mhs]stateen0 bit 1 when implemented) */
function haveZhinx() -> bool = sys_enable_zfinx()
@@ -392,42 +342,32 @@ function legalize_mip(o : Minterrupts, v : xlenbits) -> Minterrupts = {
/* The only writable bits are the S-mode bits, and with the 'N'
* extension, the U-mode bits. */
let v = Mk_Minterrupts(v);
- let m = update_SEI(o, v.SEI());
- let m = update_STI(m, v.STI());
- let m = update_SSI(m, v.SSI());
+ let m = [o with SEI = v[SEI], STI = v[STI], SSI = v[SSI]];
if haveUsrMode() & haveNExt() then {
- let m = update_UEI(m, v.UEI());
- let m = update_UTI(m, v.UTI());
- let m = update_USI(m, v.USI());
- m
+ [m with UEI = v[UEI], UTI = v[UTI], USI = v[USI]]
} else m
}
function legalize_mie(o : Minterrupts, v : xlenbits) -> Minterrupts = {
let v = Mk_Minterrupts(v);
- let m = update_MEI(o, v.MEI());
- let m = update_MTI(m, v.MTI());
- let m = update_MSI(m, v.MSI());
- let m = update_SEI(m, v.SEI());
- let m = update_STI(m, v.STI());
- let m = update_SSI(m, v.SSI());
+ let m = [o with
+ MEI = v[MEI],
+ MTI = v[MTI],
+ MSI = v[MSI],
+ SEI = v[SEI],
+ STI = v[STI],
+ SSI = v[SSI]
+ ];
/* The U-mode bits will be modified if we have the 'N' extension. */
if haveUsrMode() & haveNExt() then {
- let m = update_UEI(m, v.UEI());
- let m = update_UTI(m, v.UTI());
- let m = update_USI(m, v.USI());
- m
+ [m with UEI = v[UEI], UTI = v[UTI], USI = v[USI]]
} else m
}
function legalize_mideleg(o : Minterrupts, v : xlenbits) -> Minterrupts = {
/* M-mode interrupt delegation bits "should" be hardwired to 0. */
/* FIXME: needs verification against eventual spec language. */
- let m = Mk_Minterrupts(v);
- let m = update_MEI(m, 0b0);
- let m = update_MTI(m, 0b0);
- let m = update_MSI(m, 0b0);
- m
+ [Mk_Minterrupts(v) with MEI = 0b0, MTI = 0b0, MSI = 0b0]
}
/* exception processing state */
@@ -436,7 +376,7 @@ bitfield Medeleg : xlenbits = {
SAMO_Page_Fault : 15,
Load_Page_Fault : 13,
Fetch_Page_Fault : 12,
- MEnvCall : 10,
+ MEnvCall : 11,
SEnvCall : 9,
UEnvCall : 8,
SAMO_Access_Fault : 7,
@@ -451,10 +391,8 @@ bitfield Medeleg : xlenbits = {
register medeleg : Medeleg /* Delegation to S-mode */
function legalize_medeleg(o : Medeleg, v : xlenbits) -> Medeleg = {
- let m = Mk_Medeleg(v);
/* M-EnvCalls delegation is not supported */
- let m = update_MEnvCall(m, 0b0);
- m
+ [Mk_Medeleg(v) with MEnvCall = 0b0]
}
/* registers for trap handling */
@@ -467,10 +405,10 @@ register mtvec : Mtvec /* Trap Vector */
function legalize_tvec(o : Mtvec, v : xlenbits) -> Mtvec = {
let v = Mk_Mtvec(v);
- match (trapVectorMode_of_bits(v.Mode())) {
+ match (trapVectorMode_of_bits(v[Mode])) {
TV_Direct => v,
TV_Vector => v,
- _ => update_Mode(v, o.Mode())
+ _ => [v with Mode = o[Mode]]
}
}
@@ -482,11 +420,11 @@ register mcause : Mcause
/* Interpreting the trap-vector address */
function tvec_addr(m : Mtvec, c : Mcause) -> option(xlenbits) = {
- let base : xlenbits = m.Base() @ 0b00;
- match (trapVectorMode_of_bits(m.Mode())) {
+ let base : xlenbits = m[Base] @ 0b00;
+ match (trapVectorMode_of_bits(m[Mode])) {
TV_Direct => Some(base),
- TV_Vector => if c.IsInterrupt() == 0b1
- then Some(base + (zero_extend(c.Cause()) << 2))
+ TV_Vector => if c[IsInterrupt] == 0b1
+ then Some(base + (zero_extend(c[Cause]) << 2))
else Some(base),
TV_Reserved => None()
}
@@ -502,13 +440,13 @@ register mepc : xlenbits
function legalize_xepc(v : xlenbits) -> xlenbits =
/* allow writing xepc[1] only if misa.C is enabled or could be enabled
XXX specification says this legalization should be done on read */
- if (sys_enable_writable_misa() & sys_enable_rvc()) | misa.C() == 0b1
+ if (sys_enable_writable_misa() & sys_enable_rvc()) | misa[C] == 0b1
then [v with 0 = bitzero]
else v & sign_extend(0b100)
/* masking for reads to xepc */
function pc_alignment_mask() -> xlenbits =
- ~(zero_extend(if misa.C() == 0b1 then 0b00 else 0b10))
+ ~(zero_extend(if misa[C] == 0b1 then 0b00 else 0b10))
/* auxiliary exception registers */
@@ -529,18 +467,12 @@ register scounteren : Counteren
function legalize_mcounteren(c : Counteren, v : xlenbits) -> Counteren = {
/* no HPM counters yet */
- let c = update_IR(c, [v[2]]);
- let c = update_TM(c, [v[1]]);
- let c = update_CY(c, [v[0]]);
- c
+ [c with IR = [v[2]], TM = [v[1]], CY = [v[0]]]
}
function legalize_scounteren(c : Counteren, v : xlenbits) -> Counteren = {
/* no HPM counters yet */
- let c = update_IR(c, [v[2]]);
- let c = update_TM(c, [v[1]]);
- let c = update_CY(c, [v[0]]);
- c
+ [c with IR = [v[2]], TM = [v[1]], CY = [v[0]]]
}
bitfield Counterin : bits(32) = {
@@ -551,9 +483,7 @@ bitfield Counterin : bits(32) = {
register mcountinhibit : Counterin
function legalize_mcountinhibit(c : Counterin, v : xlenbits) -> Counterin = {
- let c = update_IR(c, [v[2]]);
- let c = update_CY(c, [v[0]]);
- c
+ [c with IR = [v[2]], CY = [v[0]]]
}
register mcycle : bits(64)
@@ -608,55 +538,55 @@ bitfield Sstatus : xlenbits = {
/* sstatus is a view of mstatus, so there is no register defined. */
function get_sstatus_UXL(s : Sstatus) -> arch_xlen = {
- let m = Mk_Mstatus(s.bits());
+ let m = Mk_Mstatus(s.bits);
get_mstatus_UXL(m)
}
function set_sstatus_UXL(s : Sstatus, a : arch_xlen) -> Sstatus = {
- let m = Mk_Mstatus(s.bits());
+ let m = Mk_Mstatus(s.bits);
let m = set_mstatus_UXL(m, a);
- Mk_Sstatus(m.bits())
+ Mk_Sstatus(m.bits)
}
function lower_mstatus(m : Mstatus) -> Sstatus = {
let s = Mk_Sstatus(zero_extend(0b0));
- let s = update_SD(s, m.SD());
+ let s = [s with SD = m[SD]];
let s = set_sstatus_UXL(s, get_mstatus_UXL(m));
- let s = update_MXR(s, m.MXR());
- let s = update_SUM(s, m.SUM());
- let s = update_XS(s, m.XS());
- let s = update_FS(s, m.FS());
- let s = update_VS(s, m.VS());
- let s = update_SPP(s, m.SPP());
- let s = update_SPIE(s, m.SPIE());
- let s = update_UPIE(s, m.UPIE());
- let s = update_SIE(s, m.SIE());
- let s = update_UIE(s, m.UIE());
+ let s = [s with MXR = m[MXR]];
+ let s = [s with SUM = m[SUM]];
+ let s = [s with XS = m[XS]];
+ let s = [s with FS = m[FS]];
+ let s = [s with VS = m[VS]];
+ let s = [s with SPP = m[SPP]];
+ let s = [s with SPIE = m[SPIE]];
+ let s = [s with UPIE = m[UPIE]];
+ let s = [s with SIE = m[SIE]];
+ let s = [s with UIE = m[UIE]];
s
}
function lift_sstatus(m : Mstatus, s : Sstatus) -> Mstatus = {
- let m = update_MXR(m, s.MXR());
- let m = update_SUM(m, s.SUM());
+ let m = [m with MXR = s[MXR]];
+ let m = [m with SUM = s[SUM]];
- let m = update_XS(m, s.XS());
+ let m = [m with XS = s[XS]];
// See comment for mstatus.FS.
- let m = update_FS(m, s.FS());
- let m = update_VS(m, s.VS());
- let dirty = extStatus_of_bits(m.FS()) == Dirty | extStatus_of_bits(m.XS()) == Dirty |
- extStatus_of_bits(m.VS()) == Dirty;
- let m = update_SD(m, bool_to_bits(dirty));
-
- let m = update_SPP(m, s.SPP());
- let m = update_SPIE(m, s.SPIE());
- let m = update_UPIE(m, s.UPIE());
- let m = update_SIE(m, s.SIE());
- let m = update_UIE(m, s.UIE());
+ let m = [m with FS = s[FS]];
+ let m = [m with VS = s[VS]];
+ let dirty = extStatus_of_bits(m[FS]) == Dirty | extStatus_of_bits(m[XS]) == Dirty |
+ extStatus_of_bits(m[VS]) == Dirty;
+ let m = [m with SD = bool_to_bits(dirty)];
+
+ let m = [m with SPP = s[SPP]];
+ let m = [m with SPIE = s[SPIE]];
+ let m = [m with UPIE = s[UPIE]];
+ let m = [m with SIE = s[SIE]];
+ let m = [m with UIE = s[UIE]];
m
}
function legalize_sstatus(m : Mstatus, v : xlenbits) -> Mstatus = {
- legalize_mstatus(m, lift_sstatus(m, Mk_Sstatus(v)).bits())
+ legalize_mstatus(m, lift_sstatus(m, Mk_Sstatus(v)).bits)
}
bitfield Sedeleg : xlenbits = {
@@ -690,35 +620,35 @@ bitfield Sinterrupts : xlenbits = {
/* Provides the sip read view of mip (m) as delegated by mideleg (d). */
function lower_mip(m : Minterrupts, d : Minterrupts) -> Sinterrupts = {
let s : Sinterrupts = Mk_Sinterrupts(zero_extend(0b0));
- let s = update_SEI(s, m.SEI() & d.SEI());
- let s = update_STI(s, m.STI() & d.STI());
- let s = update_SSI(s, m.SSI() & d.SSI());
+ let s = [s with SEI = m[SEI] & d[SEI]];
+ let s = [s with STI = m[STI] & d[STI]];
+ let s = [s with SSI = m[SSI] & d[SSI]];
- let s = update_UEI(s, m.UEI() & d.UEI());
- let s = update_UTI(s, m.UTI() & d.UTI());
- let s = update_USI(s, m.USI() & d.USI());
+ let s = [s with UEI = m[UEI] & d[UEI]];
+ let s = [s with UTI = m[UTI] & d[UTI]];
+ let s = [s with USI = m[USI] & d[USI]];
s
}
/* Provides the sie read view of mie (m) as delegated by mideleg (d). */
function lower_mie(m : Minterrupts, d : Minterrupts) -> Sinterrupts = {
let s : Sinterrupts = Mk_Sinterrupts(zero_extend(0b0));
- let s = update_SEI(s, m.SEI() & d.SEI());
- let s = update_STI(s, m.STI() & d.STI());
- let s = update_SSI(s, m.SSI() & d.SSI());
- let s = update_UEI(s, m.UEI() & d.UEI());
- let s = update_UTI(s, m.UTI() & d.UTI());
- let s = update_USI(s, m.USI() & d.USI());
+ let s = [s with SEI = m[SEI] & d[SEI]];
+ let s = [s with STI = m[STI] & d[STI]];
+ let s = [s with SSI = m[SSI] & d[SSI]];
+ let s = [s with UEI = m[UEI] & d[UEI]];
+ let s = [s with UTI = m[UTI] & d[UTI]];
+ let s = [s with USI = m[USI] & d[USI]];
s
}
/* Returns the new value of mip from the previous mip (o) and the written sip (s) as delegated by mideleg (d). */
function lift_sip(o : Minterrupts, d : Minterrupts, s : Sinterrupts) -> Minterrupts = {
let m : Minterrupts = o;
- let m = if d.SSI() == 0b1 then update_SSI(m, s.SSI()) else m;
+ let m = if d[SSI] == 0b1 then [m with SSI = s[SSI]] else m;
if haveNExt() then {
- let m = if d.UEI() == 0b1 then update_UEI(m, s.UEI()) else m;
- let m = if d.USI() == 0b1 then update_USI(m, s.USI()) else m;
+ let m = if d[UEI] == 0b1 then [m with UEI = s[UEI]] else m;
+ let m = if d[USI] == 0b1 then [m with USI = s[USI]] else m;
m
} else m
}
@@ -730,13 +660,13 @@ function legalize_sip(m : Minterrupts, d : Minterrupts, v : xlenbits) -> Minterr
/* Returns the new value of mie from the previous mie (o) and the written sie (s) as delegated by mideleg (d). */
function lift_sie(o : Minterrupts, d : Minterrupts, s : Sinterrupts) -> Minterrupts = {
let m : Minterrupts = o;
- let m = if d.SEI() == 0b1 then update_SEI(m, s.SEI()) else m;
- let m = if d.STI() == 0b1 then update_STI(m, s.STI()) else m;
- let m = if d.SSI() == 0b1 then update_SSI(m, s.SSI()) else m;
+ let m = if d[SEI] == 0b1 then [m with SEI = s[SEI]] else m;
+ let m = if d[STI] == 0b1 then [m with STI = s[STI]] else m;
+ let m = if d[SSI] == 0b1 then [m with SSI = s[SSI]] else m;
if haveNExt() then {
- let m = if d.UEI() == 0b1 then update_UEI(m, s.UEI()) else m;
- let m = if d.UTI() == 0b1 then update_UTI(m, s.UTI()) else m;
- let m = if d.USI() == 0b1 then update_USI(m, s.USI()) else m;
+ let m = if d[UEI] == 0b1 then [m with UEI = s[UEI]] else m;
+ let m = if d[UTI] == 0b1 then [m with UTI = s[UTI]] else m;
+ let m = if d[USI] == 0b1 then [m with USI = s[USI]] else m;
m
} else m
}
@@ -767,10 +697,10 @@ bitfield Satp64 : bits(64) = {
function legalize_satp64(a : Architecture, o : bits(64), v : bits(64)) -> bits(64) = {
let s = Mk_Satp64(v);
- match satp64Mode_of_bits(a, s.Mode()) {
+ match satp64Mode_of_bits(a, s[Mode]) {
None() => o,
Some(Sv32) => o, /* Sv32 is unsupported for now */
- Some(_) => s.bits()
+ Some(_) => s.bits
}
}
@@ -841,9 +771,7 @@ function read_seed_csr() -> xlenbits = {
/* Writes to the seed CSR are ignored */
function write_seed_csr () -> option(xlenbits) = None()
-// menvcfg is 64 bits. senvcfg is SXLEN bits and does not have the two
-// upper fields so for simplicity we can use the same type.
-bitfield Envcfg : bits(64) = {
+bitfield MEnvcfg : bits(64) = {
// Supervisor TimeCmp Extension
STCE : 63,
// Page Based Memory Types Extension
@@ -862,12 +790,32 @@ bitfield Envcfg : bits(64) = {
FIOM : 0,
}
-register menvcfg : Envcfg
-register senvcfg : Envcfg
+bitfield SEnvcfg : xlenbits = {
+ // Cache Block Zero instruction Enable
+ CBZE : 7,
+ // Cache Block Clean and Flush instruction Enable
+ CBCFE : 6,
+ // Cache Block Invalidate instruction Enable
+ CBIE : 5 .. 4,
+ // Reserved WPRI bits.
+ wpri_0 : 3 .. 1,
+ // Fence of I/O implies Memory
+ FIOM : 0,
+}
+
+register menvcfg : MEnvcfg
+register senvcfg : SEnvcfg
+
+function legalize_menvcfg(o : MEnvcfg, v : bits(64)) -> MEnvcfg = {
+ let v = Mk_MEnvcfg(v);
+ let o = [o with FIOM = if sys_enable_writable_fiom() then v[FIOM] else 0b0];
+ // Other extensions are not implemented yet so all other fields are read only zero.
+ o
+}
-function legalize_envcfg(o : Envcfg, v : bits(64)) -> Envcfg = {
- let v = Mk_Envcfg(v);
- let o = update_FIOM(o, if sys_enable_writable_fiom() then v.FIOM() else 0b0);
+function legalize_senvcfg(o : SEnvcfg, v : xlenbits) -> SEnvcfg = {
+ let v = Mk_SEnvcfg(v);
+ let o = [o with FIOM = if sys_enable_writable_fiom() then v[FIOM] else 0b0];
// Other extensions are not implemented yet so all other fields are read only zero.
o
}
@@ -878,8 +826,8 @@ function legalize_envcfg(o : Envcfg, v : bits(64)) -> Envcfg = {
function is_fiom_active() -> bool = {
match cur_privilege {
Machine => false,
- Supervisor => menvcfg.FIOM() == 0b1,
- User => (menvcfg.FIOM() | senvcfg.FIOM()) == 0b1,
+ Supervisor => menvcfg[FIOM] == 0b1,
+ User => (menvcfg[FIOM] | senvcfg[FIOM]) == 0b1,
}
}
/* vector csrs */
@@ -901,9 +849,9 @@ register vtype : Vtype
/* the dynamic selected element width (SEW) */
/* this returns the power of 2 for SEW */
-val get_sew_pow : unit -> {|3, 4, 5, 6|} effect {escape, rreg}
+val get_sew_pow : unit -> {3, 4, 5, 6}
function get_sew_pow() = {
- let SEW_pow : {|3, 4, 5, 6|} = match vtype.vsew() {
+ let SEW_pow : {3, 4, 5, 6} = match vtype[vsew] {
0b000 => 3,
0b001 => 4,
0b010 => 5,
@@ -913,31 +861,33 @@ function get_sew_pow() = {
SEW_pow
}
/* this returns the actual value of SEW */
-val get_sew : unit -> {|8, 16, 32, 64|} effect {escape, rreg}
+val get_sew : unit -> {8, 16, 32, 64}
function get_sew() = {
match get_sew_pow() {
3 => 8,
4 => 16,
5 => 32,
- 6 => 64
+ 6 => 64,
+ _ => {internal_error(__FILE__, __LINE__, "invalid SEW"); 8}
}
}
/* this returns the value of SEW in bytes */
-val get_sew_bytes : unit -> {|1, 2, 4, 8|} effect {escape, rreg}
+val get_sew_bytes : unit -> {1, 2, 4, 8}
function get_sew_bytes() = {
match get_sew_pow() {
3 => 1,
4 => 2,
5 => 4,
- 6 => 8
+ 6 => 8,
+ _ => {internal_error(__FILE__, __LINE__, "invalid SEW"); 1}
}
}
/* the vector register group multiplier (LMUL) */
/* this returns the power of 2 for LMUL */
-val get_lmul_pow : unit -> {|-3, -2, -1, 0, 1, 2, 3|} effect {escape, rreg}
+val get_lmul_pow : unit -> {-3, -2, -1, 0, 1, 2, 3}
function get_lmul_pow() = {
- match vtype.vlmul() {
+ match vtype[vlmul] {
0b101 => -3,
0b110 => -2,
0b111 => -1,
@@ -959,8 +909,8 @@ function decode_agtype(ag) = {
}
}
-val get_vtype_vma : unit -> agtype effect {rreg}
-function get_vtype_vma() = decode_agtype(vtype.vma())
+val get_vtype_vma : unit -> agtype
+function get_vtype_vma() = decode_agtype(vtype[vma])
-val get_vtype_vta : unit -> agtype effect {rreg}
-function get_vtype_vta() = decode_agtype(vtype.vta())
+val get_vtype_vta : unit -> agtype
+function get_vtype_vta() = decode_agtype(vtype[vta])
diff --git a/model/riscv_termination_common.sail b/model/riscv_termination_common.sail
index fb8bdf0..b820b4b 100644
--- a/model/riscv_termination_common.sail
+++ b/model/riscv_termination_common.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
termination_measure n_leading_spaces s = string_length(s)
diff --git a/model/riscv_termination_rv32.sail b/model/riscv_termination_rv32.sail
index f08162a..3bf57f2 100644
--- a/model/riscv_termination_rv32.sail
+++ b/model/riscv_termination_rv32.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
termination_measure walk32(_,_,_,_,_,_,level,_,_) = level
diff --git a/model/riscv_termination_rv64.sail b/model/riscv_termination_rv64.sail
index dcd09b4..6beabf1 100644
--- a/model/riscv_termination_rv64.sail
+++ b/model/riscv_termination_rv64.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
termination_measure walk39(_,_,_,_,_,_,level,_, _) = level
diff --git a/model/riscv_types.sail b/model/riscv_types.sail
index b940286..e9a5a19 100644
--- a/model/riscv_types.sail
+++ b/model/riscv_types.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Basic type and function definitions used pervasively in the model. */
@@ -90,7 +28,7 @@ type csreg = bits(12) /* CSR addressing */
/* register file indexing */
-type regno ('n : Int), 0 <= 'n < 32 = atom('n)
+type regno ('n : Int), 0 <= 'n < 32 = int('n)
val regidx_to_regno : bits(5) -> {'n, 0 <= 'n < 32. regno('n)}
function regidx_to_regno b = let 'r = unsigned(b) in r
@@ -143,7 +81,7 @@ function not_implemented message = throw(Error_not_implemented(message))
val internal_error : forall ('a : Type). (string, int, string) -> 'a
function internal_error(file, line, s) = {
- assert (false, file ^ ":" ^ string_of_int(line) ^ ": " ^ s);
+ assert (false, file ^ ":" ^ dec_str(line) ^ ": " ^ s);
throw Error_internal_error()
}
@@ -308,7 +246,7 @@ function exceptionType_to_str(e) =
E_Breakpoint() => "breakpoint",
E_Load_Addr_Align() => "misaligned-load",
E_Load_Access_Fault() => "load-access-fault",
- E_SAMO_Addr_Align() => "misaliged-store/amo",
+ E_SAMO_Addr_Align() => "misaligned-store/amo",
E_SAMO_Access_Fault() => "store/amo-access-fault",
E_U_EnvCall() => "u-call",
E_S_EnvCall() => "s-call",
@@ -419,11 +357,6 @@ enum extop_zbb = {RISCV_SEXTB, RISCV_SEXTH, RISCV_ZEXTH}
enum zicondop = {RISCV_CZERO_EQZ, RISCV_CZERO_NEZ}
-val sep : unit <-> string
-mapping sep : unit <-> string = {
- () <-> opt_spc() ^ "," ^ def_spc()
-}
-
mapping bool_bits : bool <-> bits(1) = {
true <-> 0b1,
false <-> 0b0
@@ -434,7 +367,8 @@ mapping bool_not_bits : bool <-> bits(1) = {
false <-> 0b1
}
-mapping size_bits : word_width <-> bits(2) = {
+// Get the bit encoding of word_width.
+mapping size_enc : word_width <-> bits(2) = {
BYTE <-> 0b00,
HALF <-> 0b01,
WORD <-> 0b10,
@@ -448,12 +382,11 @@ mapping size_mnemonic : word_width <-> string = {
DOUBLE <-> "d"
}
-val word_width_bytes : word_width -> {'s, 's == 1 | 's == 2 | 's == 4 | 's == 8 . atom('s)}
-function word_width_bytes width = match width {
- BYTE => 1,
- HALF => 2,
- WORD => 4,
- DOUBLE => 8
+mapping size_bytes : word_width <-> {1, 2, 4, 8} = {
+ BYTE <-> 1,
+ HALF <-> 2,
+ WORD <-> 4,
+ DOUBLE <-> 8,
}
/*!
@@ -474,9 +407,9 @@ function report_invalid_width(f , l, w, k) -> 'a = {
* and remove the rest of the function.
*/
// internal_error(f, l, "Invalid width, " ^ size_mnemonic(w) ^ ", for " ^ k ^
- // " with xlen=" ^ string_of_int(sizeof(xlen)));
- assert (false, f ^ ":" ^ string_of_int(l) ^ ": " ^ "Invalid width, "
+ // " with xlen=" ^ dec_str(sizeof(xlen)));
+ assert (false, f ^ ":" ^ dec_str(l) ^ ": " ^ "Invalid width, "
^ size_mnemonic(w) ^ ", for " ^ k ^ " with xlen="
- ^ string_of_int(sizeof(xlen)));
+ ^ dec_str(sizeof(xlen)));
throw Error_internal_error()
}
diff --git a/model/riscv_types_common.sail b/model/riscv_types_common.sail
index 6080f30..aa22f57 100644
--- a/model/riscv_types_common.sail
+++ b/model/riscv_types_common.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
type exc_code = bits(8)
diff --git a/model/riscv_types_ext.sail b/model/riscv_types_ext.sail
index 771ef6d..515a769 100644
--- a/model/riscv_types_ext.sail
+++ b/model/riscv_types_ext.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/*
diff --git a/model/riscv_types_kext.sail b/model/riscv_types_kext.sail
index 9f9892f..0ae260c 100644
--- a/model/riscv_types_kext.sail
+++ b/model/riscv_types_kext.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/*
@@ -163,7 +101,7 @@ function aes_decode_rcon(r) = {
}
/* SM4 SBox - only one sbox for forwards and inverse */
-let sm4_sbox_table : list(bits(8)) = [|
+let sm4_sbox_table : vector(256, bits(8)) = [
0xD6, 0x90, 0xE9, 0xFE, 0xCC, 0xE1, 0x3D, 0xB7, 0x16, 0xB6, 0x14, 0xC2, 0x28,
0xFB, 0x2C, 0x05, 0x2B, 0x67, 0x9A, 0x76, 0x2A, 0xBE, 0x04, 0xC3, 0xAA, 0x44,
0x13, 0x26, 0x49, 0x86, 0x06, 0x99, 0x9C, 0x42, 0x50, 0xF4, 0x91, 0xEF, 0x98,
@@ -184,9 +122,9 @@ let sm4_sbox_table : list(bits(8)) = [|
0xE5, 0xB4, 0xB0, 0x89, 0x69, 0x97, 0x4A, 0x0C, 0x96, 0x77, 0x7E, 0x65, 0xB9,
0xF1, 0x09, 0xC5, 0x6E, 0xC6, 0x84, 0x18, 0xF0, 0x7D, 0xEC, 0x3A, 0xDC, 0x4D,
0x20, 0x79, 0xEE, 0x5F, 0x3E, 0xD7, 0xCB, 0x39, 0x48
-|]
+]
-let aes_sbox_fwd_table : list(bits(8)) = [|
+let aes_sbox_fwd_table : vector(256, bits(8)) = [
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe,
0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4,
0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7,
@@ -207,9 +145,9 @@ let aes_sbox_fwd_table : list(bits(8)) = [|
0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e,
0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42,
0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
-|]
+]
-let aes_sbox_inv_table : list(bits(8)) = [|
+let aes_sbox_inv_table : vector(256, bits(8)) = [
0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81,
0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e,
0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23,
@@ -230,17 +168,15 @@ let aes_sbox_inv_table : list(bits(8)) = [|
0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb,
0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6,
0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
-|]
+]
-/* Lookup function - takes an index and a list, and retrieves the
- * x'th element of that list.
+/* Lookup function - takes an index and a table, and retrieves the
+ * x'th element of that table. Note that the Sail vector literals
+ * start at index 255, and go down to 0.
*/
-val sbox_lookup : (bits(8), list(bits(8))) -> bits(8)
+val sbox_lookup : (bits(8), vector(256, bits(8))) -> bits(8)
function sbox_lookup(x, table) = {
- match (x, table) {
- (0x00, t0::tn) => t0,
- ( y, t0::tn) => sbox_lookup(x - 0x01, tn)
- }
+ table[255 - unsigned(x)]
}
/* Easy function to perform a forward AES SBox operation on 1 byte. */
diff --git a/model/riscv_vext_control.sail b/model/riscv_vext_control.sail
index 0fc1660..d7a17ee 100755
--- a/model/riscv_vext_control.sail
+++ b/model/riscv_vext_control.sail
@@ -1,40 +1,10 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
function clause ext_is_CSR_defined (0x008, _) = true
function clause ext_is_CSR_defined (0xC20, _) = true
@@ -45,14 +15,14 @@ function clause ext_is_CSR_defined (0x009, _) = true
function clause ext_is_CSR_defined (0x00A, _) = true
function clause ext_is_CSR_defined (0x00F, _) = true
-function clause ext_read_CSR (0x009) = Some (zero_extend(vcsr.vxsat()))
-function clause ext_read_CSR (0x00A) = Some (zero_extend(vcsr.vxrm()))
-function clause ext_read_CSR (0x00F) = Some (zero_extend(vcsr.bits()))
+function clause ext_read_CSR (0x009) = Some (zero_extend(vcsr[vxsat]))
+function clause ext_read_CSR (0x00A) = Some (zero_extend(vcsr[vxrm]))
+function clause ext_read_CSR (0x00F) = Some (zero_extend(vcsr.bits))
-function clause ext_read_CSR (0x009) = Some (zero_extend(vcsr.vxsat()))
-function clause ext_read_CSR (0x00A) = Some (zero_extend(vcsr.vxrm()))
-function clause ext_read_CSR (0x00F) = Some (zero_extend(vcsr.bits()))
+function clause ext_read_CSR (0x009) = Some (zero_extend(vcsr[vxsat]))
+function clause ext_read_CSR (0x00A) = Some (zero_extend(vcsr[vxrm]))
+function clause ext_read_CSR (0x00F) = Some (zero_extend(vcsr.bits))
-function clause ext_write_CSR (0x009, value) = { ext_write_vcsr (vcsr.vxrm(), value[0 .. 0]); Some(zero_extend(vcsr.vxsat())) }
-function clause ext_write_CSR (0x00A, value) = { ext_write_vcsr (value[1 .. 0], vcsr.vxsat()); Some(zero_extend(vcsr.vxrm())) }
-function clause ext_write_CSR (0x00F, value) = { ext_write_vcsr (value [2 .. 1], value [0 .. 0]); Some(zero_extend(vcsr.bits())) }
+function clause ext_write_CSR (0x009, value) = { ext_write_vcsr (vcsr[vxrm], value[0 .. 0]); Some(zero_extend(vcsr[vxsat])) }
+function clause ext_write_CSR (0x00A, value) = { ext_write_vcsr (value[1 .. 0], vcsr[vxsat]); Some(zero_extend(vcsr[vxrm])) }
+function clause ext_write_CSR (0x00F, value) = { ext_write_vcsr (value [2 .. 1], value [0 .. 0]); Some(zero_extend(vcsr.bits)) }
diff --git a/model/riscv_vext_regs.sail b/model/riscv_vext_regs.sail
index 9b5d6e9..ae61ad5 100644
--- a/model/riscv_vext_regs.sail
+++ b/model/riscv_vext_regs.sail
@@ -1,40 +1,10 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
/* vector registers */
register vr0 : vregtype
@@ -108,15 +78,15 @@ mapping vreg_name = {
function dirty_v_context() -> unit = {
assert(sys_enable_vext());
- mstatus->VS() = extStatus_to_bits(Dirty);
- mstatus->SD() = 0b1
+ mstatus[VS] = extStatus_to_bits(Dirty);
+ mstatus[SD] = 0b1
}
function dirty_v_context_if_present() -> unit = {
if sys_enable_vext() then dirty_v_context()
}
-val rV : forall 'n, 0 <= 'n < 32. regno('n) -> vregtype effect {rreg, escape}
+val rV : forall 'n, 0 <= 'n < 32. regno('n) -> vregtype
function rV r = {
let zero_vreg : vregtype = zeros();
let v : vregtype =
@@ -158,7 +128,7 @@ function rV r = {
v
}
-val wV : forall 'n, 0 <= 'n < 32. (regno('n), vregtype) -> unit effect {rreg, wreg, escape}
+val wV : forall 'n, 0 <= 'n < 32. (regno('n), vregtype) -> unit
function wV (r, in_v) = {
let v = in_v;
match r {
@@ -202,7 +172,7 @@ function wV (r, in_v) = {
let VLEN = unsigned(vlenb) * 8;
assert(0 < VLEN & VLEN <= sizeof(vlenmax));
if get_config_print_reg()
- then print_reg("v" ^ string_of_int(r) ^ " <- " ^ BitStr(v[VLEN - 1 .. 0]));
+ then print_reg("v" ^ dec_str(r) ^ " <- " ^ BitStr(v[VLEN - 1 .. 0]));
}
function rV_bits(i: bits(5)) -> vregtype = rV(unsigned(i))
@@ -213,7 +183,7 @@ function wV_bits(i: bits(5), data: vregtype) -> unit = {
overload V = {rV_bits, wV_bits, rV, wV}
-val init_vregs : unit -> unit effect {wreg}
+val init_vregs : unit -> unit
function init_vregs () = {
let zero_vreg : vregtype = zeros();
vr0 = zero_vreg;
@@ -257,15 +227,15 @@ bitfield Vcsr : bits(3) = {
}
register vcsr : Vcsr
-val ext_write_vcsr : (bits(2), bits(1)) -> unit effect {rreg, wreg}
+val ext_write_vcsr : (bits(2), bits(1)) -> unit
function ext_write_vcsr (vxrm_val, vxsat_val) = {
- vcsr->vxrm() = vxrm_val; /* Note: frm can be an illegal value, 101, 110, 111 */
- vcsr->vxsat() = vxsat_val;
+ vcsr[vxrm] = vxrm_val; /* Note: frm can be an illegal value, 101, 110, 111 */
+ vcsr[vxsat] = vxsat_val;
dirty_v_context_if_present()
}
/* num_elem means max(VLMAX,VLEN/SEW)) according to Section 5.4 of RVV spec */
-val get_num_elem : (int, int) -> nat effect {escape, rreg}
+val get_num_elem : (int, int) -> nat
function get_num_elem(LMUL_pow, SEW) = {
let VLEN = unsigned(vlenb) * 8;
let LMUL_pow_reg = if LMUL_pow < 0 then 0 else LMUL_pow;
@@ -277,7 +247,7 @@ function get_num_elem(LMUL_pow, SEW) = {
}
/* Reads a single vreg into multiple elements */
-val read_single_vreg : forall 'n 'm, 'n >= 0. (int('n), int('m), regidx) -> vector('n, dec, bits('m)) effect {escape, rreg, undef}
+val read_single_vreg : forall 'n 'm, 'n >= 0. (int('n), int('m), regidx) -> vector('n, dec, bits('m))
function read_single_vreg(num_elem, SEW, vrid) = {
let bv : vregtype = V(vrid);
var result : vector('n, dec, bits('m)) = undefined;
@@ -292,7 +262,7 @@ function read_single_vreg(num_elem, SEW, vrid) = {
}
/* Writes multiple elements into a single vreg */
-val write_single_vreg : forall 'n 'm, 'n >= 0. (int('n), int('m), regidx, vector('n, dec, bits('m))) -> unit effect {escape, rreg, wreg}
+val write_single_vreg : forall 'n 'm, 'n >= 0. (int('n), int('m), regidx, vector('n, dec, bits('m))) -> unit
function write_single_vreg(num_elem, SEW, vrid, v) = {
r : vregtype = zeros();
@@ -306,7 +276,7 @@ function write_single_vreg(num_elem, SEW, vrid, v) = {
}
/* The general vreg reading operation with num_elem as max(VLMAX,VLEN/SEW)) */
-val read_vreg : forall 'n 'm 'p, 'n >= 0. (int('n), int('m), int('p), regidx) -> vector('n, dec, bits('m)) effect {escape, rreg, undef}
+val read_vreg : forall 'n 'm 'p, 'n >= 0. (int('n), int('m), int('p), regidx) -> vector('n, dec, bits('m))
function read_vreg(num_elem, SEW, LMUL_pow, vrid) = {
var result : vector('n, dec, bits('m)) = undefined;
let VLEN = unsigned(vlenb) * 8;
@@ -344,7 +314,7 @@ function read_vreg(num_elem, SEW, LMUL_pow, vrid) = {
}
/* Single element reading operation */
-val read_single_element : forall 'm 'x, 8 <= 'm <= 128. (int('m), int('x), regidx) -> bits('m) effect {escape, rreg, undef}
+val read_single_element : forall 'm 'x, 8 <= 'm <= 128. (int('m), int('x), regidx) -> bits('m)
function read_single_element(EEW, index, vrid) = {
let VLEN = unsigned(vlenb) * 8;
assert(VLEN >= EEW);
@@ -358,7 +328,7 @@ function read_single_element(EEW, index, vrid) = {
}
/* The general vreg writing operation with num_elem as max(VLMAX,VLEN/SEW)) */
-val write_vreg : forall 'n 'm 'p, 'n >= 0. (int('n), int('m), int('p), regidx, vector('n, dec, bits('m))) -> unit effect {escape, rreg, undef, wreg}
+val write_vreg : forall 'n 'm 'p, 'n >= 0. (int('n), int('m), int('p), regidx, vector('n, dec, bits('m))) -> unit
function write_vreg(num_elem, SEW, LMUL_pow, vrid, vec) = {
let VLEN = unsigned(vlenb) * 8;
let LMUL_pow_reg = if LMUL_pow < 0 then 0 else LMUL_pow;
@@ -381,7 +351,7 @@ function write_vreg(num_elem, SEW, LMUL_pow, vrid, vec) = {
}
/* Single element writing operation */
-val write_single_element : forall 'm 'x, 8 <= 'm <= 128. (int('m), int('x), regidx, bits('m)) -> unit effect {escape, rreg, undef, wreg}
+val write_single_element : forall 'm 'x, 8 <= 'm <= 128. (int('m), int('x), regidx, bits('m)) -> unit
function write_single_element(EEW, index, vrid, value) = {
let VLEN = unsigned(vlenb) * 8;
let 'elem_per_reg : int = VLEN / EEW;
@@ -403,7 +373,7 @@ function write_single_element(EEW, index, vrid, value) = {
}
/* Mask register reading operation with num_elem as max(VLMAX,VLEN/SEW)) */
-val read_vmask : forall 'n, 'n >= 0. (int('n), bits(1), regidx) -> vector('n, dec, bool) effect {escape, rreg, undef}
+val read_vmask : forall 'n, 'n >= 0. (int('n), bits(1), regidx) -> vector('n, dec, bool)
function read_vmask(num_elem, vm, vrid) = {
let VLEN = unsigned(vlenb) * 8;
assert(num_elem <= sizeof(vlenmax));
@@ -422,7 +392,7 @@ function read_vmask(num_elem, vm, vrid) = {
}
/* This is a special version of read_vmask for carry/borrow instructions, where vm=1 means no carry */
-val read_vmask_carry : forall 'n, 'n >= 0. (int('n), bits(1), regidx) -> vector('n, dec, bool) effect {escape, rreg, undef}
+val read_vmask_carry : forall 'n, 'n >= 0. (int('n), bits(1), regidx) -> vector('n, dec, bool)
function read_vmask_carry(num_elem, vm, vrid) = {
let VLEN = unsigned(vlenb) * 8;
assert(0 < num_elem & num_elem <= sizeof(vlenmax));
@@ -441,7 +411,7 @@ function read_vmask_carry(num_elem, vm, vrid) = {
}
/* Mask register writing operation with num_elem as max(VLMAX,VLEN/SEW)) */
-val write_vmask : forall 'n, 'n >= 0. (int('n), regidx, vector('n, dec, bool)) -> unit effect {escape, rreg, undef, wreg}
+val write_vmask : forall 'n, 'n >= 0. (int('n), regidx, vector('n, dec, bool)) -> unit
function write_vmask(num_elem, vrid, v) = {
let VLEN = unsigned(vlenb) * 8;
assert(0 < VLEN & VLEN <= sizeof(vlenmax));
diff --git a/model/riscv_vlen.sail b/model/riscv_vlen.sail
index 5e9b375..5e45290 100644
--- a/model/riscv_vlen.sail
+++ b/model/riscv_vlen.sail
@@ -1,44 +1,14 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
register elen : bits(1)
-val get_elen_pow : unit -> {|5, 6|} effect {rreg}
+val get_elen_pow : unit -> {5, 6}
function get_elen_pow() = match elen {
0b0 => 5,
@@ -51,7 +21,7 @@ function get_elen_pow() = match elen {
register vlen : bits(4)
-val get_vlen_pow : unit -> {|5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16|} effect {rreg}
+val get_vlen_pow : unit -> {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
function get_vlen_pow() = match vlen {
0b0000 => 5,
diff --git a/model/riscv_vmem.sail b/model/riscv_vmem.sail
new file mode 100644
index 0000000..2d1e5d1
--- /dev/null
+++ b/model/riscv_vmem.sail
@@ -0,0 +1,452 @@
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
+
+// ****************************************************************
+// Virtual memory address translation and memory protection,
+// including PTWs (Page Table Walks) and TLBs (Translation Look-aside Buffers)
+// Supported VM modes: Sv32, Sv39, Sv48. TODO: Sv57
+
+// STYLE NOTES:
+// PRIVATE items are used only within this VM code.
+// PUBLIC items are invoked from other parts of sail-riscv.
+
+// TLB NOTE:
+// TLBs are not part of the RISC-V architecture specification.
+// However, we model a simple TLB so that
+// (1) we can meaningfully test SFENCE.VMA which is a no-op wihout TLBs;
+// (2) we can greatly speed up simulation speed
+// (e.g., from 10s or minutes to few minutes for Linux boot)
+// The TLB implementation is in a separate file: riscv_vmem_tlb.sail
+// The code in this file is structured and commented so you can easily
+// ignore TLB functionality at first reading.
+
+// ****************************************************************
+// Fields of virtual addresses
+
+// PRIVATE: Extract full VPN field from VA
+function vpns_of_va(sv_params : SV_Params,
+ va : bits(64)) -> bits(64) = {
+ let mask : bits(64) = zero_extend(ones(sv_params.va_size_bits));
+ (va & mask) >> pagesize_bits
+}
+
+// PRIVATE: Extract VPN[level] from VA
+function vpn_j_of_va(sv_params : SV_Params,
+ va : bits(64),
+ level : PTW_Level) -> bits(64) = {
+ let lsb : range(0,63) = pagesize_bits + level * sv_params.vpn_size_bits;
+ assert (lsb < sizeof(xlen));
+ let mask : bits(64) = zero_extend(ones(sv_params.vpn_size_bits));
+ ((va >> lsb) & mask)
+}
+
+// PRIVATE: Extract offset within page from VA
+function offset_of_va(va : bits(64)) -> bits(PAGESIZE_BITS) = va[pagesize_bits - 1 .. 0]
+
+// Valid xlen-wide values containing virtual addrs must have upper
+// bits equal to the MSB of the virtual address.
+// Virtual address widths depend on the virtual memory mode.
+// PRIVATE
+function is_valid_vAddr(struct { va_size_bits, _ } : SV_Params,
+ vAddr : bits(64)) -> bool =
+ vAddr == sign_extend(vAddr[va_size_bits - 1 .. 0])
+
+// ****************************************************************
+// Results of Page Table Walk (PTW)
+
+// PRIVATE
+union PTW_Result = {
+ PTW_Success: (bits(64), bits(64), bits(64), nat, bool, ext_ptw),
+ PTW_Failure: (PTW_Error, ext_ptw)
+}
+
+// ****************************************************************
+// Page Table Walk (PTW)
+
+// Note: 'pt_walk()' is recursive => needs separate 'val' decls
+
+// PRIVATE
+val pt_walk : (SV_Params,
+ bits(64), // virtual addr
+ AccessType(ext_access_type), // Read/Write/ReadWrite/Execute
+ Privilege, // User/Supervisor/Machine
+ bool, // mstatus.MXR
+ bool, // do_sum
+ bits(64), // PT base addr
+ PTW_Level, // tree level for this recursive call
+ bool, // global translation,
+ ext_ptw) // ext_ptw
+ -> PTW_Result
+
+function pt_walk(sv_params,
+ va,
+ ac,
+ priv,
+ mxr,
+ do_sum,
+ pt_base,
+ level,
+ global,
+ ext_ptw) = {
+ let vpn_j = vpn_j_of_va(sv_params, va, level);
+ let pte_offset = vpn_j << sv_params.log_pte_size_bytes;
+ let pte_addr = pt_base + pte_offset;
+
+ // In Sv32, physical addrs are actually 34 bits, not XLEN(=32) bits.
+ // Below, 'pte_phys_addr' is XLEN bits because it's an arg to
+ // 'mem_read_priv()' [riscv_mem.sail] where it's declared as xlenbits.
+ // That def and this use need to be fixed together (TODO)
+ let pte_phys_addr : xlenbits = pte_addr[(sizeof(xlen) - 1) .. 0];
+
+ // Read this-level PTE from mem
+ let mem_result = mem_read_priv(Read(Data), // AccessType
+ Supervisor, // Privilege
+ pte_phys_addr,
+ 8, // atom (8)
+ false, // aq
+ false, // rl
+ false); // res
+
+ match mem_result {
+ MemException(_) => PTW_Failure(PTW_Access(), ext_ptw),
+ MemValue(pte) => {
+ let pte_flags = Mk_PTE_Flags(pte[7 .. 0]);
+ if pte_is_invalid(pte_flags) then
+ PTW_Failure(PTW_Invalid_PTE(), ext_ptw)
+ else {
+ let ppns : bits(64) = PPNs_of_PTE(sv_params, pte);
+ let global' = global | (pte_flags[G] == 0b1);
+ if pte_is_ptr(pte_flags) then {
+ // Non-Leaf PTE
+ if level > 0 then {
+ // follow the pointer to walk next level
+ let pt_base' : bits(64) = ppns << pagesize_bits;
+ let level' = level - 1;
+ pt_walk(sv_params, va, ac, priv, mxr, do_sum,
+ pt_base', level', global', ext_ptw)
+ }
+ else
+ // level 0 PTE, but contains a pointer instead of a leaf
+ PTW_Failure(PTW_Invalid_PTE(), ext_ptw)
+ }
+ else {
+ // Leaf PTE
+ let ext_pte = msbs_of_PTE(sv_params, pte);
+ let pte_check = check_PTE_permission(ac, priv, mxr, do_sum, pte_flags,
+ ext_pte, ext_ptw);
+ match pte_check {
+ PTE_Check_Failure(ext_ptw, ext_ptw_fail) =>
+ PTW_Failure(ext_get_ptw_error(ext_ptw_fail), ext_ptw),
+ PTE_Check_Success(ext_ptw) =>
+ if level > 0 then {
+ // Superpage; construct mask for lower-level PPNs from the PTE
+ let mask_bits = level * sv_params.pte_PPN_j_size_bits;
+ // Clear the lowest `mask_bits` bits.
+ let ppns_masked = (ppns >> mask_bits) << mask_bits;
+ if not(ppns == ppns_masked) then
+ // misaligned superpage mapping
+ PTW_Failure(PTW_Misaligned(), ext_ptw)
+ else {
+ // Compose final PA in superpage:
+ // Superpage PPN + lower VPNs + pagesize_bits page-offset
+ let mask : bits(64) = ~ (ones() << mask_bits);
+ let ppn = ppns | (vpns_of_va(sv_params, va) & mask);
+ let pa = (ppn << pagesize_bits) | zero_extend(offset_of_va(va));
+ PTW_Success(pa, pte, pte_addr, level, global', ext_ptw)
+ }
+ }
+ else {
+ let pa = (ppns << pagesize_bits) | zero_extend(offset_of_va(va));
+ PTW_Success(pa, pte, pte_addr, level, global', ext_ptw)
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+// ****************************************************************
+// Architectural SATP CSR
+
+// PUBLIC: see also riscv_insts_zicsr.sail and other CSR-related files
+register satp : xlenbits
+
+// See riscv_sys_regs.sail for legalize_satp{32,64}().
+// WARNING: those functions legalize Mode but not ASID?
+// PUBLIC: invoked from writeCSR() to fixup WARL fields
+function legalize_satp(a : Architecture,
+ o : xlenbits, // previous value of satp
+ v : xlenbits) // proposed new value of satp
+ -> xlenbits = { // new legal value of satp
+ if sizeof(xlen) == 32 then {
+ // The slice and extend ops below are no-ops when xlen==32,
+ // but appease the type-checker when xlen==64 (when this code is not executed!)
+ let o32 : bits(32) = o[31 .. 0];
+ let v32 : bits(32) = v[31 .. 0];
+ let new_satp : bits(32) = legalize_satp32(a, o32, v32);
+ zero_extend(new_satp);
+ } else if sizeof(xlen) == 64 then {
+ // The extend and truncate ops below are no-ops when xlen==64,
+ // but appease the type-checker when xlen==32 (when this code is not executed!)
+ let o64 : bits(64) = zero_extend(o);
+ let v64 : bits(64) = zero_extend(v);
+ let new_satp : bits(64) = legalize_satp64(a, o64, v64);
+ truncate(new_satp, sizeof(xlen))
+ } else
+ internal_error(__FILE__, __LINE__, "Unsupported xlen" ^ dec_str(sizeof(xlen)))
+}
+
+// ----------------
+// Fields of SATP
+
+// ASID is 9b in Sv32, 16b in Sv39/Sv48/Sv57: we use 16b for both
+// PRIVATE
+function satp_to_asid(satp_val : xlenbits) -> asidbits =
+ if sizeof(xlen) == 32 then zero_extend(Mk_Satp32(satp_val)[Asid])
+ else if sizeof(xlen) == 64 then Mk_Satp64(satp_val)[Asid]
+ else internal_error(__FILE__, __LINE__,
+ "Unsupported xlen" ^ dec_str(sizeof(xlen)))
+
+// Result is 64b to cover both RV32 and RV64 addrs
+// PRIVATE
+function satp_to_PT_base(satp_val : xlenbits) -> bits(64) = {
+ let ppn = if sizeof(xlen) == 32 then zero_extend (64, Mk_Satp32(satp_val)[PPN])
+ else if sizeof(xlen) == 64 then zero_extend (64, Mk_Satp64(satp_val)[PPN])
+ else internal_error(__FILE__, __LINE__,
+ "Unsupported xlen" ^ dec_str(sizeof(xlen)));
+ ppn << pagesize_bits
+}
+
+// Compute address translation mode from SATP register
+// PRIVATE
+function translationMode(priv : Privilege) -> SATPMode = {
+ if priv == Machine then
+ Sbare
+ else if sizeof(xlen) == 32 then
+ match Mk_Satp32(satp)[Mode] {
+ 0b0 => Sbare,
+ 0b1 => Sv32
+ }
+ else if sizeof(xlen) == 64 then {
+ // Translation mode is based on mstatus.SXL, which could be RV32 when xlen==64
+ let arch = architecture(get_mstatus_SXL(mstatus));
+ match arch {
+ Some(RV64) => { let mbits : bits(4) = satp[63 .. 60];
+ match satp64Mode_of_bits(RV64, mbits) { // see riscv_types.sail
+ Some(m) => m,
+ None() => internal_error(__FILE__, __LINE__,
+ "invalid RV64 translation mode in satp")
+ }
+ },
+ Some(RV32) => match Mk_Satp32(satp[31 .. 0])[Mode] { // Note: satp is 64bits here
+ // When xlen is 64, mstatus.SXL (for S privilege) can be RV32
+ 0b0 => Sbare,
+ 0b1 => Sv32
+ },
+ _ => internal_error(__FILE__, __LINE__, "unsupported address translation arch")
+ }
+ }
+ else
+ internal_error(__FILE__, __LINE__, "unsupported xlen")
+}
+
+// ****************************************************************
+// VA to PA translation
+
+// Result of address translation
+
+// PUBLIC
+union TR_Result('paddr : Type, 'failure : Type) = {
+ TR_Address : ('paddr, ext_ptw),
+ TR_Failure : ('failure, ext_ptw)
+}
+
+// This function can be ignored on first reading since TLBs are not
+// part of RISC-V architecture spec (see TLB_NOTE above).
+// PRIVATE: translate on TLB hit, and maintenance of PTE in TLB
+function translate_TLB_hit(sv_params : SV_Params,
+ asid : asidbits,
+ ptb : bits(64),
+ vAddr : bits(64),
+ ac : AccessType(ext_access_type),
+ priv : Privilege,
+ mxr : bool,
+ do_sum : bool,
+ ext_ptw : ext_ptw,
+ tlb_index : nat,
+ ent : TLB_Entry)
+ -> TR_Result(bits(64), PTW_Error) = {
+ let pte = ent.pte;
+ let ext_pte = msbs_of_PTE(sv_params, pte);
+ let pte_flags = Mk_PTE_Flags(pte[7 .. 0]);
+ let pte_check = check_PTE_permission(ac, priv, mxr, do_sum, pte_flags,
+ ext_pte,
+ ext_ptw);
+ match pte_check {
+ PTE_Check_Failure(ext_ptw, ext_ptw_fail) =>
+ TR_Failure(ext_get_ptw_error(ext_ptw_fail), ext_ptw),
+ PTE_Check_Success(ext_ptw) =>
+ match update_PTE_Bits(sv_params, pte, ac) {
+ None() => TR_Address(ent.pAddr | (vAddr & ent.vAddrMask), ext_ptw),
+ Some(pte') =>
+ // See riscv_platform.sail
+ if not(plat_enable_dirty_update()) then
+ // pte needs dirty/accessed update but that is not enabled
+ TR_Failure(PTW_PTE_Update(), ext_ptw)
+ else {
+ // Writeback the PTE (which has new A/D bits)
+ let n_ent = {ent with pte=pte'};
+ write_TLB(tlb_index, n_ent);
+ let pte_phys_addr = ent.pteAddr[(sizeof(xlen) - 1) .. 0];
+ let mv = mem_write_value_priv(pte_phys_addr,
+ 8,
+ pte',
+ Supervisor,
+ false,
+ false,
+ false);
+ match mv {
+ MemValue(_) => (),
+ MemException(e) => internal_error(__FILE__, __LINE__,
+ "invalid physical address in TLB")
+ };
+ TR_Address(ent.pAddr | (vAddr & ent.vAddrMask), ext_ptw)
+ }
+ }
+ }
+}
+
+// PRIVATE: translate on TLB miss (do a page-table walk)
+function translate_TLB_miss(sv_params : SV_Params,
+ asid : asidbits,
+ ptb : bits(64),
+ vAddr : bits(64),
+ ac : AccessType(ext_access_type),
+ priv : Privilege,
+ mxr : bool,
+ do_sum : bool,
+ ext_ptw : ext_ptw) -> TR_Result(bits(64), PTW_Error) = {
+ let initial_level = sv_params.levels - 1;
+ let ptw_result = pt_walk(sv_params, vAddr, ac, priv, mxr, do_sum,
+ ptb, initial_level, false, ext_ptw);
+ match ptw_result {
+ PTW_Failure(f, ext_ptw) => TR_Failure(f, ext_ptw),
+ PTW_Success(pAddr, pte, pteAddr, level, global, ext_ptw) => {
+ let ext_pte = msbs_of_PTE(sv_params, pte);
+ // Without TLBs, this 'match' expression can be replaced simply
+ // by: 'TR_Address(pAddr, ext_ptw)' (see TLB_NOTE above)
+ match update_PTE_Bits(sv_params, pte, ac) {
+ None() => {
+ add_to_TLB(asid, vAddr, pAddr, pte, pteAddr, level, global,
+ sv_params.vpn_size_bits,
+ pagesize_bits);
+ TR_Address(pAddr, ext_ptw)
+ },
+ Some(pte') =>
+ // See riscv_platform.sail
+ if not(plat_enable_dirty_update()) then
+ // pte needs dirty/accessed update but that is not enabled
+ TR_Failure(PTW_PTE_Update(), ext_ptw)
+ else {
+ // Writeback the PTE (which has new A/D bits)
+ let pte_phys_addr = pteAddr[(sizeof(xlen) - 1) .. 0];
+ let mv = mem_write_value_priv(pte_phys_addr, // pteAddr,
+ 8,
+ pte',
+ Supervisor,
+ false,
+ false,
+ false);
+ match mv {
+ MemValue(_) => {
+ add_to_TLB(asid, vAddr, pAddr, pte', pteAddr, level, global,
+ sv_params.vpn_size_bits,
+ pagesize_bits);
+ TR_Address(pAddr, ext_ptw)
+ },
+ MemException(e) =>
+ TR_Failure(PTW_Access(), ext_ptw)
+ }
+ }
+ }
+ }
+ }
+}
+
+// PRIVATE
+function translate(sv_params : SV_Params,
+ asid : asidbits,
+ ptb : bits(64),
+ vAddr_arg : bits(64),
+ ac : AccessType(ext_access_type),
+ priv : Privilege,
+ mxr : bool,
+ do_sum : bool,
+ ext_ptw : ext_ptw)
+ -> TR_Result(bits(64), PTW_Error) = {
+ let va_mask : bits(64) = zero_extend(ones(sv_params.va_size_bits));
+ let vAddr = (vAddr_arg & va_mask);
+
+ // On first reading, assume lookup_TLB returns None(), since TLBs
+ // are not part of RISC-V archticture spec (see TLB_NOTE above)
+ match lookup_TLB(asid, vAddr) {
+ Some(index, ent) => translate_TLB_hit(sv_params, asid, ptb, vAddr, ac, priv,
+ mxr, do_sum, ext_ptw, index, ent),
+ None() => translate_TLB_miss(sv_params, asid, ptb, vAddr, ac, priv,
+ mxr, do_sum, ext_ptw)
+ }
+}
+
+// Top-level addr-translation function
+// PUBLIC: invoked from instr-fetch and load/store/amo
+function translateAddr(vAddr : xlenbits,
+ ac : AccessType(ext_access_type))
+ -> TR_Result(xlenbits, ExceptionType) = {
+ // Internally the vmem code works with 64-bit values, whether xlen==32 or xlen==64
+ // This 'extend' is a no-op when xlen==64 and extends when xlen==32
+ let vAddr_64b : bits(64) = zero_extend(vAddr);
+ // Effective privilege takes into account mstatus.PRV, mstatus.MPP
+ // See riscv_sys_regs.sail for effectivePrivilege() and cur_privilege
+ let effPriv : Privilege = effectivePrivilege(ac, mstatus, cur_privilege);
+ let mode : SATPMode = translationMode(effPriv);
+ let (valid_va, sv_params) : (bool, SV_Params) = match mode {
+ Sbare => return TR_Address(vAddr, init_ext_ptw),
+ Sv32 => (true, sv32_params),
+ Sv39 => (is_valid_vAddr(sv39_params, vAddr_64b), sv39_params),
+ Sv48 => (is_valid_vAddr(sv48_params, vAddr_64b), sv48_params),
+ // Sv57 => (is_valid_vAddr(sv57_params, vAddr_64b), sv57_params), // TODO
+ };
+ if not(valid_va) then
+ TR_Failure(translationException(ac, PTW_Invalid_Addr()), init_ext_ptw)
+ else {
+ let mxr = mstatus.MXR() == 0b1;
+ let do_sum = mstatus.SUM() == 0b1;
+ let asid : asidbits = satp_to_asid(satp);
+ let ptb : bits(64) = satp_to_PT_base(satp);
+ let tr_result1 = translate(sv_params,
+ asid,
+ ptb,
+ vAddr_64b,
+ ac, effPriv, mxr, do_sum,
+ init_ext_ptw);
+ // Fixup result PA or exception
+ match tr_result1 {
+ TR_Address(pa, ext_ptw) => TR_Address(truncate(pa, sizeof(xlen)), ext_ptw),
+ TR_Failure(f, ext_ptw) => TR_Failure(translationException(ac, f), ext_ptw)
+ }
+ }
+}
+
+// ****************************************************************
+// Initialize Virtual Memory state
+
+// PUBLIC: invoked from init_model()
+function init_vmem() -> unit = init_TLB()
+
+// ****************************************************************
diff --git a/model/riscv_vmem_common.sail b/model/riscv_vmem_common.sail
index 46134d2..d17cb02 100644
--- a/model/riscv_vmem_common.sail
+++ b/model/riscv_vmem_common.sail
@@ -1,229 +1,114 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
-/* Shared definitions for supervisor-mode page-table-entries and permission checks.
- *
- * These definitions are independent of xlen and do not involve
- * accessing physical memory.
- */
-
-/* PageSize */
-
-let PAGESIZE_BITS = 12
-
-/*
- * Definitions for RV32, which has a single address translation mode: Sv32.
- */
-
-type vaddr32 = bits(32)
-type paddr32 = bits(34)
-type pte32 = bits(32)
-
-/* asid */
-type asid32 = bits(9)
-
-function curAsid32(satp : bits(32)) -> asid32 = {
- let s = Mk_Satp32(satp);
- s.Asid()
+// ****************************************************************
+// Parameters for VM modes sv32, sv39, sv48 and (TODO) Sv57
+
+// All VM modes use the same page size (4KB, with 12-bit index)
+
+// This two-line idiom constrains the value (2nd line) to be a singleton,
+// which helps in type-checking wherever it is used.
+type PAGESIZE_BITS : Int = 12
+let pagesize_bits = sizeof(PAGESIZE_BITS)
+
+// PRIVATE
+struct SV_Params = {
+ // VA
+ va_size_bits : {32, 39, 48}, // 32 39 48
+ vpn_size_bits : {10, 9}, // 10 9 9
+
+ // PTE
+ levels : { 2, 3, 4}, // 2 3 4
+ log_pte_size_bytes : { 2, 3}, // 2 3 3
+ pte_msbs_lsb_index : {32, 54}, // 32 54 54
+ pte_msbs_size_bits : { 0, 10}, // 0 10 10
+ pte_PPNs_lsb_index : {10}, // 10 10 10
+ pte_PPNs_size_bits : {22, 44}, // 22 44 44
+ pte_PPN_j_size_bits : {10, 9} // 10 9 9
}
-/* page table base from satp */
-function curPTB32(satp : bits(32)) -> paddr32 = {
- let s : Satp32 = Mk_Satp32(satp);
- shiftl(zero_extend(s.PPN()), PAGESIZE_BITS)
+// Current level during a page-table walk (0 to SV_Params.levels - 1)
+type PTW_Level = range(0,3) // range(0,4) when add Sv57 (TODO)
+
+// PRIVATE
+let sv32_params : SV_Params = struct {
+ // VA
+ va_size_bits = 32,
+ vpn_size_bits = 10,
+
+ // PTE
+ levels = 2,
+ log_pte_size_bytes = 2, // 4 Bytes
+ pte_msbs_lsb_index = 32,
+ pte_msbs_size_bits = 0,
+ pte_PPNs_lsb_index = 10,
+ pte_PPNs_size_bits = 22,
+ pte_PPN_j_size_bits = 10
}
-/* Sv32 parameters and bitfield layouts */
-
-let SV32_LEVEL_BITS = 10
-let SV32_LEVELS = 2
-let PTE32_LOG_SIZE = 2
-let PTE32_SIZE = 4
-
-bitfield SV32_Vaddr : vaddr32 = {
- VPNi : 31 .. 12,
- PgOfs : 11 .. 0
+// PRIVATE
+let sv39_params : SV_Params = struct {
+ // VA
+ va_size_bits = 39,
+ vpn_size_bits = 9,
+
+ // PTE
+ levels = 3,
+ log_pte_size_bytes = 3, // 8 Bytes
+ pte_msbs_lsb_index = 54,
+ pte_msbs_size_bits = 10,
+ pte_PPNs_lsb_index = 10,
+ pte_PPNs_size_bits = 44,
+ pte_PPN_j_size_bits = 9
}
-bitfield SV32_Paddr : paddr32 = {
- PPNi : 33 .. 12,
- PgOfs : 11 .. 0
-}
-
-bitfield SV32_PTE : pte32 = {
- PPNi : 31 .. 10,
- RSW : 9 .. 8,
- BITS : 7 .. 0
+// PRIVATE
+let sv48_params : SV_Params = struct {
+ // VA
+ va_size_bits = 48,
+ vpn_size_bits = 9,
+
+ // PTE
+ levels = 4,
+ log_pte_size_bytes = 3, // 8 Bytes
+ pte_msbs_lsb_index = 54,
+ pte_msbs_size_bits = 10,
+ pte_PPNs_lsb_index = 10,
+ pte_PPNs_size_bits = 44,
+ pte_PPN_j_size_bits = 9
}
+// TODO; not currently used
+// PRIVATE
/*
- * Definitions for RV64, which has two defined address translation modes: Sv39 and Sv48.
- */
-
-/* Sv48 and Sv64 are reserved but not defined. The size of the VPN
- * increases by 9 bits through Sv39, Sv48 and Sv57, but not for Sv64.
- * Also, the 45-bit size of the VPN for Sv57 exceeds the 44-bit size
- * of the PPN in satp64. Due to these corner cases, it is unlikely
- * that definitions can be shared across all four schemes, so separate
- * definitions might eventually be needed for each translation mode.
- *
- * But to keep things simple for now, since Sv39 and Sv48 have the
- * same PPN size, we share some definitions.
- */
-
-type paddr64 = bits(56)
-type pte64 = bits(64)
-
-/* asid */
-
-type asid64 = bits(16)
-
-function curAsid64(satp : bits(64)) -> asid64 = {
- let s = Mk_Satp64(satp);
- s.Asid()
-}
-
-/* page table base from satp */
-function curPTB64(satp : bits(64)) -> paddr64 = {
- let s = Mk_Satp64(satp);
- shiftl(zero_extend(s.PPN()), PAGESIZE_BITS)
-}
-
-/* Sv39 parameters and bitfield layouts */
-
-let SV39_LEVEL_BITS = 9
-let SV39_LEVELS = 3
-let PTE39_LOG_SIZE = 3
-let PTE39_SIZE = 8
-
-type vaddr39 = bits(39)
-
-bitfield SV39_Vaddr : vaddr39 = {
- VPNi : 38 .. 12,
- PgOfs : 11 .. 0
-}
-
-bitfield SV39_Paddr : paddr64 = {
- PPNi : 55 .. 12,
- PgOfs : 11 .. 0
-}
-
-bitfield SV39_PTE : pte64 = {
- Ext : 63 .. 54,
- PPNi : 53 .. 10,
- RSW : 9 .. 8,
- BITS : 7 .. 0
-}
-
-/* Sv48 parameters and bitfield layouts */
-
-let SV48_LEVEL_BITS = 9
-let SV48_LEVELS = 4
-let PTE48_LOG_SIZE = 3
-let PTE48_SIZE = 8
-
-type vaddr48 = bits(48)
-type pte48 = bits(64)
-
-bitfield SV48_Vaddr : vaddr48 = {
- VPNi : 47 .. 12,
- PgOfs : 11 .. 0
-}
-
-bitfield SV48_Paddr : paddr64 = {
- PPNi : 55 .. 12,
- PgOfs : 11 .. 0
-}
-
-bitfield SV48_PTE : pte48 = {
- Ext : 63 .. 54,
- PPNi : 53 .. 10,
- RSW : 9 .. 8,
- BITS : 7 .. 0
-}
-
-/* The types below are parameterized by 'paddr and 'pte to support
- * various architectural widths (e.g. RV32, RV64). ext_ptw supports
- * extensions to the default address translation and page-table-walk.
- */
-
-/* Result of a page-table walk. */
-
-union PTW_Result('paddr : Type, 'pte : Type) = {
- PTW_Success: ('paddr, 'pte, 'paddr, nat, bool, ext_ptw),
- PTW_Failure: (PTW_Error, ext_ptw)
-}
-
-/* Result of address translation */
-
-union TR_Result('paddr : Type, 'failure : Type) = {
- TR_Address : ('paddr, ext_ptw),
- TR_Failure : ('failure, ext_ptw)
+let sv57_params : SV_Params = struct {
+ // VA
+ va_size_bits = 57,
+ vpn_size_bits = 9,
+
+ // PTE
+ levels = 5,
+ log_pte_size_bytes = 3, // 8 Bytes
+ pte_msbs_lsb_index = 54,
+ pte_msbs_size_bits = 10,
+ pte_PPNs_lsb_index = 10,
+ pte_PPNs_size_bits = 44,
+ pte_PPN_j_size_bits = 9
}
+*/
+
+// This 'undefined_SV_Params()' function is not used anywhere, but is
+// currently (2023-12) needed to work around an issue where Sail tries
+// to figure out how it could do
+// let x : SV_Params = undefined
+// even though the code never does this. This has been fixed in Sail.
+// The fix will become available in a new Sail release, at which point
+// this function can be deleted (TODO).
+// PRIVATE
+val undefined_SV_Params : unit -> SV_Params
+function undefined_SV_Params() = sv32_params
diff --git a/model/riscv_vmem_pte.sail b/model/riscv_vmem_pte.sail
new file mode 100644
index 0000000..dfe032c
--- /dev/null
+++ b/model/riscv_vmem_pte.sail
@@ -0,0 +1,135 @@
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
+
+// ****************************************************************
+// PTE (Page Table Entry) in PTN (Page Table Node)
+
+// PTE MSBs PPNs RSW BITs
+// Sv32 - 31..10 9..8 7..0
+// Sv39 63..54 53..10 9..8 7..0
+// Sv48 63..54 53..10 9..8 7..0
+
+// MSBs of PTE are reserved for RV64 extensions.
+// There are not available bits on RV32, so these bits will be zeros on RV32.
+
+type pte_flags_bits = bits(8)
+
+// For PTW extensions (non-standard)
+type extPte = bits(64)
+
+// PRIVATE: extract msbs of PTE above the PPN
+function msbs_of_PTE(sv_params : SV_Params, pte : bits(64)) -> bits(64) = {
+ let mask : bits(64) = zero_extend(ones(sv_params.pte_msbs_size_bits));
+ (pte >> sv_params.pte_msbs_lsb_index) & mask
+}
+
+// PRIVATE: extract PPNs of PTE
+function PPNs_of_PTE(sv_params : SV_Params, pte : bits(64)) -> bits(64) = {
+ let mask : bits(64) = zero_extend(ones(sv_params.pte_PPNs_size_bits));
+ (pte >> sv_params.pte_PPNs_lsb_index) & mask
+}
+
+// PRIVATE: 8 LSBs of PTEs in Sv32, Sv39, Sv48 and Sv57
+bitfield PTE_Flags : pte_flags_bits = {
+ D : 7, // dirty
+ A : 6, // accessed
+ G : 5, // global
+ U : 4, // User
+ X : 3, // Execute permission
+ W : 2, // Write permission
+ R : 1, // Read permission
+ V : 0 // Valid
+}
+
+// PRIVATE: check if a PTE is a pointer to next level (non-leaf)
+function pte_is_ptr(pte_flags : PTE_Flags) -> bool = (pte_flags[X] == 0b0)
+ & (pte_flags[W] == 0b0)
+ & (pte_flags[R] == 0b0)
+
+// PRIVATE: check if a PTE is valid
+function pte_is_invalid(pte_flags : PTE_Flags) -> bool = (pte_flags[V] == 0b0)
+ | ((pte_flags[W] == 0b1)
+ & (pte_flags[R] == 0b0))
+
+// ----------------
+// Check access permissions in PTE
+
+// For (non-standard) extensions: this function gets the extension-available bits
+// of the PTE in extPte, and the accumulated information of the page-table-walk
+// in ext_ptw. It should return the updated ext_ptw in both success and failure cases.
+
+union PTE_Check = {
+ PTE_Check_Success : ext_ptw,
+ PTE_Check_Failure : (ext_ptw, ext_ptw_fail)
+}
+
+// PRIVATE
+function check_PTE_permission(ac : AccessType(ext_access_type),
+ priv : Privilege,
+ mxr : bool,
+ do_sum : bool,
+ pte_flags : PTE_Flags,
+ ext : extPte,
+ ext_ptw : ext_ptw) -> PTE_Check = {
+ let pte_U = pte_flags[U];
+ let pte_R = pte_flags[R];
+ let pte_W = pte_flags[W];
+ let pte_X = pte_flags[X];
+ let success : bool =
+ match (ac, priv) {
+ (Read(_), User) => (pte_U == 0b1)
+ & ((pte_R == 0b1)
+ | ((pte_X == 0b1 & mxr))),
+ (Write(_), User) => (pte_U == 0b1) & (pte_W == 0b1),
+ (ReadWrite(_, _), User) => (pte_U == 0b1)
+ & (pte_W == 0b1)
+ & ((pte_R == 0b1) | ((pte_X == 0b1) & mxr)),
+ (Execute(), User) => (pte_U == 0b1) & (pte_X == 0b1),
+ (Read(_), Supervisor) => ((pte_U == 0b0) | do_sum)
+ & ((pte_R == 0b1) | ((pte_X == 0b1) & mxr)),
+ (Write(_), Supervisor) => ((pte_U == 0b0) | do_sum)
+ & (pte_W == 0b1),
+ (ReadWrite(_, _), Supervisor) => ((pte_U == 0b0) | do_sum)
+ & (pte_W == 0b1)
+ & ((pte_R == 0b1)
+ | ((pte_X == 0b1) & mxr)),
+ (Execute(), Supervisor) => (pte_U == 0b0) & (pte_X == 0b1),
+ (_, Machine) => internal_error(__FILE__, __LINE__,
+ "m-mode mem perm check")};
+ if success then PTE_Check_Success(())
+ else PTE_Check_Failure((), ())
+}
+
+// Update PTE bits if needed; return new PTE if updated
+// PRIVATE
+function update_PTE_Bits(sv_params : SV_Params,
+ pte : bits(64),
+ a : AccessType(ext_access_type))
+ -> option(bits(64)) = {
+ let pte_flags = Mk_PTE_Flags(pte [7 .. 0]);
+
+ // Update 'dirty' bit?
+ let update_d : bool = (pte_flags[D] == 0b0)
+ & (match a {
+ Execute() => false,
+ Read() => false,
+ Write(_) => true,
+ ReadWrite(_, _) => true
+ });
+ // Update 'accessed'-bit?
+ let update_a = (pte_flags[A] == 0b0);
+
+ if update_d | update_a then {
+ let pte_flags = [pte_flags with
+ A = 0b1,
+ D = (if update_d then 0b1 else pte_flags[D])];
+ Some(pte[63 .. 8] @ pte_flags.bits())
+ }
+ else
+ None()
+}
diff --git a/model/riscv_vmem_ptw.sail b/model/riscv_vmem_ptw.sail
new file mode 100644
index 0000000..ab73b19
--- /dev/null
+++ b/model/riscv_vmem_ptw.sail
@@ -0,0 +1,66 @@
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
+
+// ****************************************************************
+// PTW exceptions
+
+// 'ext_ptw' supports (non-standard) extensions to the default addr-translation and PTW.
+// See riscv_types_ext.sail for definitions.
+
+// Failure modes for address-translation/page-table-walks
+// PRIVATE
+union PTW_Error = {
+ PTW_Invalid_Addr : unit, // invalid source address
+ PTW_Access : unit, // physical memory access error for a PTE
+ PTW_Invalid_PTE : unit,
+ PTW_No_Permission : unit,
+ PTW_Misaligned : unit, // misaligned superpage
+ PTW_PTE_Update : unit, // PTE update needed but not enabled
+ PTW_Ext_Error : ext_ptw_error // parameterized for errors from extensions
+}
+
+// PRIVATE: only 'to_str' overload is public
+function ptw_error_to_str(e : PTW_Error) -> string = {
+ match e {
+ PTW_Invalid_Addr() => "invalid-source-addr",
+ PTW_Access() => "mem-access-error",
+ PTW_Invalid_PTE() => "invalid-pte",
+ PTW_No_Permission() => "no-permission",
+ PTW_Misaligned() => "misaligned-superpage",
+ PTW_PTE_Update() => "pte-update-needed",
+ PTW_Ext_Error(e) => "extension-error"
+ }
+}
+
+// PUBLIC
+overload to_str = {ptw_error_to_str}
+
+// hook for (non-standard) extensions to customize errors reported by page-table
+// walks during address translation; it typically works in conjunction
+// with any customization to check_PTE_permission().
+
+// PRIVATE
+function ext_get_ptw_error(eptwf : ext_ptw_fail) -> PTW_Error =
+ PTW_No_Permission()
+
+// Convert translation/PTW failures into architectural exceptions
+function translationException(a : AccessType(ext_access_type),
+ f : PTW_Error)
+ -> ExceptionType = {
+ match (a, f) {
+ (_, PTW_Ext_Error(e)) => E_Extension(ext_translate_exception(e)),
+ (ReadWrite(_), PTW_Access()) => E_SAMO_Access_Fault(),
+ (ReadWrite(_), _) => E_SAMO_Page_Fault(),
+ (Read(_), PTW_Access()) => E_Load_Access_Fault(),
+ (Read(_), _) => E_Load_Page_Fault(),
+ (Write(_), PTW_Access()) => E_SAMO_Access_Fault(),
+ (Write(_), _) => E_SAMO_Page_Fault(),
+ (Execute(), PTW_Access()) => E_Fetch_Access_Fault(),
+ (Execute(), _) => E_Fetch_Page_Fault()
+ }
+}
diff --git a/model/riscv_vmem_rv32.sail b/model/riscv_vmem_rv32.sail
deleted file mode 100644
index 3478be4..0000000
--- a/model/riscv_vmem_rv32.sail
+++ /dev/null
@@ -1,137 +0,0 @@
-/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
-/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=======================================================================================*/
-
-/* RV32 Supervisor-mode address translation and page-table walks. */
-
-/* Define the architectural satp and its legalizer. */
-
-register satp : xlenbits
-
-function legalize_satp(a : Architecture, o : xlenbits, v : xlenbits) -> xlenbits =
- legalize_satp32(a, o, v)
-
-/* Compute the address translation mode. */
-
-val translationMode : (Privilege) -> SATPMode
-function translationMode(priv) = {
- if priv == Machine then Sbare
- else {
- let arch = architecture(get_mstatus_SXL(mstatus));
- match arch {
- Some(RV32) => {
- let s = Mk_Satp32(satp[31..0]);
- if s.Mode() == 0b0 then Sbare else Sv32
- },
- _ => internal_error(__FILE__, __LINE__, "unsupported address translation arch")
- }
- }
-}
-
-/* Top-level address translation dispatcher */
-
-val translateAddr_priv : (xlenbits, AccessType(ext_access_type), Privilege) -> TR_Result(xlenbits, ExceptionType)
-function translateAddr_priv(vAddr, ac, effPriv) = {
- let mxr : bool = mstatus.MXR() == 0b1;
- let do_sum : bool = mstatus.SUM() == 0b1;
- let mode : SATPMode = translationMode(effPriv);
-
- let asid = curAsid32(satp);
- let ptb = curPTB32(satp);
-
- /* PTW extensions: initialize the PTW extension state */
- let ext_ptw : ext_ptw = init_ext_ptw;
-
- match mode {
- Sbare => TR_Address(vAddr, ext_ptw),
- Sv32 => match translate32(asid, ptb, vAddr, ac, effPriv, mxr, do_sum, SV32_LEVELS - 1, ext_ptw) {
- TR_Address(pa, ext_ptw) => TR_Address(to_phys_addr(pa), ext_ptw),
- TR_Failure(f, ext_ptw) => TR_Failure(translationException(ac, f), ext_ptw)
- },
- _ => internal_error(__FILE__, __LINE__, "unsupported address translation scheme")
- }
-}
-
-val translateAddr : (xlenbits, AccessType(ext_access_type)) -> TR_Result(xlenbits, ExceptionType)
-function translateAddr(vAddr, ac) =
- translateAddr_priv(vAddr, ac, effectivePrivilege(ac, mstatus, cur_privilege))
-
-val flush_TLB : (option(xlenbits), option(xlenbits)) -> unit
-function flush_TLB(asid_xlen, addr_xlen) -> unit = {
- let asid : option(asid32) =
- match (asid_xlen) {
- None() => None(),
- Some(a) => Some(a[8 .. 0])
- };
- flush_TLB32(asid, addr_xlen)
-}
-
-function init_vmem () -> unit = {
- init_vmem_sv32()
-}
diff --git a/model/riscv_vmem_rv64.sail b/model/riscv_vmem_rv64.sail
deleted file mode 100644
index 18d0991..0000000
--- a/model/riscv_vmem_rv64.sail
+++ /dev/null
@@ -1,176 +0,0 @@
-/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
-/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=======================================================================================*/
-
-/* RV64 Supervisor-mode address translation and page-table walks. */
-
-/* Define the architectural satp and its legalizer. */
-
-register satp : xlenbits
-
-function legalize_satp(a : Architecture, o : xlenbits, v : xlenbits) -> xlenbits =
- legalize_satp64(a, o, v)
-
-/* Define valid source addresses for translation */
-
-function isValidSv39Addr(vAddr : xlenbits) -> bool = {
- vAddr[63 .. 39] == (if vAddr[38] == bitone
- then ones()
- else zeros())
-}
-
-function isValidSv48Addr(vAddr : xlenbits) -> bool = {
- vAddr[63 .. 48] == (if vAddr[47] == bitone
- then ones()
- else zeros())
-}
-
-/* Compute the address translation mode. */
-
-val translationMode : (Privilege) -> SATPMode
-function translationMode(priv) = {
- if priv == Machine then Sbare
- else {
- let arch = architecture(get_mstatus_SXL(mstatus));
- match arch {
- Some(RV64) => {
- let mbits : satp_mode = Mk_Satp64(satp).Mode();
- match satp64Mode_of_bits(RV64, mbits) {
- Some(m) => m,
- None() => internal_error(__FILE__, __LINE__, "invalid RV64 translation mode in satp")
- }
- },
- Some(RV32) => {
- let s = Mk_Satp32(satp[31..0]);
- if s.Mode() == 0b0 then Sbare else Sv32
- },
- _ => internal_error(__FILE__, __LINE__, "unsupported address translation arch")
- }
- }
-}
-
-/* Top-level address translation dispatcher */
-
-val translateAddr_priv : (xlenbits, AccessType(ext_access_type), Privilege) -> TR_Result(xlenbits, ExceptionType)
-function translateAddr_priv(vAddr, ac, effPriv) = {
- let mxr : bool = mstatus.MXR() == 0b1;
- let do_sum : bool = mstatus.SUM() == 0b1;
- let mode : SATPMode = translationMode(effPriv);
-
- let asid = curAsid64(satp);
- let ptb = curPTB64(satp);
-
- /* PTW extensions: initialize the PTW extension state. */
- let ext_ptw : ext_ptw = init_ext_ptw;
-
- match mode {
- Sbare => TR_Address(vAddr, ext_ptw),
- Sv39 => { if isValidSv39Addr(vAddr)
- then match translate39(asid, ptb, vAddr[38 .. 0], ac, effPriv, mxr, do_sum, SV39_LEVELS - 1, ext_ptw) {
- TR_Address(pa, ext_ptw) => TR_Address(zero_extend(pa), ext_ptw),
- TR_Failure(f, ext_ptw) => TR_Failure(translationException(ac, f), ext_ptw)
- }
- else TR_Failure(translationException(ac, PTW_Invalid_Addr()), ext_ptw)
- },
- Sv48 => { if isValidSv48Addr(vAddr)
- then match translate48(asid, ptb, vAddr[47 .. 0], ac, effPriv, mxr, do_sum, SV48_LEVELS - 1, ext_ptw) {
- TR_Address(pa, ext_ptw) => TR_Address(zero_extend(pa), ext_ptw),
- TR_Failure(f, ext_ptw) => TR_Failure(translationException(ac, f), ext_ptw)
- }
- else TR_Failure(translationException(ac, PTW_Invalid_Addr()), ext_ptw)
- },
- _ => internal_error(__FILE__, __LINE__, "unsupported address translation scheme")
- }
-}
-
-val translateAddr : (xlenbits, AccessType(ext_access_type)) -> TR_Result(xlenbits, ExceptionType)
-function translateAddr(vAddr, ac) =
- translateAddr_priv(vAddr, ac, effectivePrivilege(ac, mstatus, cur_privilege))
-
-val flush_TLB : (option(xlenbits), option(xlenbits)) -> unit
-function flush_TLB(asid_xlen, addr_xlen) -> unit = {
- /* Flush both Sv39 and Sv48 TLBs. */
- let (addr39, addr48) : (option(vaddr39), option(vaddr48)) =
- match addr_xlen {
- None() => (None(), None()),
- Some(a) => (Some(a[38 .. 0]), Some(a[47 .. 0]))
- };
- let asid : option(asid64) =
- match asid_xlen {
- None() => None(),
- Some(a) => Some(a[15 .. 0])
- };
- flush_TLB39(asid, addr39);
- flush_TLB48(asid, addr48)
-}
-
-function init_vmem() -> unit = {
- init_vmem_sv39();
- init_vmem_sv48()
-}
diff --git a/model/riscv_vmem_sv32.sail b/model/riscv_vmem_sv32.sail
deleted file mode 100644
index 72def15..0000000
--- a/model/riscv_vmem_sv32.sail
+++ /dev/null
@@ -1,262 +0,0 @@
-/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
-/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=======================================================================================*/
-
-/* Sv32 address translation for RV32. */
-
-/* FIXME: paddr32 is 34-bits, but phys_mem accesses in riscv_mem take 32-bit (xlenbits) addresses.
- * Define a converter for now.
- */
-
-function to_phys_addr(a : paddr32) -> xlenbits = a[31..0]
-
-val walk32 : (vaddr32, AccessType(ext_access_type), Privilege, bool, bool, paddr32, nat, bool, ext_ptw) -> PTW_Result(paddr32, SV32_PTE)
-function walk32(vaddr, ac, priv, mxr, do_sum, ptb, level, global, ext_ptw) = {
- let va = Mk_SV32_Vaddr(vaddr);
- let pt_ofs : paddr32 = shiftl(zero_extend(shiftr(va.VPNi(), (level * SV32_LEVEL_BITS))[(SV32_LEVEL_BITS - 1) .. 0]),
- PTE32_LOG_SIZE);
- let pte_addr = ptb + pt_ofs;
- match (mem_read_priv(Read(Data), Supervisor, to_phys_addr(pte_addr), 4, false, false, false)) {
- MemException(_) => {
-/* print("walk32(vaddr=" ^ BitStr(vaddr) ^ " level=" ^ string_of_int(level)
- ^ " pt_base=" ^ BitStr(to_phys_addr(ptb))
- ^ " pt_ofs=" ^ BitStr(to_phys_addr(pt_ofs))
- ^ " pte_addr=" ^ BitStr(to_phys_addr(pte_addr))
- ^ ": invalid pte address"); */
- PTW_Failure(PTW_Access(), ext_ptw)
- },
- MemValue(v) => {
- let pte = Mk_SV32_PTE(v);
- let pbits = pte.BITS();
- let ext_pte : extPte = default_sv32_ext_pte;
- let pattr = Mk_PTE_Bits(pbits);
- let is_global = global | (pattr.G() == 0b1);
-/* print("walk32(vaddr=" ^ BitStr(vaddr) ^ " level=" ^ string_of_int(level)
- ^ " pt_base=" ^ BitStr(to_phys_addr(ptb))
- ^ " pt_ofs=" ^ BitStr(to_phys_addr(pt_ofs))
- ^ " pte_addr=" ^ BitStr(to_phys_addr(pte_addr))
- ^ " pte=" ^ BitStr(v)); */
- if isInvalidPTE(pbits, ext_pte) then {
-/* print("walk32: invalid pte"); */
- PTW_Failure(PTW_Invalid_PTE(), ext_ptw)
- } else {
- if isPTEPtr(pbits, ext_pte) then {
- if level > 0 then {
- /* walk down the pointer to the next level */
- walk32(vaddr, ac, priv, mxr, do_sum, shiftl(zero_extend(pte.PPNi()), PAGESIZE_BITS), level - 1, is_global, ext_ptw)
- } else {
- /* last-level PTE contains a pointer instead of a leaf */
-/* print("walk32: last-level pte contains a ptr"); */
- PTW_Failure(PTW_Invalid_PTE(), ext_ptw)
- }
- } else { /* leaf PTE */
- match checkPTEPermission(ac, priv, mxr, do_sum, pattr, ext_pte, ext_ptw) {
- PTE_Check_Failure(ext_ptw, ext_ptw_fail) => {
-/* print("walk32: pte permission check failure"); */
- PTW_Failure(ext_get_ptw_error(ext_ptw_fail), ext_ptw)
- },
- PTE_Check_Success(ext_ptw) => {
- if level > 0 then { /* superpage */
- /* fixme hack: to get a mask of appropriate size */
- let mask = shiftl(pte.PPNi() ^ pte.PPNi() ^ zero_extend(0b1), level * SV32_LEVEL_BITS) - 1;
- if (pte.PPNi() & mask) != zero_extend(0b0) then {
- /* misaligned superpage mapping */
-/* print("walk32: misaligned superpage mapping"); */
- PTW_Failure(PTW_Misaligned(), ext_ptw)
- } else {
- /* add the appropriate bits of the VPN to the superpage PPN */
- let ppn = pte.PPNi() | (zero_extend(va.VPNi()) & mask);
-/* let res = append(ppn, va.PgOfs());
- print("walk32: using superpage: pte.ppn=" ^ BitStr(pte.PPNi())
- ^ " ppn=" ^ BitStr(ppn) ^ " res=" ^ BitStr(res)); */
- PTW_Success(append(ppn, va.PgOfs()), pte, pte_addr, level, is_global, ext_ptw)
- }
- } else {
- /* normal leaf PTE */
-/* let res = append(pte.PPNi(), va.PgOfs());
- print("walk32: pte.ppn=" ^ BitStr(pte.PPNi()) ^ " ppn=" ^ BitStr(pte.PPNi()) ^ " res=" ^ BitStr(res)); */
- PTW_Success(append(pte.PPNi(), va.PgOfs()), pte, pte_addr, level, is_global, ext_ptw)
- }
- }
- }
- }
- }
- }
- }
-}
-
-/* TLB management: single entry for now */
-
-// ideally we would use the below form:
-// type TLB32_Entry = TLB_Entry(sizeof(asid32), sizeof(vaddr32), sizeof(paddr32), sizeof(pte32))
-type TLB32_Entry = TLB_Entry(9, 32, 34, 32)
-register tlb32 : option(TLB32_Entry)
-
-val lookup_TLB32 : (asid32, vaddr32) -> option((nat, TLB32_Entry))
-function lookup_TLB32(asid, vaddr) =
- match tlb32 {
- None() => None(),
- Some(e) => if match_TLB_Entry(e, asid, vaddr) then Some((0, e)) else None()
- }
-
-val add_to_TLB32 : (asid32, vaddr32, paddr32, SV32_PTE, paddr32, nat, bool) -> unit
-function add_to_TLB32(asid, vAddr, pAddr, pte, pteAddr, level, global) = {
- let ent : TLB32_Entry = make_TLB_Entry(asid, global, vAddr, pAddr, pte.bits(), level, pteAddr, SV32_LEVEL_BITS);
- tlb32 = Some(ent)
-}
-
-function write_TLB32(idx : nat, ent : TLB32_Entry) -> unit =
- tlb32 = Some(ent)
-
-val flush_TLB32 : (option(asid32), option(vaddr32)) -> unit
-function flush_TLB32(asid, addr) =
- match (tlb32) {
- None() => (),
- Some(e) => if flush_TLB_Entry(e, asid, addr)
- then tlb32 = None()
- else ()
- }
-
-/* address translation */
-
-val translate32 : (asid32, paddr32, vaddr32, AccessType(ext_access_type), Privilege, bool, bool, nat, ext_ptw) -> TR_Result(paddr32, PTW_Error)
-function translate32(asid, ptb, vAddr, ac, priv, mxr, do_sum, level, ext_ptw) = {
- match lookup_TLB32(asid, vAddr) {
- Some(idx, ent) => {
-/* print("translate32: TLB32 hit for " ^ BitStr(vAddr)); */
- let pte = Mk_SV32_PTE(ent.pte);
- let ext_pte : extPte = zeros(); // no reserved bits for extensions
- let pteBits = Mk_PTE_Bits(pte.BITS());
- match checkPTEPermission(ac, priv, mxr, do_sum, pteBits, ext_pte, ext_ptw) {
- PTE_Check_Failure(ext_ptw, ext_ptw_fail) => { TR_Failure(ext_get_ptw_error(ext_ptw_fail), ext_ptw) },
- PTE_Check_Success(ext_ptw) => {
- match update_PTE_Bits(pteBits, ac, ext_pte) {
- None() => TR_Address(ent.pAddr | zero_extend(vAddr & ent.vAddrMask), ext_ptw),
- Some(pbits, ext) => {
- if not(plat_enable_dirty_update())
- then {
- /* pte needs dirty/accessed update but that is not enabled */
- TR_Failure(PTW_PTE_Update(), ext_ptw)
- } else {
- /* update PTE entry and TLB */
- n_pte = update_BITS(pte, pbits.bits());
- /* ext is unused since there are no reserved bits for extensions */
- n_ent : TLB32_Entry = ent;
- n_ent.pte = n_pte.bits();
- write_TLB32(idx, n_ent);
- /* update page table */
- match mem_write_value_priv(to_phys_addr(zero_extend(ent.pteAddr)), 4, n_pte.bits(), Supervisor, false, false, false) {
- MemValue(_) => (),
- MemException(e) => internal_error(__FILE__, __LINE__, "invalid physical address in TLB")
- };
- TR_Address(ent.pAddr | zero_extend(vAddr & ent.vAddrMask), ext_ptw)
- }
- }
- }
- }
- }
- },
- None() => {
- match walk32(vAddr, ac, priv, mxr, do_sum, ptb, level, false, ext_ptw) {
- PTW_Failure(f, ext_ptw) => TR_Failure(f, ext_ptw),
- PTW_Success(pAddr, pte, pteAddr, level, global, ext_ptw) => {
- match update_PTE_Bits(Mk_PTE_Bits(pte.BITS()), ac, zeros()) {
- None() => {
- add_to_TLB32(asid, vAddr, pAddr, pte, pteAddr, level, global);
- TR_Address(pAddr, ext_ptw)
- },
- Some(pbits, ext) =>
- if not(plat_enable_dirty_update())
- then {
- /* pte needs dirty/accessed update but that is not enabled */
- TR_Failure(PTW_PTE_Update(), ext_ptw)
- } else {
- var w_pte : SV32_PTE = update_BITS(pte, pbits.bits());
- /* ext is unused since there are no reserved bits for extensions */
- match mem_write_value_priv(to_phys_addr(pteAddr), 4, w_pte.bits(), Supervisor, false, false, false) {
- MemValue(_) => {
- add_to_TLB32(asid, vAddr, pAddr, w_pte, pteAddr, level, global);
- TR_Address(pAddr, ext_ptw)
- },
- MemException(e) => {
- /* pte is not in valid memory */
- TR_Failure(PTW_Access(), ext_ptw)
- }
- }
- }
- }
- }
- }
- }
- }
-}
-
-function init_vmem_sv32() -> unit = {
- tlb32 = None()
-}
diff --git a/model/riscv_vmem_sv39.sail b/model/riscv_vmem_sv39.sail
deleted file mode 100644
index 25378a8..0000000
--- a/model/riscv_vmem_sv39.sail
+++ /dev/null
@@ -1,256 +0,0 @@
-/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
-/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=======================================================================================*/
-
-/* Sv39 address translation for RV64. */
-
-val walk39 : (vaddr39, AccessType(ext_access_type), Privilege, bool, bool, paddr64, nat, bool, ext_ptw) -> PTW_Result(paddr64, SV39_PTE)
-function walk39(vaddr, ac, priv, mxr, do_sum, ptb, level, global, ext_ptw) = {
- let va = Mk_SV39_Vaddr(vaddr);
- let pt_ofs : paddr64 = shiftl(zero_extend(shiftr(va.VPNi(), (level * SV39_LEVEL_BITS))[(SV39_LEVEL_BITS - 1) .. 0]),
- PTE39_LOG_SIZE);
- let pte_addr = ptb + pt_ofs;
- match (mem_read_priv(Read(Data), Supervisor, zero_extend(pte_addr), 8, false, false, false)) {
- MemException(_) => {
-/* print("walk39(vaddr=" ^ BitStr(vaddr) ^ " level=" ^ string_of_int(level)
- ^ " pt_base=" ^ BitStr(ptb)
- ^ " pt_ofs=" ^ BitStr(pt_ofs)
- ^ " pte_addr=" ^ BitStr(pte_addr)
- ^ ": invalid pte address"); */
- PTW_Failure(PTW_Access(), ext_ptw)
- },
- MemValue(v) => {
- let pte = Mk_SV39_PTE(v);
- let pbits = pte.BITS();
- let ext_pte = pte.Ext();
- let pattr = Mk_PTE_Bits(pbits);
- let is_global = global | (pattr.G() == 0b1);
-/* print("walk39(vaddr=" ^ BitStr(vaddr) ^ " level=" ^ string_of_int(level)
- ^ " pt_base=" ^ BitStr(ptb)
- ^ " pt_ofs=" ^ BitStr(pt_ofs)
- ^ " pte_addr=" ^ BitStr(pte_addr)
- ^ " pte=" ^ BitStr(v)); */
- if isInvalidPTE(pbits, ext_pte) then {
-/* print("walk39: invalid pte"); */
- PTW_Failure(PTW_Invalid_PTE(), ext_ptw)
- } else {
- if isPTEPtr(pbits, ext_pte) then {
- if level > 0 then {
- /* walk down the pointer to the next level */
- walk39(vaddr, ac, priv, mxr, do_sum, shiftl(zero_extend(pte.PPNi()), PAGESIZE_BITS), level - 1, is_global, ext_ptw)
- } else {
- /* last-level PTE contains a pointer instead of a leaf */
-/* print("walk39: last-level pte contains a ptr"); */
- PTW_Failure(PTW_Invalid_PTE(), ext_ptw)
- }
- } else { /* leaf PTE */
- match checkPTEPermission(ac, priv, mxr, do_sum, pattr, ext_pte, ext_ptw) {
- PTE_Check_Failure(ext_ptw, ext_ptw_fail) => {
-/* print("walk39: pte permission check failure"); */
- PTW_Failure(ext_get_ptw_error(ext_ptw_fail), ext_ptw)
- },
- PTE_Check_Success(ext_ptw) => {
- if level > 0 then { /* superpage */
- /* fixme hack: to get a mask of appropriate size */
- let mask = shiftl(pte.PPNi() ^ pte.PPNi() ^ zero_extend(0b1), level * SV39_LEVEL_BITS) - 1;
- if (pte.PPNi() & mask) != zero_extend(0b0) then {
- /* misaligned superpage mapping */
-/* print("walk39: misaligned superpage mapping"); */
- PTW_Failure(PTW_Misaligned(), ext_ptw)
- } else {
- /* add the appropriate bits of the VPN to the superpage PPN */
- let ppn = pte.PPNi() | (zero_extend(va.VPNi()) & mask);
-/* let res = append(ppn, va.PgOfs());
- print("walk39: using superpage: pte.ppn=" ^ BitStr(pte.PPNi())
- ^ " ppn=" ^ BitStr(ppn) ^ " res=" ^ BitStr(res)); */
- PTW_Success(append(ppn, va.PgOfs()), pte, pte_addr, level, is_global, ext_ptw)
- }
- } else {
- /* normal leaf PTE */
-/* let res = append(pte.PPNi(), va.PgOfs());
- print("walk39: pte.ppn=" ^ BitStr(pte.PPNi()) ^ " ppn=" ^ BitStr(pte.PPNi()) ^ " res=" ^ BitStr(res)); */
- PTW_Success(append(pte.PPNi(), va.PgOfs()), pte, pte_addr, level, is_global, ext_ptw)
- }
- }
- }
- }
- }
- }
- }
-}
-
-/* TLB management: single entry for now */
-
-// ideally we would use the below form:
-// type TLB39_Entry = TLB_Entry(sizeof(asid64), sizeof(vaddr39), sizeof(paddr64), sizeof(pte64))
-type TLB39_Entry = TLB_Entry(16, 39, 56, 64)
-register tlb39 : option(TLB39_Entry)
-
-val lookup_TLB39 : (asid64, vaddr39) -> option((nat, TLB39_Entry))
-function lookup_TLB39(asid, vaddr) =
- match tlb39 {
- None() => None(),
- Some(e) => if match_TLB_Entry(e, asid, vaddr) then Some((0, e)) else None()
- }
-
-val add_to_TLB39 : (asid64, vaddr39, paddr64, SV39_PTE, paddr64, nat, bool) -> unit
-function add_to_TLB39(asid, vAddr, pAddr, pte, pteAddr, level, global) = {
- let ent : TLB39_Entry = make_TLB_Entry(asid, global, vAddr, pAddr, pte.bits(), level, pteAddr, SV39_LEVEL_BITS);
- tlb39 = Some(ent)
-}
-
-function write_TLB39(idx : nat, ent : TLB39_Entry) -> unit =
- tlb39 = Some(ent)
-
-val flush_TLB39 : (option(asid64), option(vaddr39)) -> unit
-function flush_TLB39(asid, addr) =
- match (tlb39) {
- None() => (),
- Some(e) => if flush_TLB_Entry(e, asid, addr)
- then tlb39 = None()
- else ()
- }
-
-/* address translation */
-
-val translate39 : (asid64, paddr64, vaddr39, AccessType(ext_access_type), Privilege, bool, bool, nat, ext_ptw) -> TR_Result(paddr64, PTW_Error)
-function translate39(asid, ptb, vAddr, ac, priv, mxr, do_sum, level, ext_ptw) = {
- match lookup_TLB39(asid, vAddr) {
- Some(idx, ent) => {
-/* print("translate39: TLB39 hit for " ^ BitStr(vAddr)); */
- let pte = Mk_SV39_PTE(ent.pte);
- let ext_pte = pte.Ext();
- let pteBits = Mk_PTE_Bits(pte.BITS());
- match checkPTEPermission(ac, priv, mxr, do_sum, pteBits, ext_pte, ext_ptw) {
- PTE_Check_Failure(ext_ptw, ext_ptw_fail) => { TR_Failure(ext_get_ptw_error(ext_ptw_fail), ext_ptw) },
- PTE_Check_Success(ext_ptw) => {
- match update_PTE_Bits(pteBits, ac, ext_pte) {
- None() => TR_Address(ent.pAddr | zero_extend(vAddr & ent.vAddrMask), ext_ptw),
- Some(pbits, ext) => {
- if not(plat_enable_dirty_update())
- then {
- /* pte needs dirty/accessed update but that is not enabled */
- TR_Failure(PTW_PTE_Update(), ext_ptw)
- } else {
- /* update PTE entry and TLB */
- n_pte = update_BITS(pte, pbits.bits());
- n_pte = update_Ext(n_pte, ext);
- n_ent : TLB39_Entry = ent;
- n_ent.pte = n_pte.bits();
- write_TLB39(idx, n_ent);
- /* update page table */
- match mem_write_value_priv(zero_extend(ent.pteAddr), 8, n_pte.bits(), Supervisor, false, false, false) {
- MemValue(_) => (),
- MemException(e) => internal_error(__FILE__, __LINE__, "invalid physical address in TLB")
- };
- TR_Address(ent.pAddr | zero_extend(vAddr & ent.vAddrMask), ext_ptw)
- }
- }
- }
- }
- }
- },
- None() => {
- match walk39(vAddr, ac, priv, mxr, do_sum, ptb, level, false, ext_ptw) {
- PTW_Failure(f, ext_ptw) => TR_Failure(f, ext_ptw),
- PTW_Success(pAddr, pte, pteAddr, level, global, ext_ptw) => {
- match update_PTE_Bits(Mk_PTE_Bits(pte.BITS()), ac, pte.Ext()) {
- None() => {
- add_to_TLB39(asid, vAddr, pAddr, pte, pteAddr, level, global);
- TR_Address(pAddr, ext_ptw)
- },
- Some(pbits, ext) =>
- if not(plat_enable_dirty_update())
- then {
- /* pte needs dirty/accessed update but that is not enabled */
- TR_Failure(PTW_PTE_Update(), ext_ptw)
- } else {
- var w_pte : SV39_PTE = update_BITS(pte, pbits.bits());
- w_pte = update_Ext(w_pte, ext);
- match mem_write_value_priv(zero_extend(pteAddr), 8, w_pte.bits(), Supervisor, false, false, false) {
- MemValue(_) => {
- add_to_TLB39(asid, vAddr, pAddr, w_pte, pteAddr, level, global);
- TR_Address(pAddr, ext_ptw)
- },
- MemException(e) => {
- /* pte is not in valid memory */
- TR_Failure(PTW_Access(), ext_ptw)
- }
- }
- }
- }
- }
- }
- }
- }
-}
-
-function init_vmem_sv39() -> unit = {
- tlb39 = None()
-}
diff --git a/model/riscv_vmem_sv48.sail b/model/riscv_vmem_sv48.sail
deleted file mode 100644
index 64c7a54..0000000
--- a/model/riscv_vmem_sv48.sail
+++ /dev/null
@@ -1,218 +0,0 @@
-/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
-/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=======================================================================================*/
-
-/* Sv48 address translation for RV64. */
-
-val walk48 : (vaddr48, AccessType(ext_access_type), Privilege, bool, bool, paddr64, nat, bool, ext_ptw) -> PTW_Result(paddr64, SV48_PTE)
-function walk48(vaddr, ac, priv, mxr, do_sum, ptb, level, global, ext_ptw) = {
- let va = Mk_SV48_Vaddr(vaddr);
- let pt_ofs : paddr64 = shiftl(zero_extend(shiftr(va.VPNi(), (level * SV48_LEVEL_BITS))[(SV48_LEVEL_BITS - 1) .. 0]),
- PTE48_LOG_SIZE);
- let pte_addr = ptb + pt_ofs;
- match (mem_read_priv(Read(Data), Supervisor, zero_extend(pte_addr), 8, false, false, false)) {
- MemException(_) => {
-/* print("walk48(vaddr=" ^ BitStr(vaddr) ^ " level=" ^ string_of_int(level)
- ^ " pt_base=" ^ BitStr(ptb)
- ^ " pt_ofs=" ^ BitStr(pt_ofs)
- ^ " pte_addr=" ^ BitStr(pte_addr)
- ^ ": invalid pte address"); */
- PTW_Failure(PTW_Access(), ext_ptw)
- },
- MemValue(v) => {
- let pte = Mk_SV48_PTE(v);
- let pbits = pte.BITS();
- let ext_pte = pte.Ext();
- let pattr = Mk_PTE_Bits(pbits);
- let is_global = global | (pattr.G() == 0b1);
-/* print("walk48(vaddr=" ^ BitStr(vaddr) ^ " level=" ^ string_of_int(level)
- ^ " pt_base=" ^ BitStr(ptb)
- ^ " pt_ofs=" ^ BitStr(pt_ofs)
- ^ " pte_addr=" ^ BitStr(pte_addr)
- ^ " pte=" ^ BitStr(v)); */
- if isInvalidPTE(pbits, ext_pte) then {
-/* print("walk48: invalid pte"); */
- PTW_Failure(PTW_Invalid_PTE(), ext_ptw)
- } else {
- if isPTEPtr(pbits, ext_pte) then {
- if level > 0 then {
- /* walk down the pointer to the next level */
- walk48(vaddr, ac, priv, mxr, do_sum, shiftl(zero_extend(pte.PPNi()), PAGESIZE_BITS), level - 1, is_global, ext_ptw)
- } else {
- /* last-level PTE contains a pointer instead of a leaf */
-/* print("walk48: last-level pte contains a ptr"); */
- PTW_Failure(PTW_Invalid_PTE(), ext_ptw)
- }
- } else { /* leaf PTE */
- match checkPTEPermission(ac, priv, mxr, do_sum, pattr, ext_pte, ext_ptw) {
- PTE_Check_Failure(ext_ptw, ext_ptw_fail) => {
-/* print("walk48: pte permission check failure"); */
- PTW_Failure(ext_get_ptw_error(ext_ptw_fail), ext_ptw)
- },
- PTE_Check_Success(ext_ptw) => {
- if level > 0 then { /* superpage */
- /* fixme hack: to get a mask of appropriate size */
- let mask = shiftl(pte.PPNi() ^ pte.PPNi() ^ zero_extend(0b1), level * SV48_LEVEL_BITS) - 1;
- if (pte.PPNi() & mask) != zero_extend(0b0) then {
- /* misaligned superpage mapping */
-/* print("walk48: misaligned superpage mapping"); */
- PTW_Failure(PTW_Misaligned(), ext_ptw)
- } else {
- /* add the appropriate bits of the VPN to the superpage PPN */
- let ppn = pte.PPNi() | (zero_extend(va.VPNi()) & mask);
-/* let res = append(ppn, va.PgOfs());
- print("walk48: using superpage: pte.ppn=" ^ BitStr(pte.PPNi())
- ^ " ppn=" ^ BitStr(ppn) ^ " res=" ^ BitStr(res)); */
- PTW_Success(append(ppn, va.PgOfs()), pte, pte_addr, level, is_global, ext_ptw)
- }
- } else {
- /* normal leaf PTE */
-/* let res = append(pte.PPNi(), va.PgOfs());
- print("walk48: pte.ppn=" ^ BitStr(pte.PPNi()) ^ " ppn=" ^ BitStr(pte.PPNi()) ^ " res=" ^ BitStr(res)); */
- PTW_Success(append(pte.PPNi(), va.PgOfs()), pte, pte_addr, level, is_global, ext_ptw)
- }
- }
- }
- }
- }
- }
- }
-}
-
-/* TLB management: single entry for now */
-
-// ideally we would use the below form:
-// type TLB48_Entry = TLB_Entry(sizeof(asid64), sizeof(vaddr48), sizeof(paddr64), sizeof(pte64))
-type TLB48_Entry = TLB_Entry(16, 48, 56, 64)
-register tlb48 : option(TLB48_Entry)
-
-val lookup_TLB48 : (asid64, vaddr48) -> option((nat, TLB48_Entry))
-function lookup_TLB48(asid, vaddr) =
- match tlb48 {
- None() => None(),
- Some(e) => if match_TLB_Entry(e, asid, vaddr) then Some((0, e)) else None()
- }
-
-val add_to_TLB48 : (asid64, vaddr48, paddr64, SV48_PTE, paddr64, nat, bool) -> unit
-function add_to_TLB48(asid, vAddr, pAddr, pte, pteAddr, level, global) = {
- let ent : TLB48_Entry = make_TLB_Entry(asid, global, vAddr, pAddr, pte.bits(), level, pteAddr, SV48_LEVEL_BITS);
- tlb48 = Some(ent)
-}
-
-function write_TLB48(idx : nat, ent : TLB48_Entry) -> unit =
- tlb48 = Some(ent)
-
-val flush_TLB48 : (option(asid64), option(vaddr48)) -> unit
-function flush_TLB48(asid, addr) =
- match (tlb48) {
- None() => (),
- Some(e) => if flush_TLB_Entry(e, asid, addr)
- then tlb48 = None()
- else ()
- }
-
-/* address translation */
-
-val translate48 : (asid64, paddr64, vaddr48, AccessType(ext_access_type), Privilege, bool, bool, nat, ext_ptw) -> TR_Result(paddr64, PTW_Error)
-function translate48(asid, ptb, vAddr, ac, priv, mxr, do_sum, level, ext_ptw) = {
- match walk48(vAddr, ac, priv, mxr, do_sum, ptb, level, false, ext_ptw) {
- PTW_Failure(f, ext_ptw) => TR_Failure(f, ext_ptw),
- PTW_Success(pAddr, pte, pteAddr, level, global, ext_ptw) => {
- match update_PTE_Bits(Mk_PTE_Bits(pte.BITS()), ac, pte.Ext()) {
- None() => {
- add_to_TLB48(asid, vAddr, pAddr, pte, pteAddr, level, global);
- TR_Address(pAddr, ext_ptw)
- },
- Some(pbits, ext) =>
- if not(plat_enable_dirty_update())
- then {
- /* pte needs dirty/accessed update but that is not enabled */
- TR_Failure(PTW_PTE_Update(), ext_ptw)
- } else {
- var w_pte : SV48_PTE = update_BITS(pte, pbits.bits());
- w_pte = update_Ext(w_pte, ext);
- match mem_write_value_priv(zero_extend(pteAddr), 8, w_pte.bits(), Supervisor, false, false, false) {
- MemValue(_) => {
- add_to_TLB48(asid, vAddr, pAddr, w_pte, pteAddr, level, global);
- TR_Address(pAddr, ext_ptw)
- },
- MemException(e) => {
- /* pte is not in valid memory */
- TR_Failure(PTW_Access(), ext_ptw)
- }
- }
- }
- }
- }
- }
-}
-
-function init_vmem_sv48() -> unit = {
- tlb48 = None()
-}
diff --git a/model/riscv_vmem_tlb.sail b/model/riscv_vmem_tlb.sail
index 27b63ba..828fa72 100644
--- a/model/riscv_vmem_tlb.sail
+++ b/model/riscv_vmem_tlb.sail
@@ -1,120 +1,56 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
-/* idealized generic TLB entry to model fence.vm and also speed up simulation. */
+// Although a TLB is not part of the RISC-V Architecture
+// specification, we model a simple TLB so that
+// (1) we can meaningfully test SFENCE.VMA which would be a no-op wihout a TLB;
+// (2) we can greatly speed up simulation speed (for Linux boot, can
+// reduce elapsed time from 10s of minutes to few minutes).
-struct TLB_Entry('asidlen: Int, 'valen: Int, 'palen: Int, 'ptelen: Int) = {
- asid : bits('asidlen),
- global : bool,
- vAddr : bits('valen), /* VPN */
- pAddr : bits('palen), /* PPN */
- vMatchMask : bits('valen), /* matching mask for superpages */
- vAddrMask : bits('valen), /* selection mask for superpages */
- pte : bits('ptelen), /* PTE */
- pteAddr : bits('palen), /* for dirty writeback */
- age : bits(64)
+type asidbits = bits(16)
+
+// PRIVATE
+struct TLB_Entry = {
+ asid : asidbits, // address-space id
+ global : bool, // global translation
+ vAddr : bits(64), // VPN
+ pAddr : bits(64), // ppn
+ vMatchMask : bits(64), // matching mask for superpages
+ vAddrMask : bits(64), // selection mask for superpages
+ pte : bits(64), // PTE
+ pteAddr : bits(64), // for dirty writeback
+ age : bits(64) // for replacement policy?
}
+// Single-entry TLB (could enlarge this in future for better simulation speed)
+// PRIVATE
+register tlb : option(TLB_Entry) = None()
-val make_TLB_Entry : forall 'asidlen 'valen 'palen 'ptelen, 'valen > 0.
- (bits('asidlen), bool, bits('valen), bits('palen), bits('ptelen), nat, bits('palen), nat)
- -> TLB_Entry('asidlen, 'valen, 'palen, 'ptelen)
-function make_TLB_Entry(asid, global, vAddr, pAddr, pte, level, pteAddr, levelBitSize) = {
- let shift : nat = PAGESIZE_BITS + (level * levelBitSize);
- /* fixme hack: use a better idiom for masks */
- let vAddrMask : bits('valen) = shiftl(vAddr ^ vAddr ^ zero_extend(0b1), shift) - 1;
- let vMatchMask : bits('valen) = ~ (vAddrMask);
- struct {
- asid = asid,
- global = global,
- pte = pte,
- pteAddr = pteAddr,
- vAddrMask = vAddrMask,
- vMatchMask = vMatchMask,
- vAddr = vAddr & vMatchMask,
- pAddr = shiftl(shiftr(pAddr, shift), shift),
- age = mcycle
- }
-}
+// PUBLIC: invoked in init_vmem() [riscv_vmem.sail]
+function init_TLB() -> unit =
+ tlb = None()
+
+// PUBLIC: invoked in translate_TLB_hit() [riscv_vmem.sail]
+function write_TLB(idx : nat, ent : TLB_Entry) -> unit =
+ tlb = Some(ent)
-val match_TLB_Entry : forall 'asidlen 'valen 'palen 'ptelen.
- (TLB_Entry('asidlen, 'valen, 'palen, 'ptelen), bits('asidlen), bits('valen))
- -> bool
-function match_TLB_Entry(ent, asid, vaddr) =
- (ent.global | (ent.asid == asid)) & (ent.vAddr == (ent.vMatchMask & vaddr))
+// PRIVATE
+function match_TLB_Entry(ent : TLB_Entry,
+ asid : asidbits,
+ vaddr : bits(64)) -> bool =
+ (ent.global | (ent.asid == asid))
+ & (ent.vAddr == (ent.vMatchMask & vaddr))
-val flush_TLB_Entry : forall 'asidlen 'valen 'palen 'ptelen.
- (TLB_Entry('asidlen, 'valen, 'palen, 'ptelen), option(bits('asidlen)), option(bits('valen)))
- -> bool
-function flush_TLB_Entry(e, asid, addr) = {
- match(asid, addr) {
+// PRIVATE
+function flush_TLB_Entry(e : TLB_Entry,
+ asid : option(asidbits),
+ addr : option(bits(64))) -> bool = {
+ match (asid, addr) {
( None(), None()) => true,
( None(), Some(a)) => e.vAddr == (e.vMatchMask & a),
(Some(i), None()) => (e.asid == i) & not(e.global),
@@ -122,3 +58,58 @@ function flush_TLB_Entry(e, asid, addr) = {
& not(e.global))
}
}
+
+// PUBLIC: invoked in translate() [riscv_vmem.sail]
+function lookup_TLB (asid : asidbits, vaddr : bits(64)) -> option((nat, TLB_Entry)) =
+ match tlb {
+ None() => None(),
+ Some(e) => if match_TLB_Entry(e, asid, vaddr) then Some((0, e)) else None()
+ }
+
+// PRIVATE
+function add_to_TLB(asid : asidbits,
+ vAddr : bits(64),
+ pAddr : bits(64),
+ pte : bits(64),
+ pteAddr : bits(64),
+ level : nat,
+ global : bool,
+ levelBitSize : nat,
+ PAGESIZE_BITS : nat) -> unit = {
+ let shift = PAGESIZE_BITS + (level * levelBitSize);
+ assert(shift <= 64);
+ let vAddrMask : bits(64) = zero_extend(ones(shift));
+ let vMatchMask : bits(64) = ~ (vAddrMask);
+ let entry : TLB_Entry = struct{asid = asid,
+ global = global,
+ pte = pte,
+ pteAddr = pteAddr,
+ vAddrMask = vAddrMask,
+ vMatchMask = vMatchMask,
+ vAddr = vAddr & vMatchMask,
+ pAddr = shiftl(shiftr(pAddr, shift), shift),
+ age = mcycle};
+ tlb = Some(entry)
+}
+
+// Top-level TLB flush function
+// PUBLIC: invoked from exec SFENCE_VMA
+function flush_TLB(asid_xlen : option(xlenbits),
+ addr_xlen : option(xlenbits)) -> unit = {
+ let asid : option(asidbits) =
+ match asid_xlen {
+ None() => None(),
+ Some(a) => Some(a[15 .. 0])
+ };
+ let addr_64b : option(bits(64)) =
+ match addr_xlen {
+ None() => None(),
+ Some(a) => Some(zero_extend(a))
+ };
+ match tlb {
+ None() => (),
+ Some(e) => if flush_TLB_Entry(e, asid, addr_64b)
+ then tlb = None()
+ else ()
+ }
+}
diff --git a/model/riscv_vmem_types.sail b/model/riscv_vmem_types.sail
index 15cb95b..da1e053 100644
--- a/model/riscv_vmem_types.sail
+++ b/model/riscv_vmem_types.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
// Extensions for memory Accesstype.
diff --git a/model/riscv_vreg_type.sail b/model/riscv_vreg_type.sail
index f8025b4..baed7fa 100755
--- a/model/riscv_vreg_type.sail
+++ b/model/riscv_vreg_type.sail
@@ -1,40 +1,10 @@
-/*=================================================================================*/
-/* Copyright (c) 2021-2023 */
-/* Authors from RIOS Lab, Tsinghua University: */
-/* Xinlai Wan <xinlai.w@rioslab.org> */
-/* Xi Wang <xi.w@rioslab.org> */
-/* Yifei Zhu <yifei.z@rioslab.org> */
-/* Shenwei Hu <shenwei.h@rioslab.org> */
-/* Kalvin Vu */
-/* Other contributors: */
-/* Jessica Clarke <jrtc27@jrtc27.com> */
-/* Victor Moya <victor.moya@semidynamics.com> */
-/* */
-/* All rights reserved. */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
-/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
-/*=================================================================================*/
+/*=======================================================================================*/
+/* This Sail RISC-V architecture model, comprising all files and */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
+/* */
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*=======================================================================================*/
/* Definitions for vector registers (V extension) */
diff --git a/model/riscv_xlen32.sail b/model/riscv_xlen32.sail
index eb0ae8a..fb883ac 100644
--- a/model/riscv_xlen32.sail
+++ b/model/riscv_xlen32.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Define the XLEN value for the architecture. */
diff --git a/model/riscv_xlen64.sail b/model/riscv_xlen64.sail
index 65c4696..7a90307 100644
--- a/model/riscv_xlen64.sail
+++ b/model/riscv_xlen64.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
/* Define the XLEN value for the architecture. */
diff --git a/model/rvfi_dii.sail b/model/rvfi_dii.sail
index e1007bb..d1ad480 100644
--- a/model/rvfi_dii.sail
+++ b/model/rvfi_dii.sail
@@ -1,71 +1,9 @@
/*=======================================================================================*/
-/* RISCV Sail Model */
-/* */
/* This Sail RISC-V architecture model, comprising all files and */
-/* directories except for the snapshots of the Lem and Sail libraries */
-/* in the prover_snapshots directory (which include copies of their */
-/* licences), is subject to the BSD two-clause licence below. */
-/* */
-/* Copyright (c) 2017-2023 */
-/* Prashanth Mundkur */
-/* Rishiyur S. Nikhil and Bluespec, Inc. */
-/* Jon French */
-/* Brian Campbell */
-/* Robert Norton-Wright */
-/* Alasdair Armstrong */
-/* Thomas Bauereiss */
-/* Shaked Flur */
-/* Christopher Pulte */
-/* Peter Sewell */
-/* Alexander Richardson */
-/* Hesham Almatary */
-/* Jessica Clarke */
-/* Microsoft, for contributions by Robert Norton-Wright and Nathaniel Wesley Filardo */
-/* Peter Rugg */
-/* Aril Computer Corp., for contributions by Scott Johnson */
-/* Philipp Tomsich */
-/* VRULL GmbH, for contributions by its employees */
-/* */
-/* All rights reserved. */
-/* */
-/* This software was developed by the above within the Rigorous */
-/* Engineering of Mainstream Systems (REMS) project, partly funded by */
-/* EPSRC grant EP/K008528/1, at the Universities of Cambridge and */
-/* Edinburgh. */
-/* */
-/* This software was developed by SRI International and the University of */
-/* Cambridge Computer Laboratory (Department of Computer Science and */
-/* Technology) under DARPA/AFRL contract FA8650-18-C-7809 ("CIFV"), and */
-/* under DARPA contract HR0011-18-C-0016 ("ECATS") as part of the DARPA */
-/* SSITH research programme. */
-/* */
-/* This project has received funding from the European Research Council */
-/* (ERC) under the European Union’s Horizon 2020 research and innovation */
-/* programme (grant agreement 789108, ELVER). */
-/* */
-/* */
-/* Redistribution and use in source and binary forms, with or without */
-/* modification, are permitted provided that the following conditions */
-/* are met: */
-/* 1. Redistributions of source code must retain the above copyright */
-/* notice, this list of conditions and the following disclaimer. */
-/* 2. Redistributions in binary form must reproduce the above copyright */
-/* notice, this list of conditions and the following disclaimer in */
-/* the documentation and/or other materials provided with the */
-/* distribution. */
+/* directories except where otherwise noted is subject the BSD */
+/* two-clause license in the LICENSE file. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */
-/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
-/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
-/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */
-/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
-/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
-/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */
-/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */
-/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
-/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
-/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */
-/* SUCH DAMAGE. */
+/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
// "RISC-V Formal Interface - Direct Instruction Injection" support
@@ -93,18 +31,18 @@ function rvfi_set_instr_packet(p) =
val rvfi_get_cmd : unit -> bits(8)
-function rvfi_get_cmd () = rvfi_instruction.rvfi_cmd()
+function rvfi_get_cmd () = rvfi_instruction[rvfi_cmd]
val rvfi_get_insn : unit -> bits(32)
-function rvfi_get_insn () = rvfi_instruction.rvfi_insn()
+function rvfi_get_insn () = rvfi_instruction[rvfi_insn]
val print_instr_packet : bits(64) -> unit
function print_instr_packet(bs) = {
let p = Mk_RVFI_DII_Instruction_Packet(bs);
- print_bits("command ", p.rvfi_cmd());
- print_bits("instruction ", p.rvfi_insn())
+ print_bits("command ", p[rvfi_cmd]);
+ print_bits("instruction ", p[rvfi_insn])
}
bitfield RVFI_DII_Execution_Packet_V1 : bits(704) = {
@@ -291,36 +229,36 @@ function rvfi_get_v2_support_packet () = {
// backwards compatibility with old implementations that do not support
// the new trace format.
let rvfi_exec = update_rvfi_halt(rvfi_exec, 0x03);
- return rvfi_exec.bits();
+ return rvfi_exec.bits;
}
val rvfi_get_exec_packet_v1 : unit -> bits(704)
function rvfi_get_exec_packet_v1 () = {
let v1_packet = Mk_RVFI_DII_Execution_Packet_V1(zero_extend(0b0));
// Convert the v2 packet to a v1 packet
- let v1_packet = update_rvfi_intr(v1_packet, rvfi_inst_data.rvfi_intr());
- let v1_packet = update_rvfi_halt(v1_packet, rvfi_inst_data.rvfi_halt());
- let v1_packet = update_rvfi_trap(v1_packet, rvfi_inst_data.rvfi_trap());
- let v1_packet = update_rvfi_insn(v1_packet, rvfi_inst_data.rvfi_insn());
- let v1_packet = update_rvfi_order(v1_packet, rvfi_inst_data.rvfi_order());
+ let v1_packet = update_rvfi_intr(v1_packet, rvfi_inst_data[rvfi_intr]);
+ let v1_packet = update_rvfi_halt(v1_packet, rvfi_inst_data[rvfi_halt]);
+ let v1_packet = update_rvfi_trap(v1_packet, rvfi_inst_data[rvfi_trap]);
+ let v1_packet = update_rvfi_insn(v1_packet, rvfi_inst_data[rvfi_insn]);
+ let v1_packet = update_rvfi_order(v1_packet, rvfi_inst_data[rvfi_order]);
- let v1_packet = update_rvfi_pc_wdata(v1_packet, rvfi_pc_data.rvfi_pc_wdata());
- let v1_packet = update_rvfi_pc_rdata(v1_packet, rvfi_pc_data.rvfi_pc_rdata());
+ let v1_packet = update_rvfi_pc_wdata(v1_packet, rvfi_pc_data[rvfi_pc_wdata]);
+ let v1_packet = update_rvfi_pc_rdata(v1_packet, rvfi_pc_data[rvfi_pc_rdata]);
- let v1_packet = update_rvfi_rd_addr(v1_packet, rvfi_int_data.rvfi_rd_addr());
+ let v1_packet = update_rvfi_rd_addr(v1_packet, rvfi_int_data[rvfi_rd_addr]);
let v1_packet = update_rvfi_rs2_addr(v1_packet, rvfi_int_data.rvfi_rs2_addr());
let v1_packet = update_rvfi_rs1_addr(v1_packet, rvfi_int_data.rvfi_rs1_addr());
- let v1_packet = update_rvfi_rd_wdata(v1_packet, rvfi_int_data.rvfi_rd_wdata());
+ let v1_packet = update_rvfi_rd_wdata(v1_packet, rvfi_int_data[rvfi_rd_wdata]);
let v1_packet = update_rvfi_rs2_data(v1_packet, rvfi_int_data.rvfi_rs2_rdata());
let v1_packet = update_rvfi_rs1_data(v1_packet, rvfi_int_data.rvfi_rs1_rdata());
- let v1_packet = update_rvfi_mem_wmask(v1_packet, truncate(rvfi_mem_data.rvfi_mem_wmask(), 8));
- let v1_packet = update_rvfi_mem_rmask(v1_packet, truncate(rvfi_mem_data.rvfi_mem_rmask(), 8));
- let v1_packet = update_rvfi_mem_wdata(v1_packet, truncate(rvfi_mem_data.rvfi_mem_wdata(), 64));
- let v1_packet = update_rvfi_mem_rdata(v1_packet, truncate(rvfi_mem_data.rvfi_mem_rdata(), 64));
- let v1_packet = update_rvfi_mem_addr(v1_packet, rvfi_mem_data.rvfi_mem_addr());
+ let v1_packet = update_rvfi_mem_wmask(v1_packet, truncate(rvfi_mem_data[rvfi_mem_wmask], 8));
+ let v1_packet = update_rvfi_mem_rmask(v1_packet, truncate(rvfi_mem_data[rvfi_mem_rmask], 8));
+ let v1_packet = update_rvfi_mem_wdata(v1_packet, truncate(rvfi_mem_data[rvfi_mem_wdata], 64));
+ let v1_packet = update_rvfi_mem_rdata(v1_packet, truncate(rvfi_mem_data[rvfi_mem_rdata], 64));
+ let v1_packet = update_rvfi_mem_addr(v1_packet, rvfi_mem_data[rvfi_mem_addr]);
- return v1_packet.bits();
+ return v1_packet.bits;
}
val rvfi_get_v2_trace_size : unit -> bits(64)
@@ -337,30 +275,30 @@ function rvfi_get_exec_packet_v2 () = {
// TODO: find a way to return a variable-length bitvector
let packet = Mk_RVFI_DII_Execution_PacketV2(zero_extend(0b0));
let packet = update_magic(packet, 0x32762d6563617274); // ASCII "trace-v2" (BE)
- let packet = update_basic_data(packet, rvfi_inst_data.bits());
- let packet = update_pc_data(packet, rvfi_pc_data.bits());
+ let packet = update_basic_data(packet, rvfi_inst_data.bits);
+ let packet = update_pc_data(packet, rvfi_pc_data.bits);
let packet = update_integer_data_available(packet, bool_to_bits(rvfi_int_data_present));
let packet = update_memory_access_data_available(packet, bool_to_bits(rvfi_mem_data_present));
// To simplify the implementation (so that we can return a fixed-size vector)
// we always return a max-size packet from this function, and the C emulator
// ensures that only trace_size bits are sent over the socket.
let packet = update_trace_size(packet, rvfi_get_v2_trace_size());
- return packet.bits();
+ return packet.bits;
}
val rvfi_get_int_data : unit -> bits(320)
function rvfi_get_int_data () = {
assert(rvfi_int_data_present, "reading uninitialized data");
- return rvfi_int_data.bits();
+ return rvfi_int_data.bits;
}
val rvfi_get_mem_data : unit -> bits(704)
function rvfi_get_mem_data () = {
assert(rvfi_mem_data_present, "reading uninitialized data");
- return rvfi_mem_data.bits();
+ return rvfi_mem_data.bits;
}
-val rvfi_encode_width_mask : forall 'n, 0 < 'n <= 32. atom('n) -> bits(32)
+val rvfi_encode_width_mask : forall 'n, 0 < 'n <= 32. int('n) -> bits(32)
function rvfi_encode_width_mask(width) =
(0xFFFFFFFF >> (32 - width))
@@ -368,22 +306,22 @@ function rvfi_encode_width_mask(width) =
val print_rvfi_exec : unit -> unit
function print_rvfi_exec () = {
- print_bits("rvfi_intr : ", rvfi_inst_data.rvfi_intr());
- print_bits("rvfi_halt : ", rvfi_inst_data.rvfi_halt());
- print_bits("rvfi_trap : ", rvfi_inst_data.rvfi_trap());
- print_bits("rvfi_rd_addr : ", rvfi_int_data.rvfi_rd_addr());
+ print_bits("rvfi_intr : ", rvfi_inst_data[rvfi_intr]);
+ print_bits("rvfi_halt : ", rvfi_inst_data[rvfi_halt]);
+ print_bits("rvfi_trap : ", rvfi_inst_data[rvfi_trap]);
+ print_bits("rvfi_rd_addr : ", rvfi_int_data[rvfi_rd_addr]);
print_bits("rvfi_rs2_addr : ", rvfi_int_data.rvfi_rs2_addr());
print_bits("rvfi_rs1_addr : ", rvfi_int_data.rvfi_rs1_addr());
- print_bits("rvfi_mem_wmask: ", rvfi_mem_data.rvfi_mem_wmask());
- print_bits("rvfi_mem_rmask: ", rvfi_mem_data.rvfi_mem_rmask());
- print_bits("rvfi_mem_wdata: ", rvfi_mem_data.rvfi_mem_wdata());
- print_bits("rvfi_mem_rdata: ", rvfi_mem_data.rvfi_mem_rdata());
- print_bits("rvfi_mem_addr : ", rvfi_mem_data.rvfi_mem_addr());
- print_bits("rvfi_rd_wdata : ", rvfi_int_data.rvfi_rd_wdata());
+ print_bits("rvfi_mem_wmask: ", rvfi_mem_data[rvfi_mem_wmask]);
+ print_bits("rvfi_mem_rmask: ", rvfi_mem_data[rvfi_mem_rmask]);
+ print_bits("rvfi_mem_wdata: ", rvfi_mem_data[rvfi_mem_wdata]);
+ print_bits("rvfi_mem_rdata: ", rvfi_mem_data[rvfi_mem_rdata]);
+ print_bits("rvfi_mem_addr : ", rvfi_mem_data[rvfi_mem_addr]);
+ print_bits("rvfi_rd_wdata : ", rvfi_int_data[rvfi_rd_wdata]);
print_bits("rvfi_rs2_data : ", rvfi_int_data.rvfi_rs2_rdata());
print_bits("rvfi_rs1_data : ", rvfi_int_data.rvfi_rs1_rdata());
- print_bits("rvfi_insn : ", rvfi_inst_data.rvfi_insn());
- print_bits("rvfi_pc_wdata : ", rvfi_pc_data.rvfi_pc_wdata());
- print_bits("rvfi_pc_rdata : ", rvfi_pc_data.rvfi_pc_rdata());
- print_bits("rvfi_order : ", rvfi_inst_data.rvfi_order());
+ print_bits("rvfi_insn : ", rvfi_inst_data[rvfi_insn]);
+ print_bits("rvfi_pc_wdata : ", rvfi_pc_data[rvfi_pc_wdata]);
+ print_bits("rvfi_pc_rdata : ", rvfi_pc_data[rvfi_pc_rdata]);
+ print_bits("rvfi_order : ", rvfi_inst_data[rvfi_order]);
}
diff --git a/ocaml_emulator/platform.ml b/ocaml_emulator/platform.ml
index e4dbfeb..2f0aaaf 100644
--- a/ocaml_emulator/platform.ml
+++ b/ocaml_emulator/platform.ml
@@ -10,9 +10,14 @@ let config_enable_writable_misa = ref true
let config_enable_dirty_update = ref false
let config_enable_misaligned_access = ref false
let config_mtval_has_illegal_inst_bits = ref false
-let config_enable_pmp = ref false
+let config_enable_zcb = ref false
let config_enable_writable_fiom = ref true
let config_enable_vext = ref true
+let config_pmp_count = ref Big_int.zero
+let config_pmp_grain = ref Big_int.zero
+
+let set_config_pmp_count x = config_pmp_count := Big_int.of_int x
+let set_config_pmp_grain x = config_pmp_grain := Big_int.of_int x
let platform_arch = ref P.RV64
@@ -84,9 +89,11 @@ let enable_vext () = !config_enable_vext
let enable_dirty_update () = !config_enable_dirty_update
let enable_misaligned_access () = !config_enable_misaligned_access
let mtval_has_illegal_inst_bits () = !config_mtval_has_illegal_inst_bits
-let enable_pmp () = !config_enable_pmp
+let enable_zcb () = !config_enable_zcb
let enable_zfinx () = false
let enable_writable_fiom () = !config_enable_writable_fiom
+let pmp_count () = !config_pmp_count
+let pmp_grain () = !config_pmp_grain
let rom_base () = arch_bits_of_int64 P.rom_base
let rom_size () = arch_bits_of_int !rom_size_ref
diff --git a/ocaml_emulator/riscv_ocaml_sim.ml b/ocaml_emulator/riscv_ocaml_sim.ml
index c151d69..8dad8a4 100644
--- a/ocaml_emulator/riscv_ocaml_sim.ml
+++ b/ocaml_emulator/riscv_ocaml_sim.ml
@@ -41,15 +41,21 @@ let options = Arg.align ([("-dump-dts",
("-enable-misaligned-access",
Arg.Set P.config_enable_misaligned_access,
" enable misaligned accesses without M-mode traps");
- ("-enable-pmp",
- Arg.Set P.config_enable_pmp,
- " enable PMP support");
+ ("-pmp-count",
+ Arg.Int P.set_config_pmp_count,
+ " number of supported PMPs (0, 16, 64)");
+ ("-pmp-grain",
+ Arg.Int P.set_config_pmp_grain,
+ " exponent of granularity of PMP addresses (G in the spec)");
("-enable-next",
Arg.Set P.config_enable_next,
" enable N extension");
("-mtval-has-illegal-inst-bits",
Arg.Set P.config_mtval_has_illegal_inst_bits,
" mtval stores instruction bits on an illegal instruction exception");
+ ("-enable-zcb",
+ Arg.Set P.config_enable_zcb,
+ " enable Zcb (simple code size) extension");
("-enable-writable-fiom",
Arg.Set P.config_enable_writable_fiom,
" enable FIOM (Fence of I/O implies Memory) bit in menvcfg");
diff --git a/sail-riscv.install b/sail-riscv.install
index 5a83673..7a539df 100644
--- a/sail-riscv.install
+++ b/sail-riscv.install
@@ -1,2 +1,2 @@
bin: ["c_emulator/riscv_sim_RV64" "c_emulator/riscv_sim_RV32"]
-share: [ "model/main.sail" {"model/main.sail"} "model/prelude.sail" {"model/prelude.sail"} "model/prelude_mapping.sail" {"model/prelude_mapping.sail"} "model/prelude_mem.sail" {"model/prelude_mem.sail"} "model/prelude_mem_metadata.sail" {"model/prelude_mem_metadata.sail"} "model/riscv_addr_checks.sail" {"model/riscv_addr_checks.sail"} "model/riscv_addr_checks_common.sail" {"model/riscv_addr_checks_common.sail"} "model/riscv_analysis.sail" {"model/riscv_analysis.sail"} "model/riscv_csr_ext.sail" {"model/riscv_csr_ext.sail"} "model/riscv_csr_map.sail" {"model/riscv_csr_map.sail"} "model/riscv_decode_ext.sail" {"model/riscv_decode_ext.sail"} "model/riscv_ext_regs.sail" {"model/riscv_ext_regs.sail"} "model/riscv_fdext_control.sail" {"model/riscv_fdext_control.sail"} "model/riscv_fdext_regs.sail" {"model/riscv_fdext_regs.sail"} "model/riscv_fetch.sail" {"model/riscv_fetch.sail"} "model/riscv_fetch_rvfi.sail" {"model/riscv_fetch_rvfi.sail"} "model/riscv_flen_D.sail" {"model/riscv_flen_D.sail"} "model/riscv_flen_F.sail" {"model/riscv_flen_F.sail"} "model/riscv_freg_type.sail" {"model/riscv_freg_type.sail"} "model/riscv_insts_aext.sail" {"model/riscv_insts_aext.sail"} "model/riscv_insts_base.sail" {"model/riscv_insts_base.sail"} "model/riscv_insts_begin.sail" {"model/riscv_insts_begin.sail"} "model/riscv_insts_cdext.sail" {"model/riscv_insts_cdext.sail"} "model/riscv_insts_cext.sail" {"model/riscv_insts_cext.sail"} "model/riscv_insts_cfext.sail" {"model/riscv_insts_cfext.sail"} "model/riscv_insts_dext.sail" {"model/riscv_insts_dext.sail"} "model/riscv_insts_end.sail" {"model/riscv_insts_end.sail"} "model/riscv_insts_fext.sail" {"model/riscv_insts_fext.sail"} "model/riscv_insts_hints.sail" {"model/riscv_insts_hints.sail"} "model/riscv_insts_mext.sail" {"model/riscv_insts_mext.sail"} "model/riscv_insts_next.sail" {"model/riscv_insts_next.sail"} "model/riscv_insts_rmem.sail" {"model/riscv_insts_rmem.sail"} "model/riscv_insts_zba.sail" {"model/riscv_insts_zba.sail"} "model/riscv_insts_zbb.sail" {"model/riscv_insts_zbb.sail"} "model/riscv_insts_zbc.sail" {"model/riscv_insts_zbc.sail"} "model/riscv_insts_zbkb.sail" {"model/riscv_insts_zbkb.sail"} "model/riscv_insts_zbkx.sail" {"model/riscv_insts_zbkx.sail"} "model/riscv_insts_zbs.sail" {"model/riscv_insts_zbs.sail"} "model/riscv_insts_zfh.sail" {"model/riscv_insts_zfh.sail"} "model/riscv_insts_zicsr.sail" {"model/riscv_insts_zicsr.sail"} "model/riscv_insts_zkn.sail" {"model/riscv_insts_zkn.sail"} "model/riscv_insts_zks.sail" {"model/riscv_insts_zks.sail"} "model/riscv_jalr_rmem.sail" {"model/riscv_jalr_rmem.sail"} "model/riscv_jalr_seq.sail" {"model/riscv_jalr_seq.sail"} "model/riscv_mem.sail" {"model/riscv_mem.sail"} "model/riscv_misa_ext.sail" {"model/riscv_misa_ext.sail"} "model/riscv_next_control.sail" {"model/riscv_next_control.sail"} "model/riscv_next_regs.sail" {"model/riscv_next_regs.sail"} "model/riscv_pc_access.sail" {"model/riscv_pc_access.sail"} "model/riscv_platform.sail" {"model/riscv_platform.sail"} "model/riscv_pmp_control.sail" {"model/riscv_pmp_control.sail"} "model/riscv_pmp_regs.sail" {"model/riscv_pmp_regs.sail"} "model/riscv_pte.sail" {"model/riscv_pte.sail"} "model/riscv_ptw.sail" {"model/riscv_ptw.sail"} "model/riscv_reg_type.sail" {"model/riscv_reg_type.sail"} "model/riscv_regs.sail" {"model/riscv_regs.sail"} "model/riscv_softfloat_interface.sail" {"model/riscv_softfloat_interface.sail"} "model/riscv_step.sail" {"model/riscv_step.sail"} "model/riscv_step_common.sail" {"model/riscv_step_common.sail"} "model/riscv_step_ext.sail" {"model/riscv_step_ext.sail"} "model/riscv_step_rvfi.sail" {"model/riscv_step_rvfi.sail"} "model/riscv_sync_exception.sail" {"model/riscv_sync_exception.sail"} "model/riscv_sys_control.sail" {"model/riscv_sys_control.sail"} "model/riscv_sys_exceptions.sail" {"model/riscv_sys_exceptions.sail"} "model/riscv_sys_regs.sail" {"model/riscv_sys_regs.sail"} "model/riscv_termination_common.sail" {"model/riscv_termination_common.sail"} "model/riscv_termination_rv32.sail" {"model/riscv_termination_rv32.sail"} "model/riscv_termination_rv64.sail" {"model/riscv_termination_rv64.sail"} "model/riscv_types.sail" {"model/riscv_types.sail"} "model/riscv_types_common.sail" {"model/riscv_types_common.sail"} "model/riscv_types_ext.sail" {"model/riscv_types_ext.sail"} "model/riscv_types_kext.sail" {"model/riscv_types_kext.sail"} "model/riscv_vmem_common.sail" {"model/riscv_vmem_common.sail"} "model/riscv_vmem_rv32.sail" {"model/riscv_vmem_rv32.sail"} "model/riscv_vmem_rv64.sail" {"model/riscv_vmem_rv64.sail"} "model/riscv_vmem_sv32.sail" {"model/riscv_vmem_sv32.sail"} "model/riscv_vmem_sv39.sail" {"model/riscv_vmem_sv39.sail"} "model/riscv_vmem_sv48.sail" {"model/riscv_vmem_sv48.sail"} "model/riscv_vmem_tlb.sail" {"model/riscv_vmem_tlb.sail"} "model/riscv_vmem_types.sail" {"model/riscv_vmem_types.sail"} "model/riscv_xlen32.sail" {"model/riscv_xlen32.sail"} "model/riscv_xlen64.sail" {"model/riscv_xlen64.sail"} "model/rvfi_dii.sail" {"model/rvfi_dii.sail"} "c_emulator/riscv_platform.c" {"c_emulator/riscv_platform.c"} "c_emulator/riscv_platform_impl.c" {"c_emulator/riscv_platform_impl.c"} "c_emulator/riscv_prelude.c" {"c_emulator/riscv_prelude.c"} "c_emulator/riscv_sim.c" {"c_emulator/riscv_sim.c"} "c_emulator/riscv_softfloat.c" {"c_emulator/riscv_softfloat.c"} "c_emulator/riscv_config.h" {"c_emulator/riscv_config.h"} "c_emulator/riscv_platform.h" {"c_emulator/riscv_platform.h"} "c_emulator/riscv_platform_impl.h" {"c_emulator/riscv_platform_impl.h"} "c_emulator/riscv_prelude.h" {"c_emulator/riscv_prelude.h"} "c_emulator/riscv_sail.h" {"c_emulator/riscv_sail.h"} "c_emulator/riscv_softfloat.h" {"c_emulator/riscv_softfloat.h"} "handwritten_support/mem_metadata.lem" {"handwritten_support/mem_metadata.lem"} "handwritten_support/riscv_extras.lem" {"handwritten_support/riscv_extras.lem"} "handwritten_support/riscv_extras_fdext.lem" {"handwritten_support/riscv_extras_fdext.lem"} "handwritten_support/riscv_extras_sequential.lem" {"handwritten_support/riscv_extras_sequential.lem"} "handwritten_support/hgen/ast.hgen" {"handwritten_support/hgen/ast.hgen"} "handwritten_support/hgen/fold.hgen" {"handwritten_support/hgen/fold.hgen"} "handwritten_support/hgen/herdtools_ast_to_shallow_ast.hgen" {"handwritten_support/hgen/herdtools_ast_to_shallow_ast.hgen"} "handwritten_support/hgen/herdtools_types_to_shallow_types.hgen" {"handwritten_support/hgen/herdtools_types_to_shallow_types.hgen"} "handwritten_support/hgen/lexer.hgen" {"handwritten_support/hgen/lexer.hgen"} "handwritten_support/hgen/lexer_regexps.hgen" {"handwritten_support/hgen/lexer_regexps.hgen"} "handwritten_support/hgen/map.hgen" {"handwritten_support/hgen/map.hgen"} "handwritten_support/hgen/parser.hgen" {"handwritten_support/hgen/parser.hgen"} "handwritten_support/hgen/pretty.hgen" {"handwritten_support/hgen/pretty.hgen"} "handwritten_support/hgen/pretty_xml.hgen" {"handwritten_support/hgen/pretty_xml.hgen"} "handwritten_support/hgen/sail_trans_out.hgen" {"handwritten_support/hgen/sail_trans_out.hgen"} "handwritten_support/hgen/shallow_ast_to_herdtools_ast.hgen" {"handwritten_support/hgen/shallow_ast_to_herdtools_ast.hgen"} "handwritten_support/hgen/shallow_types_to_herdtools_types.hgen" {"handwritten_support/hgen/shallow_types_to_herdtools_types.hgen"} "handwritten_support/hgen/token_types.hgen" {"handwritten_support/hgen/token_types.hgen"} "handwritten_support/hgen/tokens.hgen" {"handwritten_support/hgen/tokens.hgen"} "handwritten_support/hgen/trans_sail.hgen" {"handwritten_support/hgen/trans_sail.hgen"} "handwritten_support/hgen/types.hgen" {"handwritten_support/hgen/types.hgen"} "handwritten_support/hgen/types_sail_trans_out.hgen" {"handwritten_support/hgen/types_sail_trans_out.hgen"} "handwritten_support/hgen/types_trans_sail.hgen" {"handwritten_support/hgen/types_trans_sail.hgen"} "handwritten_support/0.11/mem_metadata.lem" {"handwritten_support/0.11/mem_metadata.lem"} "handwritten_support/0.11/riscv_extras.lem" {"handwritten_support/0.11/riscv_extras.lem"} "handwritten_support/0.11/riscv_extras_fdext.lem" {"handwritten_support/0.11/riscv_extras_fdext.lem"} "handwritten_support/0.11/riscv_extras_sequential.lem" {"handwritten_support/0.11/riscv_extras_sequential.lem"} "generated_definitions/for-rmem/riscv.lem" {"generated_definitions/for-rmem/riscv.lem"} "generated_definitions/for-rmem/riscv_types.lem" {"generated_definitions/for-rmem/riscv_types.lem"} "generated_definitions/for-rmem/riscv_toFromInterp2.ml" {"generated_definitions/for-rmem/riscv_toFromInterp2.ml"} "generated_definitions/for-rmem/riscv.defs" {"generated_definitions/for-rmem/riscv.defs"} ]
+share: [ "model/main.sail" {"model/main.sail"} "model/prelude.sail" {"model/prelude.sail"} "model/prelude_mem.sail" {"model/prelude_mem.sail"} "model/prelude_mem_metadata.sail" {"model/prelude_mem_metadata.sail"} "model/riscv_addr_checks.sail" {"model/riscv_addr_checks.sail"} "model/riscv_addr_checks_common.sail" {"model/riscv_addr_checks_common.sail"} "model/riscv_analysis.sail" {"model/riscv_analysis.sail"} "model/riscv_csr_ext.sail" {"model/riscv_csr_ext.sail"} "model/riscv_csr_map.sail" {"model/riscv_csr_map.sail"} "model/riscv_decode_ext.sail" {"model/riscv_decode_ext.sail"} "model/riscv_ext_regs.sail" {"model/riscv_ext_regs.sail"} "model/riscv_fdext_control.sail" {"model/riscv_fdext_control.sail"} "model/riscv_fdext_regs.sail" {"model/riscv_fdext_regs.sail"} "model/riscv_fetch.sail" {"model/riscv_fetch.sail"} "model/riscv_fetch_rvfi.sail" {"model/riscv_fetch_rvfi.sail"} "model/riscv_flen_D.sail" {"model/riscv_flen_D.sail"} "model/riscv_flen_F.sail" {"model/riscv_flen_F.sail"} "model/riscv_freg_type.sail" {"model/riscv_freg_type.sail"} "model/riscv_insts_aext.sail" {"model/riscv_insts_aext.sail"} "model/riscv_insts_base.sail" {"model/riscv_insts_base.sail"} "model/riscv_insts_begin.sail" {"model/riscv_insts_begin.sail"} "model/riscv_insts_cdext.sail" {"model/riscv_insts_cdext.sail"} "model/riscv_insts_cext.sail" {"model/riscv_insts_cext.sail"} "model/riscv_insts_cfext.sail" {"model/riscv_insts_cfext.sail"} "model/riscv_insts_dext.sail" {"model/riscv_insts_dext.sail"} "model/riscv_insts_end.sail" {"model/riscv_insts_end.sail"} "model/riscv_insts_fext.sail" {"model/riscv_insts_fext.sail"} "model/riscv_insts_hints.sail" {"model/riscv_insts_hints.sail"} "model/riscv_insts_mext.sail" {"model/riscv_insts_mext.sail"} "model/riscv_insts_next.sail" {"model/riscv_insts_next.sail"} "model/riscv_insts_rmem.sail" {"model/riscv_insts_rmem.sail"} "model/riscv_insts_zba.sail" {"model/riscv_insts_zba.sail"} "model/riscv_insts_zbb.sail" {"model/riscv_insts_zbb.sail"} "model/riscv_insts_zbc.sail" {"model/riscv_insts_zbc.sail"} "model/riscv_insts_zbkb.sail" {"model/riscv_insts_zbkb.sail"} "model/riscv_insts_zbkx.sail" {"model/riscv_insts_zbkx.sail"} "model/riscv_insts_zbs.sail" {"model/riscv_insts_zbs.sail"} "model/riscv_insts_zfh.sail" {"model/riscv_insts_zfh.sail"} "model/riscv_insts_zicsr.sail" {"model/riscv_insts_zicsr.sail"} "model/riscv_insts_zkn.sail" {"model/riscv_insts_zkn.sail"} "model/riscv_insts_zks.sail" {"model/riscv_insts_zks.sail"} "model/riscv_jalr_rmem.sail" {"model/riscv_jalr_rmem.sail"} "model/riscv_jalr_seq.sail" {"model/riscv_jalr_seq.sail"} "model/riscv_mem.sail" {"model/riscv_mem.sail"} "model/riscv_misa_ext.sail" {"model/riscv_misa_ext.sail"} "model/riscv_next_control.sail" {"model/riscv_next_control.sail"} "model/riscv_next_regs.sail" {"model/riscv_next_regs.sail"} "model/riscv_pc_access.sail" {"model/riscv_pc_access.sail"} "model/riscv_platform.sail" {"model/riscv_platform.sail"} "model/riscv_pmp_control.sail" {"model/riscv_pmp_control.sail"} "model/riscv_pmp_regs.sail" {"model/riscv_pmp_regs.sail"} "model/riscv_pte.sail" {"model/riscv_pte.sail"} "model/riscv_ptw.sail" {"model/riscv_ptw.sail"} "model/riscv_reg_type.sail" {"model/riscv_reg_type.sail"} "model/riscv_regs.sail" {"model/riscv_regs.sail"} "model/riscv_softfloat_interface.sail" {"model/riscv_softfloat_interface.sail"} "model/riscv_step.sail" {"model/riscv_step.sail"} "model/riscv_step_common.sail" {"model/riscv_step_common.sail"} "model/riscv_step_ext.sail" {"model/riscv_step_ext.sail"} "model/riscv_step_rvfi.sail" {"model/riscv_step_rvfi.sail"} "model/riscv_sync_exception.sail" {"model/riscv_sync_exception.sail"} "model/riscv_sys_control.sail" {"model/riscv_sys_control.sail"} "model/riscv_sys_exceptions.sail" {"model/riscv_sys_exceptions.sail"} "model/riscv_sys_regs.sail" {"model/riscv_sys_regs.sail"} "model/riscv_termination_common.sail" {"model/riscv_termination_common.sail"} "model/riscv_termination_rv32.sail" {"model/riscv_termination_rv32.sail"} "model/riscv_termination_rv64.sail" {"model/riscv_termination_rv64.sail"} "model/riscv_types.sail" {"model/riscv_types.sail"} "model/riscv_types_common.sail" {"model/riscv_types_common.sail"} "model/riscv_types_ext.sail" {"model/riscv_types_ext.sail"} "model/riscv_types_kext.sail" {"model/riscv_types_kext.sail"} "model/riscv_vmem_common.sail" {"model/riscv_vmem_common.sail"} "model/riscv_vmem_rv32.sail" {"model/riscv_vmem_rv32.sail"} "model/riscv_vmem_rv64.sail" {"model/riscv_vmem_rv64.sail"} "model/riscv_vmem_sv32.sail" {"model/riscv_vmem_sv32.sail"} "model/riscv_vmem_sv39.sail" {"model/riscv_vmem_sv39.sail"} "model/riscv_vmem_sv48.sail" {"model/riscv_vmem_sv48.sail"} "model/riscv_vmem_tlb.sail" {"model/riscv_vmem_tlb.sail"} "model/riscv_vmem_types.sail" {"model/riscv_vmem_types.sail"} "model/riscv_xlen32.sail" {"model/riscv_xlen32.sail"} "model/riscv_xlen64.sail" {"model/riscv_xlen64.sail"} "model/rvfi_dii.sail" {"model/rvfi_dii.sail"} "c_emulator/riscv_platform.c" {"c_emulator/riscv_platform.c"} "c_emulator/riscv_platform_impl.c" {"c_emulator/riscv_platform_impl.c"} "c_emulator/riscv_prelude.c" {"c_emulator/riscv_prelude.c"} "c_emulator/riscv_sim.c" {"c_emulator/riscv_sim.c"} "c_emulator/riscv_softfloat.c" {"c_emulator/riscv_softfloat.c"} "c_emulator/riscv_config.h" {"c_emulator/riscv_config.h"} "c_emulator/riscv_platform.h" {"c_emulator/riscv_platform.h"} "c_emulator/riscv_platform_impl.h" {"c_emulator/riscv_platform_impl.h"} "c_emulator/riscv_prelude.h" {"c_emulator/riscv_prelude.h"} "c_emulator/riscv_sail.h" {"c_emulator/riscv_sail.h"} "c_emulator/riscv_softfloat.h" {"c_emulator/riscv_softfloat.h"} "handwritten_support/mem_metadata.lem" {"handwritten_support/mem_metadata.lem"} "handwritten_support/riscv_extras.lem" {"handwritten_support/riscv_extras.lem"} "handwritten_support/riscv_extras_fdext.lem" {"handwritten_support/riscv_extras_fdext.lem"} "handwritten_support/riscv_extras_sequential.lem" {"handwritten_support/riscv_extras_sequential.lem"} "handwritten_support/hgen/ast.hgen" {"handwritten_support/hgen/ast.hgen"} "handwritten_support/hgen/fold.hgen" {"handwritten_support/hgen/fold.hgen"} "handwritten_support/hgen/herdtools_ast_to_shallow_ast.hgen" {"handwritten_support/hgen/herdtools_ast_to_shallow_ast.hgen"} "handwritten_support/hgen/herdtools_types_to_shallow_types.hgen" {"handwritten_support/hgen/herdtools_types_to_shallow_types.hgen"} "handwritten_support/hgen/lexer.hgen" {"handwritten_support/hgen/lexer.hgen"} "handwritten_support/hgen/lexer_regexps.hgen" {"handwritten_support/hgen/lexer_regexps.hgen"} "handwritten_support/hgen/map.hgen" {"handwritten_support/hgen/map.hgen"} "handwritten_support/hgen/parser.hgen" {"handwritten_support/hgen/parser.hgen"} "handwritten_support/hgen/pretty.hgen" {"handwritten_support/hgen/pretty.hgen"} "handwritten_support/hgen/pretty_xml.hgen" {"handwritten_support/hgen/pretty_xml.hgen"} "handwritten_support/hgen/sail_trans_out.hgen" {"handwritten_support/hgen/sail_trans_out.hgen"} "handwritten_support/hgen/shallow_ast_to_herdtools_ast.hgen" {"handwritten_support/hgen/shallow_ast_to_herdtools_ast.hgen"} "handwritten_support/hgen/shallow_types_to_herdtools_types.hgen" {"handwritten_support/hgen/shallow_types_to_herdtools_types.hgen"} "handwritten_support/hgen/token_types.hgen" {"handwritten_support/hgen/token_types.hgen"} "handwritten_support/hgen/tokens.hgen" {"handwritten_support/hgen/tokens.hgen"} "handwritten_support/hgen/trans_sail.hgen" {"handwritten_support/hgen/trans_sail.hgen"} "handwritten_support/hgen/types.hgen" {"handwritten_support/hgen/types.hgen"} "handwritten_support/hgen/types_sail_trans_out.hgen" {"handwritten_support/hgen/types_sail_trans_out.hgen"} "handwritten_support/hgen/types_trans_sail.hgen" {"handwritten_support/hgen/types_trans_sail.hgen"} "handwritten_support/0.11/mem_metadata.lem" {"handwritten_support/0.11/mem_metadata.lem"} "handwritten_support/0.11/riscv_extras.lem" {"handwritten_support/0.11/riscv_extras.lem"} "handwritten_support/0.11/riscv_extras_fdext.lem" {"handwritten_support/0.11/riscv_extras_fdext.lem"} "handwritten_support/0.11/riscv_extras_sequential.lem" {"handwritten_support/0.11/riscv_extras_sequential.lem"} "generated_definitions/for-rmem/riscv.lem" {"generated_definitions/for-rmem/riscv.lem"} "generated_definitions/for-rmem/riscv_types.lem" {"generated_definitions/for-rmem/riscv_types.lem"} "generated_definitions/for-rmem/riscv_toFromInterp2.ml" {"generated_definitions/for-rmem/riscv_toFromInterp2.ml"} "generated_definitions/for-rmem/riscv.defs" {"generated_definitions/for-rmem/riscv.defs"} ]