Add incOffset as option for setOffset
This commit is contained in:
@@ -1006,8 +1006,8 @@ instance CHERICap #(CapPipe, OTypeW, FlagsW, CapAddressW, CapW);
|
||||
|
||||
function getOffset (x) = getOffsetFat(x.capFat, x.tempFields);
|
||||
|
||||
function Exact#(CapPipe) setOffset (CapPipe cap, Bit#(CapAddressW) offset);
|
||||
let result = incOffset(cap.capFat, ?, zeroExtend(offset), cap.tempFields, True); //TODO split into separate incOffset and setOffset functions?
|
||||
function Exact#(CapPipe) setOffset (CapPipe cap, Bit#(CapAddressW) offset, Bool increment);
|
||||
let result = incOffset(cap.capFat, ?, zeroExtend(offset), cap.tempFields, !increment);
|
||||
cap.capFat = result.d;
|
||||
cap.tempFields = getTempFields(cap.capFat);
|
||||
return Exact {exact: result.v, value: cap};
|
||||
|
||||
@@ -127,7 +127,7 @@ typeclass CHERICap#(type t, numeric type ot, numeric type flg, numeric type n, n
|
||||
// Get the offset of the capability
|
||||
function Bit#(n) getOffset (t cap) = getAddr(cap) - getBase(cap);
|
||||
// Set the offset of the capability. Result invalid if not exact
|
||||
function Exact#(t) setOffset (t cap, Bit#(n) offset);
|
||||
function Exact#(t) setOffset (t cap, Bit#(n) offset, Bool increment);
|
||||
|
||||
// Get the base
|
||||
function Bit#(n) getBase (t cap);
|
||||
|
||||
Reference in New Issue
Block a user