Add incOffset as option for setOffset

This commit is contained in:
Peter Rugg
2019-09-05 11:09:05 +01:00
parent 06fbe6d31d
commit bc9f058976
2 changed files with 3 additions and 3 deletions

View File

@@ -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};

View File

@@ -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);