summaryrefslogtreecommitdiff
path: root/riscv/riscv_platform.sail
diff options
context:
space:
mode:
authorPrashanth Mundkur2018-06-07 16:58:23 -0700
committerPrashanth Mundkur2018-06-07 16:58:23 -0700
commitccf13b8039686a483f95e451c5d52cac9f4e4ce0 (patch)
treeed91ff46aa943b9f1e581a5e3d2bdc93e7b04cc1 /riscv/riscv_platform.sail
parent958db3f98da25a435c5fb570309b326f3992ab19 (diff)
Slight refactor to keep platform handling localized to the _platform file.
Diffstat (limited to 'riscv/riscv_platform.sail')
-rw-r--r--riscv/riscv_platform.sail18
1 files changed, 18 insertions, 0 deletions
diff --git a/riscv/riscv_platform.sail b/riscv/riscv_platform.sail
index 8be3a52c..761aeebd 100644
--- a/riscv/riscv_platform.sail
+++ b/riscv/riscv_platform.sail
@@ -144,6 +144,24 @@ function htif_store(addr, width, data) = {
MemValue(())
}
+/* Top-level MMIO dispatch */
+
+function mmio_load(addr : xlenbits, width : atom('n)) -> forall 'n. MemoryOpResult(bits(8 * 'n)) =
+ if within_clint(addr, width)
+ then clint_load(addr, width)
+ else if within_htif_readable(addr, width) & (1 <= 'n)
+ then htif_load(addr, width)
+ else MemException(E_Load_Access_Fault)
+
+function mmio_write(addr : xlenbits, width : atom('n), data: bits(8 * 'n)) -> forall 'n, 'n > 0. MemoryOpResult(unit) =
+ if within_clint(addr, width)
+ then clint_store(addr, width, data)
+ else if within_htif_writable(addr, width) & 'n <= 8
+ then htif_store(addr, width, data)
+ else MemException(E_SAMO_Access_Fault)
+
+/* Platform initialization */
+
function init_platform() -> unit = {
htif_done = false;
htif_exit_code = EXTZ(0b0);