aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon French <jf451@cam.ac.uk>2019-03-12 12:07:33 +0000
committerJon French <jf451@cam.ac.uk>2019-03-12 14:02:19 +0000
commit68a69d4ea5357c698da1f007fce6215c6e58e1f7 (patch)
tree5e31ed5fad64218cbf1b1ba27a220b436e99fd8d
parenteab254dedc3f72d5ab1b6bbcae69cfebf15988dc (diff)
downloadsail-riscv-68a69d4ea5357c698da1f007fce6215c6e58e1f7.zip
sail-riscv-68a69d4ea5357c698da1f007fce6215c6e58e1f7.tar.gz
sail-riscv-68a69d4ea5357c698da1f007fce6215c6e58e1f7.tar.bz2
riscv_platform.sail: use externs for platform values even in interpreter
-rw-r--r--model/riscv_platform.sail28
-rw-r--r--model/riscv_sys_control.sail10
-rw-r--r--model/riscv_vmem.sail4
3 files changed, 16 insertions, 26 deletions
diff --git a/model/riscv_platform.sail b/model/riscv_platform.sail
index 8d7fe4c..0ac77da 100644
--- a/model/riscv_platform.sail
+++ b/model/riscv_platform.sail
@@ -4,7 +4,6 @@
- it cannot access memory directly, but instead provides definitions for the physical memory model
- it can access system register state, needed to manipulate interrupt bits
- it relies on externs to get platform address information and doesn't hardcode them
- (except for a set of defaults used when interpreting)
*/
val elf_tohost = {
@@ -20,42 +19,36 @@ val elf_entry = {
} : unit -> int
/* Main memory */
-val plat_ram_base = {c: "plat_ram_base", ocaml: "Platform.dram_base", lem: "plat_ram_base"} : unit -> xlenbits
-function plat_ram_base () = 0x0000000080000000
-val plat_ram_size = {c: "plat_ram_size", ocaml: "Platform.dram_size", lem: "plat_ram_size"} : unit -> xlenbits
-function plat_ram_size () = 0x0000000000000800 << 0x14
+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 MMU should update dirty bits in PTEs */
val plat_enable_dirty_update = {ocaml: "Platform.enable_dirty_update",
+ interpreter: "Platform.enable_dirty_update",
c: "plat_enable_dirty_update",
lem: "plat_enable_dirty_update"} : unit -> bool
-function plat_enable_dirty_update () = false
/* whether the platform supports misaligned accesses without trapping to M-mode. if false,
* misaligned loads/stores are trapped to Machine mode.
*/
val plat_enable_misaligned_access = {ocaml: "Platform.enable_misaligned_access",
+ interpreter: "Platform.enable_misaligned_access",
c: "plat_enable_misaligned_access",
lem: "plat_enable_misaligned_access"} : unit -> bool
-function plat_enable_misaligned_access () = false
/* whether mtval stores the bits of a faulting instruction on illegal instruction exceptions */
val plat_mtval_has_illegal_inst_bits = {ocaml: "Platform.mtval_has_illegal_inst_bits",
+ interpreter: "Platform.mtval_has_illegal_inst_bits",
c: "plat_mtval_has_illegal_inst_bits",
lem: "plat_mtval_has_illegal_inst_bits"} : unit -> bool
-function plat_mtval_has_illegal_inst_bits () = false
/* ROM holding reset vector and device-tree DTB */
-val plat_rom_base = {ocaml: "Platform.rom_base", c: "plat_rom_base", lem: "plat_rom_base"} : unit -> xlenbits
-function plat_rom_base () = 0x0000000000001000
-val plat_rom_size = {ocaml: "Platform.rom_size", c: "plat_rom_size", lem: "plat_rom_size"} : unit -> xlenbits
-function plat_rom_size () = 0x0000000000000100
+val plat_rom_base = {ocaml: "Platform.rom_base", interpreter: "Platform.rom_base", c: "plat_rom_base", lem: "plat_rom_base"} : unit -> xlenbits
+val plat_rom_size = {ocaml: "Platform.rom_size", interpreter: "Platform.rom_size", c: "plat_rom_size", lem: "plat_rom_size"} : unit -> xlenbits
/* Location of clock-interface, which should match with the spec in the DTB */
-val plat_clint_base = {ocaml: "Platform.clint_base", c: "plat_clint_base", lem: "plat_clint_base"} : unit -> xlenbits
-function plat_clint_base () = 0x0000000002000000
-val plat_clint_size = {ocaml: "Platform.clint_size", c: "plat_clint_size", lem: "plat_clint_size"} : unit -> xlenbits
-function plat_clint_size () = 0x00000000000c0000
+val plat_clint_base = {ocaml: "Platform.clint_base", interpreter: "Platform.clint_base", c: "plat_clint_base", lem: "plat_clint_base"} : unit -> xlenbits
+val plat_clint_size = {ocaml: "Platform.clint_size", interpreter: "Platform.clint_size", c: "plat_clint_size", lem: "plat_clint_size"} : unit -> xlenbits
/* Location of HTIF ports */
val plat_htif_tohost = {ocaml: "Platform.htif_tohost", c: "plat_htif_tohost", lem: "plat_htif_tohost"} : unit -> xlenbits
@@ -105,8 +98,7 @@ function within_htif_readable forall 'n. (addr : xlenbits, width : atom('n)) ->
/* CLINT (Core Local Interruptor), based on Spike. */
-val plat_insns_per_tick = {ocaml: "Platform.insns_per_tick", c: "plat_insns_per_tick", lem: "plat_insns_per_tick"} : unit -> int
-function plat_insns_per_tick () = 100
+val plat_insns_per_tick = {ocaml: "Platform.insns_per_tick", interpreter: "Platform.insns_per_tick", c: "plat_insns_per_tick", lem: "plat_insns_per_tick"} : unit -> int
// assumes a single hart, since this typically is a vector of per-hart registers.
register mtimecmp : xlenbits // memory-mapped internal clint register.
diff --git a/model/riscv_sys_control.sail b/model/riscv_sys_control.sail
index 3bdaadd..df84733 100644
--- a/model/riscv_sys_control.sail
+++ b/model/riscv_sys_control.sail
@@ -99,13 +99,11 @@ function check_CSR(csr : csreg, p : Privilege, isWrite : bool) -> bool =
* where cancellation can be performed.
*/
-val speculate_conditional = {ocaml: "Platform.speculate_conditional", c: "speculate_conditional", lem: "speculate_conditional_success"} : unit -> bool effect {exmem}
+val speculate_conditional = {ocaml: "Platform.speculate_conditional", interpreter: "excl_res", c: "speculate_conditional", lem: "speculate_conditional_success"} : unit -> bool effect {exmem}
-val load_reservation = {ocaml: "Platform.load_reservation", c: "load_reservation", lem: "load_reservation"} : xlenbits -> unit
-
-val match_reservation = {ocaml: "Platform.match_reservation", lem: "match_reservation", c: "match_reservation"} : xlenbits -> bool
-
-val cancel_reservation = {ocaml: "Platform.cancel_reservation", c: "cancel_reservation", lem: "cancel_reservation"} : unit -> unit
+val load_reservation = {ocaml: "Platform.load_reservation", interpreter: "Platform.load_reservation", c: "load_reservation", lem: "load_reservation"} : xlenbits -> unit
+val match_reservation = {ocaml: "Platform.match_reservation", interpreter: "Platform.match_reservation", lem: "match_reservation", c: "match_reservation"} : xlenbits -> bool
+val cancel_reservation = {ocaml: "Platform.cancel_reservation", interpreter: "Platform.cancel_reservation", c: "cancel_reservation", lem: "cancel_reservation"} : unit -> unit
/* Exception delegation: given an exception and the privilege at which
* it occured, returns the privilege at which it should be handled.
diff --git a/model/riscv_vmem.sail b/model/riscv_vmem.sail
index b617d29..ef56108 100644
--- a/model/riscv_vmem.sail
+++ b/model/riscv_vmem.sail
@@ -313,7 +313,7 @@ function translate39(vAddr, ac, priv, mxr, do_sum, level) = {
n_ent.pte = update_BITS(ent.pte, pbits.bits());
writeTLB39(idx, n_ent);
/* update page table */
- match checked_mem_write(EXTZ(ent.pteAddr), 8, ent.pte.bits()) {
+ match checked_mem_write(EXTZ(ent.pteAddr), 8, ent.pte.bits(), false, false, false) {
MemValue(_) => (),
MemException(e) => internal_error("invalid physical address in TLB")
};
@@ -339,7 +339,7 @@ function translate39(vAddr, ac, priv, mxr, do_sum, level) = {
TR39_Failure(PTW_PTE_Update)
} else {
w_pte : SV39_PTE = update_BITS(pte, pbits.bits());
- match checked_mem_write(EXTZ(pteAddr), 8, w_pte.bits()) {
+ match checked_mem_write(EXTZ(pteAddr), 8, w_pte.bits(), false, false, false) {
MemValue(_) => {
addToTLB39(asid, vAddr, pAddr, w_pte, pteAddr, level, global);
TR39_Address(pAddr)