diff options
Diffstat (limited to 'model/riscv_types.sail')
-rw-r--r-- | model/riscv_types.sail | 129 |
1 files changed, 77 insertions, 52 deletions
diff --git a/model/riscv_types.sail b/model/riscv_types.sail index e0a1f45..f61674c 100644 --- a/model/riscv_types.sail +++ b/model/riscv_types.sail @@ -138,74 +138,99 @@ function interruptType_to_bits (i) = /* architectural exception definitions */ -enum ExceptionType = { - E_Fetch_Addr_Align, - E_Fetch_Access_Fault, - E_Illegal_Instr, - E_Breakpoint, - E_Load_Addr_Align, - E_Load_Access_Fault, - E_SAMO_Addr_Align, - E_SAMO_Access_Fault, - E_U_EnvCall, - E_S_EnvCall, - E_Reserved_10, - E_M_EnvCall, - E_Fetch_Page_Fault, - E_Load_Page_Fault, - E_Reserved_14, - E_SAMO_Page_Fault, +union ExceptionType = { + E_Fetch_Addr_Align : unit, + E_Fetch_Access_Fault : unit, + E_Illegal_Instr : unit, + E_Breakpoint : unit, + E_Load_Addr_Align : unit, + E_Load_Access_Fault : unit, + E_SAMO_Addr_Align : unit, + E_SAMO_Access_Fault : unit, + E_U_EnvCall : unit, + E_S_EnvCall : unit, + E_Reserved_10 : unit, + E_M_EnvCall : unit, + E_Fetch_Page_Fault : unit, + E_Load_Page_Fault : unit, + E_Reserved_14 : unit, + E_SAMO_Page_Fault : unit, /* extensions */ - E_CHERI + E_Extension : ext_exc_type } val cast exceptionType_to_bits : ExceptionType -> exc_code function exceptionType_to_bits(e) = match (e) { - E_Fetch_Addr_Align => 0x00, - E_Fetch_Access_Fault => 0x01, - E_Illegal_Instr => 0x02, - E_Breakpoint => 0x03, - E_Load_Addr_Align => 0x04, - E_Load_Access_Fault => 0x05, - E_SAMO_Addr_Align => 0x06, - E_SAMO_Access_Fault => 0x07, - E_U_EnvCall => 0x08, - E_S_EnvCall => 0x09, - E_Reserved_10 => 0x0a, - E_M_EnvCall => 0x0b, - E_Fetch_Page_Fault => 0x0c, - E_Load_Page_Fault => 0x0d, - E_Reserved_14 => 0x0e, - E_SAMO_Page_Fault => 0x0f, + E_Fetch_Addr_Align() => 0x00, + E_Fetch_Access_Fault() => 0x01, + E_Illegal_Instr() => 0x02, + E_Breakpoint() => 0x03, + E_Load_Addr_Align() => 0x04, + E_Load_Access_Fault() => 0x05, + E_SAMO_Addr_Align() => 0x06, + E_SAMO_Access_Fault() => 0x07, + E_U_EnvCall() => 0x08, + E_S_EnvCall() => 0x09, + E_Reserved_10() => 0x0a, + E_M_EnvCall() => 0x0b, + E_Fetch_Page_Fault() => 0x0c, + E_Load_Page_Fault() => 0x0d, + E_Reserved_14() => 0x0e, + E_SAMO_Page_Fault() => 0x0f, /* extensions */ - E_CHERI => 0x20 /* FIXME: this is reserved for a future standard */ + E_Extension(e) => 0x18 /* First code for a custom extension */ + } + +val num_of_ExceptionType : ExceptionType -> {'n, (0 <= 'n < xlen). int('n)} +function num_of_ExceptionType(e) = + match (e) { + E_Fetch_Addr_Align() => 0, + E_Fetch_Access_Fault() => 1, + E_Illegal_Instr() => 2, + E_Breakpoint() => 3, + E_Load_Addr_Align() => 4, + E_Load_Access_Fault() => 5, + E_SAMO_Addr_Align() => 6, + E_SAMO_Access_Fault() => 7, + E_U_EnvCall() => 8, + E_S_EnvCall() => 9, + E_Reserved_10() => 10, + E_M_EnvCall() => 11, + E_Fetch_Page_Fault() => 12, + E_Load_Page_Fault() => 13, + E_Reserved_14() => 14, + E_SAMO_Page_Fault() => 15, + + /* extensions */ + E_Extension(e) => 24 /* First code for a custom extension */ + } val exceptionType_to_str : ExceptionType -> string function exceptionType_to_str(e) = match (e) { - E_Fetch_Addr_Align => "misaligned-fetch", - E_Fetch_Access_Fault => "fetch-access-fault", - E_Illegal_Instr => "illegal-instruction", - 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_Access_Fault => "store/amo-access-fault", - E_U_EnvCall => "u-call", - E_S_EnvCall => "s-call", - E_Reserved_10 => "reserved-0", - E_M_EnvCall => "m-call", - E_Fetch_Page_Fault => "fetch-page-fault", - E_Load_Page_Fault => "load-page-fault", - E_Reserved_14 => "reserved-1", - E_SAMO_Page_Fault => "store/amo-page-fault", + E_Fetch_Addr_Align() => "misaligned-fetch", + E_Fetch_Access_Fault() => "fetch-access-fault", + E_Illegal_Instr() => "illegal-instruction", + 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_Access_Fault() => "store/amo-access-fault", + E_U_EnvCall() => "u-call", + E_S_EnvCall() => "s-call", + E_Reserved_10() => "reserved-0", + E_M_EnvCall() => "m-call", + E_Fetch_Page_Fault() => "fetch-page-fault", + E_Load_Page_Fault() => "load-page-fault", + E_Reserved_14() => "reserved-1", + E_SAMO_Page_Fault() => "store/amo-page-fault", /* extensions */ - E_CHERI => "CHERI" + E_Extension() => "extension-exception" } overload to_str = {exceptionType_to_str} |