aboutsummaryrefslogtreecommitdiff
path: root/model/riscv_sys_control.sail
diff options
context:
space:
mode:
authorPrashanth Mundkur <prashanth.mundkur@gmail.com>2019-05-03 12:25:20 -0700
committerPrashanth Mundkur <prashanth.mundkur@gmail.com>2019-05-03 12:25:20 -0700
commita0818796b4ad4340812805bdc9d4281786ab9cf4 (patch)
tree8d090498a68484f526360cb8448051415602fd2b /model/riscv_sys_control.sail
parent8f89e8a877f93a2bafbe2e7e42b4bccd30ba45f9 (diff)
downloadsail-riscv-a0818796b4ad4340812805bdc9d4281786ab9cf4.zip
sail-riscv-a0818796b4ad4340812805bdc9d4281786ab9cf4.tar.gz
sail-riscv-a0818796b4ad4340812805bdc9d4281786ab9cf4.tar.bz2
Fix inconsistency in accessing PC/nextPC, which also clarifies which handlers return nextPC values as opposed to setting them.
Diffstat (limited to 'model/riscv_sys_control.sail')
-rw-r--r--model/riscv_sys_control.sail14
1 files changed, 7 insertions, 7 deletions
diff --git a/model/riscv_sys_control.sail b/model/riscv_sys_control.sail
index 5c72058..41fe13a 100644
--- a/model/riscv_sys_control.sail
+++ b/model/riscv_sys_control.sail
@@ -279,8 +279,8 @@ $endif
/* handle exceptional ctl flow by updating nextPC and operating privilege */
-function handle_trap(del_priv : Privilege, intr : bool, c : exc_code, pc : xlenbits, info : option(xlenbits), ext : option(ext_exception))
- -> xlenbits = {
+function trap_handler(del_priv : Privilege, intr : bool, c : exc_code, pc : xlenbits, info : option(xlenbits), ext : option(ext_exception))
+ -> xlenbits = {
rvfi_trap();
print_platform("handling " ^ (if intr then "int#" else "exc#")
^ BitStr(c) ^ " at priv " ^ del_priv ^ " with tval " ^ BitStr(tval(info)));
@@ -352,14 +352,14 @@ function handle_trap(del_priv : Privilege, intr : bool, c : exc_code, pc : xlenb
};
}
-function handle_exception(cur_priv : Privilege, ctl : ctl_result,
- pc: xlenbits) -> xlenbits = {
+function exception_handler(cur_priv : Privilege, ctl : ctl_result,
+ pc: xlenbits) -> xlenbits = {
match (cur_priv, ctl) {
(_, CTL_TRAP(e)) => {
let del_priv = exception_delegatee(e.trap, cur_priv);
print_platform("trapping from " ^ cur_priv ^ " to " ^ del_priv
^ " to handle " ^ e.trap);
- handle_trap(del_priv, false, e.trap, pc, e.excinfo, e.ext)
+ trap_handler(del_priv, false, e.trap, pc, e.excinfo, e.ext)
},
(_, CTL_MRET()) => {
let prev_priv = cur_privilege;
@@ -407,11 +407,11 @@ function handle_mem_exception(addr : xlenbits, e : ExceptionType) -> unit = {
let t : sync_exception = struct { trap = e,
excinfo = Some(addr),
ext = None() } in
- nextPC = handle_exception(cur_privilege, CTL_TRAP(t), PC)
+ set_next_pc(exception_handler(cur_privilege, CTL_TRAP(t), PC))
}
function handle_interrupt(i : InterruptType, del_priv : Privilege) -> unit =
- nextPC = handle_trap(del_priv, true, i, PC, None(), None())
+ set_next_pc(trap_handler(del_priv, true, i, PC, None(), None()))
/* state state initialization */