Fix hardcoded assumption in maskAddr that MW was 8 from CAP64

This commit is contained in:
Peter Rugg
2020-01-20 14:30:31 +00:00
parent 123fe712a9
commit 774e883a26

View File

@@ -1018,7 +1018,7 @@ instance CHERICap #(CapReg, OTypeW, FlagsW, CapAddressW, CapW, TSub#(MW, 3));
function CapReg maskAddr (CapReg cap, Bit#(TSub#(MW, 3)) mask);
cap.address[valueOf(TSub#(MW, 4)):0] = cap.address[valueOf(TSub#(MW, 4)):0] & mask;
//Update addrBits. Since exp can be up to 64, extend to 64 + 8 bits so bit-select is always in range
cap.addrBits = (({40'b0,cap.address})[cap.bounds.exp+7:cap.bounds.exp]); //TODO avoid shift?
cap.addrBits = (({40'b0,cap.address})[cap.bounds.exp+fromInteger(valueOf(TSub#(MW,1))):cap.bounds.exp]); //TODO avoid shift?
return cap;
endfunction