Fix Toooba to use addresses instead of offsets (#32)
* Fixed the Decoding of (C)JAL * Use CSR addresses instead of offsets * Fixed offsets correctly * Fixed all offsets I could spot * Fix use of modifyOffset function * Corrected brAddrCalc function * Preliminary fix for ddc offsetting * Use setAddr instead of incOffset for DDC * Deleted unnecessarily added lines in ALU pipeline * Deleted white space * Switched off verbosity for ALU pipeline * Removed unnecessary print import
This commit is contained in:
@@ -354,10 +354,10 @@ module mkStatsCsr(StatsCsr);
|
||||
endmodule
|
||||
|
||||
function Reg#(Data) scrToCsr(Reg#(CapReg) scr) = interface Reg
|
||||
method _write (x) = action CapPipe scr_pipe = cast(scr); scr <= cast(setOffset(scr_pipe, x).value); endaction;
|
||||
method _write (x) = action CapPipe scr_pipe = cast(scr); scr <= cast(setAddr(scr_pipe, x).value); endaction;
|
||||
method Data _read;
|
||||
CapPipe scr_pipe = cast(scr);
|
||||
return getOffset(scr_pipe);
|
||||
return getAddr(scr_pipe);
|
||||
endmethod
|
||||
endinterface;
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ function SCR unpackSCR(Bit#(5) addr);
|
||||
endfunction
|
||||
|
||||
function CapPipe update_scr_via_csr (CapPipe old_scr, WordXL new_csr, Bool allow_sealed);
|
||||
let new_scr = setOffset(old_scr, new_csr);
|
||||
let new_scr = setAddr(old_scr, new_csr);
|
||||
let ret = new_scr.value;
|
||||
if (!new_scr.exact || (getKind(old_scr) != UNSEALED && !allow_sealed)) begin
|
||||
ret = setValidCap(ret, False);
|
||||
|
||||
@@ -530,7 +530,7 @@ module mkMemExePipeline#(MemExeInput inIfc)(MemExePipeline);
|
||||
if(x.regs.src1 matches tagged Valid .src1 &&& src1 != 0) begin
|
||||
rVal1 <- readRFBypass(src1, regsReady.src1, inIfc.rf_rd1(src1), bypassWire);
|
||||
end
|
||||
if (x.ddc_offset) rVal1 = incOffset(ddc, getAddr(rVal1)).value;
|
||||
if (x.ddc_offset) rVal1 = setAddr(ddc, getAddr(rVal1)).value;
|
||||
|
||||
// get rVal2 (check bypass)
|
||||
CapPipe rVal2 = nullCap;
|
||||
|
||||
@@ -523,14 +523,15 @@ function DecodeResult decode(Instruction inst, Bool cap_mode);
|
||||
end
|
||||
|
||||
opcJal: begin
|
||||
legalInst = True;
|
||||
|
||||
if (cap_mode) begin
|
||||
dInst.iType = CJAL;
|
||||
end
|
||||
else begin
|
||||
dInst.iType = J;
|
||||
end
|
||||
|
||||
legalInst = True;
|
||||
|
||||
regs.dst = Valid(tagged Gpr rd);
|
||||
regs.src1 = Invalid;
|
||||
regs.src2 = Invalid;
|
||||
|
||||
@@ -200,19 +200,19 @@ endfunction
|
||||
|
||||
(* noinline *)
|
||||
function CapPipe specialRWALU(CapPipe cap, CapPipe oldCap, SpecialRWFunc scrType);
|
||||
function csrOp (oldOffset, val, f) =
|
||||
function csrOp (oldAddr, val, f) =
|
||||
case (f)
|
||||
Write: val;
|
||||
Set: (oldOffset | val);
|
||||
Clear: (oldOffset & ~val);
|
||||
Set: (oldAddr | val);
|
||||
Clear: (oldAddr & ~val);
|
||||
endcase;
|
||||
let offset = getOffset(cap);
|
||||
let oldOffset = getOffset(oldCap);
|
||||
let addr = getAddr(cap);
|
||||
let oldAddr = getAddr(oldCap);
|
||||
CapPipe res = (case (scrType) matches
|
||||
tagged TVEC .csrf: update_scr_via_csr(oldCap, csrOp(oldOffset, getAddr(cap), csrf) & ~64'h2, False);
|
||||
tagged EPC .csrf: update_scr_via_csr(oldCap, csrOp(oldOffset, getAddr(cap), csrf) & ~64'h1, False);
|
||||
tagged TCC: update_scr_via_csr(cap, offset & ~64'h2, False); // Mask out bit 1
|
||||
tagged EPCC: update_scr_via_csr(cap, offset & ~64'h1, offset[0] == 1'b0); // Mask out bit 0
|
||||
tagged TVEC .csrf: update_scr_via_csr(oldCap, csrOp(oldAddr, getAddr(cap), csrf) & ~64'h2, False);
|
||||
tagged EPC .csrf: update_scr_via_csr(oldCap, csrOp(oldAddr, getAddr(cap), csrf) & ~64'h1, False);
|
||||
tagged TCC: update_scr_via_csr(cap, addr & ~64'h2, False); // Mask out bit 1
|
||||
tagged EPCC: update_scr_via_csr(cap, addr & ~64'h1, addr[0] == 1'b0); // Mask out bit 0
|
||||
tagged Normal: cap;
|
||||
endcase);
|
||||
return res;
|
||||
@@ -251,8 +251,8 @@ function CapPipe capModify(CapPipe a, CapPipe b, CapModifyFunc func);
|
||||
tagged TCC: b;
|
||||
tagged EPCC: b;
|
||||
tagged Normal: b;
|
||||
tagged TVEC ._: nullWithAddr(getOffset(b));
|
||||
tagged EPC ._: nullWithAddr(getOffset(b));
|
||||
tagged TVEC ._: nullWithAddr(getAddr(b));
|
||||
tagged EPC ._: nullWithAddr(getAddr(b));
|
||||
endcase
|
||||
tagged SetAddr .addrSource :
|
||||
clearTagIf(setAddr(b_mut, (addrSource == Src1Type) ? a_type : getAddr(a) ).value, (addrSource == Src1Type) ? a_res : False);
|
||||
@@ -271,7 +271,7 @@ function CapPipe capModify(CapPipe a, CapPipe b, CapModifyFunc func);
|
||||
tagged SetFlags :
|
||||
setFlags(a_mut, truncate(getAddr(b)));
|
||||
tagged FromPtr :
|
||||
(getAddr(a) == 0 ? nullCap : setOffset(b_mut, getAddr(a)).value);
|
||||
(getAddr(a) == 0 ? nullCap : setAddr(b_mut, getAddr(a)).value);
|
||||
tagged SetHigh:
|
||||
fromMem(tuple2(False, {getAddr(b), getAddr(a)}));
|
||||
tagged BuildCap :
|
||||
@@ -367,7 +367,9 @@ function CapPipe brAddrCalc(CapPipe pc, CapPipe val, IType iType, Data imm, Bool
|
||||
doInc = False;
|
||||
end
|
||||
end
|
||||
CapPipe targetAddr = modifyOffset(nextPc, offset, doInc).value;
|
||||
CapPipe targetAddr = ?;
|
||||
if(doInc) targetAddr = modifyOffset(nextPc, offset, doInc).value;
|
||||
else targetAddr = setAddr(nextPc, offset).value;
|
||||
// jumpTarget.address[0] = 1'b0;
|
||||
targetAddr = setAddrUnsafe(targetAddr, {truncateLSB(getAddr(targetAddr)), 1'b0});
|
||||
targetAddr = setKind(targetAddr, UNSEALED); // It is checked elsewhere that we have an unsealed cap already, or sentry if permitted
|
||||
@@ -434,12 +436,12 @@ function ExecResult basicExec(DecodedInst dInst, CapPipe rVal1, CapPipe rVal2, C
|
||||
St : rVal2;
|
||||
Sc : rVal2;
|
||||
Amo : rVal2;
|
||||
J : nullWithAddr(getOffset(link_pcc));
|
||||
J : nullWithAddr(getAddr(link_pcc));
|
||||
CJAL : setKind(link_pcc, SENTRY);
|
||||
CCall : cap_alu_result;
|
||||
CJALR : setKind(link_pcc, SENTRY);
|
||||
Jr : nullWithAddr(getOffset(link_pcc));
|
||||
Auipc : nullWithAddr(getOffset(pcc) + getDInstImm(dInst).Valid);
|
||||
Jr : nullWithAddr(getAddr(link_pcc));
|
||||
Auipc : nullWithAddr(getAddr(pcc) + getDInstImm(dInst).Valid);
|
||||
Auipcc : incOffset(pcc, getDInstImm(dInst).Valid).value; // could be computed with alu
|
||||
Csr : rVal1;
|
||||
Scr : cap_alu_result;
|
||||
|
||||
Reference in New Issue
Block a user