hack for fromMem function to pass compile time checks

This commit is contained in:
2026-02-20 01:59:39 +00:00
parent c7060e23d1
commit d98b6571f6
3 changed files with 33 additions and 10 deletions

View File

@@ -228,4 +228,4 @@ Bit #(3) f3_AMO_CAP = w_SIZE_CAP;
Bit #(XLEN) otype_unsealed_ext = -1;
Bit #(XLEN) otype_sentry_ext = -2;
Bit #(XLEN) otype_res0_ext = -3;
Bit #(XLEN) otype_res1_ext = -4;
Bit #(XLEN) otype_res1_ext = -4;

View File

@@ -285,7 +285,7 @@ function CapPipe capModify(CapPipe a, CapPipe b, CapModifyFunc func);
tagged FromPtr :
(getAddr(a) == 0 ? nullCap : setAddr(b_mut, getAddr(a)).value);
tagged SetHigh:
// fromMem(tuple2(False, {getAddr(b), getAddr(a)} :: Bit#(CapW)));
// fromMemTest(tuple2(False, {getAddr(b), getAddr(a)}));
capFromAddrs(a,b);
// getTruncatedTuple(getAddr(b))
tagged BuildCap :
@@ -299,14 +299,37 @@ function CapPipe capModify(CapPipe a, CapPipe b, CapModifyFunc func);
return res;
endfunction
function CapPipe capFromAddrs (capT a, capT b);
// function CapPipe capFromAddrs (CapPipe a, CapPipe b)
// provisos (
// CHERICap#(CapPipe, o, f, addrW, CapW, m, d)
// );
// // Get full serialized capability of 'a'
// match {.tag, .rawA} = toMem(a); // rawA : Bit#(inMemW)
// // Replace low addrW bits with address from b
// Bit#(addrW) newAddr = getAddr(b);
// Bit#(inMemW) newRaw =
// { rawA[CapW-1 : addrW] // keep upper metadata
// , newAddr // replace address field
// };
// return fromMem(tuple2(tag, newRaw));
// endfunction
function CapPipe capFromAddrs(capT a, capT b)
provisos (CHERICap#(capT, a, b, 64, d, e, f)); // exact instance
// Extract addresses
Bit#(0) addrA = getAddr(a);
Bit#(116) addrB = getAddr(b);
// Concatenate into a 180-bit raw capability
Bit#(116) rawCap = {addrB, addrA};
// Convert to CapPipe using fromMem
return fromMem(tuple2(False, rawCap));
Bit#(64) addrA = getAddr(a);
Bit#(64) addrB = getAddr(b);
// Extra bits to reach inMemW = 180
Bit#(52) extra = 0; // can be zeros or delta bits if needed
// Concatenate explicitly typed
Bit#(180) rawBits = {addrB, addrA, extra};
return fromMem(tuple2(False, rawBits));
endfunction
(* noinline *)