Added toMem/fromMem class methods

This commit is contained in:
Alexandre Joannou
2019-05-22 14:52:06 +01:00
parent 5063a8d9e3
commit 4d4001af8d
2 changed files with 20 additions and 7 deletions

View File

@@ -78,8 +78,8 @@ typedef enum {
SEALED_WITH_TYPE
} Kind deriving (Eq, FShow);
typeclass CHERICap#(type t, numeric type ot, numeric type flg, numeric type n)
dependencies (t determines (ot, flg, n));
typeclass CHERICap#(type t, numeric type ot, numeric type flg, numeric type n, numeric type mem_sz)
dependencies (t determines (ot, flg, n, mem_sz));
// Return whether the Capability is valid
function Bool isValidCap (t cap);
@@ -159,9 +159,13 @@ typeclass CHERICap#(type t, numeric type ot, numeric type flg, numeric type n)
// Check if a type is valid
function Bool validAsType (t dummy, Bit#(n) checkType);
// convert from and to bit memory representation
function t fromMem (Tuple2#(Bool, Bit#(mem_sz)) mem_cap);
function Tuple2#(Bool, Bit#(mem_sz)) toMem (t cap);
endtypeclass
function Fmt showCHERICap(t cap) provisos (CHERICap#(t, ot, flg, n));
function Fmt showCHERICap(t cap) provisos (CHERICap#(t, ot, flg, n, mem_sz));
return $format( "Valid: 0x%0x", isValidCap(cap)) +
$format(" Perms: 0x%0x", getPerms(cap)) +
$format(" Kind: ", fshow(getKind(cap))) +