Merged Capability128ccLibs.bsv and CHERICC128Cap.bsv into CHERICC_Fat.bsv and added a CHERICC.bsv library (not currently working)

This commit is contained in:
Alexandre Joannou
2019-03-05 16:50:35 +00:00
parent 5c4a81b12e
commit f3c9f5972a
4 changed files with 700 additions and 273 deletions

View File

@@ -129,7 +129,12 @@ typeclass CHERICap#(type t, numeric type ot, numeric type n)
function Bit#(TAdd#(n, 1)) getLength (t cap);
// Assertion that address is between base and top
function Bool isInBounds (t cap, Bool inclusive);
function Bool isInBounds (t cap, Bool isTopIncluded);
Bool isNotTooHigh = isTopIncluded ? zeroExtend(getAddr(cap)) <= getTop(cap)
: zeroExtend(getAddr(cap)) < getTop(cap);
Bool isNotTooLow = getAddr(cap) >= getBase(cap);
return isNotTooLow && isNotTooHigh;
endfunction
// Set the length of the capability. Inexact: result length may be different to requested
function Exact#(t) setBounds (t cap, Bit#(n) length);
@@ -154,12 +159,12 @@ function Fmt showCHERICap(t cap) provisos (CHERICap#(t, ot, n));
$format(" Length: 0x%0x", getLength(cap));
endfunction
typeclass Cast #(type src, type dest);
typeclass Cast#(type src, type dest);
function dest cast (src x);
endtypeclass
instance Cast #(t, t);
function t cast (t x) = x;
instance Cast#(t, t);
function cast = id;
endinstance
endpackage