diff options
| author | Prashanth Mundkur | 2018-04-09 16:02:03 -0700 |
|---|---|---|
| committer | Prashanth Mundkur | 2018-04-09 16:02:03 -0700 |
| commit | b3fe73490a61130c1e2f12a03599797d4a44c439 (patch) | |
| tree | 79b146aca650d626bb3ea3be7094cf55be1c350a | |
| parent | 91bc72caff60a03775bd75962f43940856b9bcbb (diff) | |
Slightly re-org defs to move related things closer together.
| -rw-r--r-- | riscv/riscv_types.sail | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/riscv/riscv_types.sail b/riscv/riscv_types.sail index 1c11a32f..2c5ecbf5 100644 --- a/riscv/riscv_types.sail +++ b/riscv/riscv_types.sail @@ -1,19 +1,4 @@ -union exception = { - Error_not_implemented : string, - Error_misaligned_access : unit, - Error_EBREAK : unit, - Error_internal_error : unit -} - -val not_implemented : forall ('a : Type). string -> 'a effect {escape} - -function not_implemented message = throw(Error_not_implemented(message)) - -val internal_error : forall ('a : Type). string -> 'a effect {escape} -function internal_error(s) = { - assert (false, s); - throw Error_internal_error() -} +/* basic types */ let xlen = 64 type xlenbits = bits(64) @@ -32,6 +17,7 @@ val creg2reg_bits : cregbits -> regbits function creg2reg_bits(creg) = 0b01 @ creg /* some arch and ABI relevant registers */ + let zreg : regbits = 0b00000 let ra : regbits = 0b00001 /* x1 */ let sp : regbits = 0b00010 /* x2 */ @@ -39,6 +25,7 @@ let sp : regbits = 0b00010 /* x2 */ register PC : xlenbits register nextPC : xlenbits +/* register file and accessors */ register Xs : vector(32, dec, xlenbits) /* Getters and setters for X registers (special case for zeros register, x0) */ @@ -57,6 +44,27 @@ function wX (r, v) = overload X = {rX, wX} +/* exceptions */ + +union exception = { + Error_not_implemented : string, + Error_misaligned_access : unit, + Error_EBREAK : unit, + Error_internal_error : unit +} + +val not_implemented : forall ('a : Type). string -> 'a effect {escape} + +function not_implemented message = throw(Error_not_implemented(message)) + +val internal_error : forall ('a : Type). string -> 'a effect {escape} +function internal_error(s) = { + assert (false, s); + throw Error_internal_error() +} + +/* memory */ + function check_alignment (addr : xlenbits, width : atom('n)) -> forall 'n. unit = if unsigned(addr) % width != 0 then throw Error_misaligned_access() else () |
