Skip to content

Commit

Permalink
add software check exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ved-rivos committed Feb 7, 2024
1 parent c382d72 commit 1719a31
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions model/riscv_sys_control.sail
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,13 @@ function handle_mem_exception(addr : xlenbits, e : ExceptionType) -> unit = {
set_next_pc(exception_handler(cur_privilege, CTL_TRAP(t), PC))
}

function handle_sw_check_exception(code : SWCheckCodes) -> unit = {
let t : sync_exception = struct { trap = E_SW_Check_Fault(),
excinfo = Some(sw_check_code_to_bits(code)),
ext = None() } in
set_next_pc(exception_handler(cur_privilege, CTL_TRAP(t), PC))
}

function handle_exception(e: ExceptionType) -> unit = {
let t : sync_exception = struct { trap = e,
excinfo = None(),
Expand Down
20 changes: 20 additions & 0 deletions model/riscv_types.sail
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ union ExceptionType = {
E_Load_Page_Fault : unit,
E_Reserved_14 : unit,
E_SAMO_Page_Fault : unit,
E_Reserved_16 : unit,
E_Reserved_17 : unit,
E_SW_Check_Fault : unit,

/* extensions */
E_Extension : ext_exc_type
Expand All @@ -269,6 +272,9 @@ function exceptionType_to_bits(e) =
E_Load_Page_Fault() => 0x0d,
E_Reserved_14() => 0x0e,
E_SAMO_Page_Fault() => 0x0f,
E_Reserved_16() => 0x10,
E_Reserved_17() => 0x11,
E_SW_Check_Fault() => 0x12,

/* extensions */
E_Extension(e) => ext_exc_type_to_bits(e)
Expand All @@ -293,6 +299,9 @@ function num_of_ExceptionType(e) =
E_Load_Page_Fault() => 13,
E_Reserved_14() => 14,
E_SAMO_Page_Fault() => 15,
E_Reserved_16() => 16,
E_Reserved_17() => 17,
E_SW_Check_Fault() => 18,

/* extensions */
E_Extension(e) => num_of_ext_exc_type(e)
Expand All @@ -318,13 +327,24 @@ function exceptionType_to_str(e) =
E_Load_Page_Fault() => "load-page-fault",
E_Reserved_14() => "reserved-1",
E_SAMO_Page_Fault() => "store/amo-page-fault",
E_Reserved_16() => "reserved-2",
E_Reserved_17() => "reserved-3",
E_SW_Check_Fault() => "software-check-fault",

/* extensions */
E_Extension(e) => ext_exc_type_to_str(e)
}

overload to_str = {exceptionType_to_str}

/* SW check exception codes */
enum SWCheckCodes = {LANDING_PAD_FAULT}

function sw_check_code_to_bits (c : SWCheckCodes) -> xlenbits =
match (c) {
LANDING_PAD_FAULT => zero_extend(0b010),
}

/* trap modes */

type tv_mode = bits(2)
Expand Down

0 comments on commit 1719a31

Please sign in to comment.