Move getLength to address length (not address length + 1), as we're explicitly saturating in order to express as a normal address.
This commit is contained in:
@@ -346,7 +346,7 @@ function BoundsInfo#(CapAddrW) getBoundsInfoFat (CapFat cap, TempFields tf)
|
||||
Bit #(TAdd #(MW, 2)) correctTop = {pack (tf.topCorrection), topBits};
|
||||
// Get the length by subtracting base from top and shifting appropriately, and
|
||||
// saturate in case of big exponent
|
||||
CapAddrPlus1 length =
|
||||
CapAddr length =
|
||||
(exp >= resetExp) ? ~0 : zeroExtend (correctTop - correctBase) << exp;
|
||||
|
||||
// compute repBase
|
||||
@@ -437,12 +437,12 @@ function CapAddrPlus1 getTopFat(CapFat cap, TempFields tf);
|
||||
ret[valueOf(CapAddrW)] = ~ret[valueOf(CapAddrW)];
|
||||
return ret;
|
||||
endfunction
|
||||
function CapAddrPlus1 getLengthFat(CapFat cap, TempFields tf);
|
||||
function CapAddr getLengthFat(CapFat cap, TempFields tf);
|
||||
// Get the top and base bits with the 2 correction bits prepended
|
||||
Bit#(TAdd#(MW,2)) top = {pack(tf.topCorrection),cap.bounds.topBits};
|
||||
Bit#(TAdd#(MW,2)) base = {pack(tf.baseCorrection),cap.bounds.baseBits};
|
||||
// Get the length by substracting base from top and shifting appropriately
|
||||
CapAddrPlus1 length = zeroExtend(top - base) << cap.bounds.exp;
|
||||
CapAddr length = zeroExtend(top - base) << cap.bounds.exp;
|
||||
// Return a saturated length in case of big exponent
|
||||
// TODO: The saturation behaviour here is short of being correct
|
||||
return (cap.bounds.exp >= resetExp) ? ~0 : length;
|
||||
|
||||
@@ -80,7 +80,7 @@ typedef union tagged {
|
||||
typedef struct {
|
||||
Bit #(addrW) base;
|
||||
Bit #(TAdd #(addrW, 1)) top;
|
||||
Bit #(TAdd #(addrW, 1)) length;
|
||||
Bit #(addrW) length;
|
||||
Bit #(addrW) repBase;
|
||||
Bit #(TAdd #(addrW, 1)) repTop;
|
||||
Bit #(TAdd #(addrW, 1)) repLength;
|
||||
@@ -258,7 +258,7 @@ typeclass CHERICap #( type capT // type of the CHERICap capability
|
||||
// Get the top
|
||||
function Bit #(TAdd #(addrW, 1)) getTop (capT cap) = getBoundsInfo(cap).top;
|
||||
// Get the length
|
||||
function Bit #(TAdd #(addrW, 1)) getLength (capT cap) =
|
||||
function Bit #(addrW) getLength (capT cap) =
|
||||
getBoundsInfo(cap).length;
|
||||
// Assertion that the capability's address is between its base and top
|
||||
function Bool isInBounds (capT cap, Bool isTopIncluded) =
|
||||
|
||||
@@ -88,7 +88,7 @@ function Bit#(CapAddrW) `W(getBase) (`CAPTYPE cap) = getBase(capArg(cap));
|
||||
(* noinline *)
|
||||
function Bit#(TAdd#(CapAddrW, 1)) `W(getTop) (`CAPTYPE cap) = getTop(capArg(cap));
|
||||
(* noinline *)
|
||||
function Bit#(TAdd#(CapAddrW, 1)) `W(getLength) (`CAPTYPE cap) = getLength(capArg(cap));
|
||||
function Bit#(CapAddrW) `W(getLength) (`CAPTYPE cap) = getLength(capArg(cap));
|
||||
(* noinline *)
|
||||
function Bool `W(isInBounds) (`CAPTYPE cap, Bool isTopIncluded) = isInBounds(capArg(cap), isTopIncluded);
|
||||
(* noinline *)
|
||||
|
||||
Reference in New Issue
Block a user