diff --git a/src_Core/CPU/CsrFile.bsv b/src_Core/CPU/CsrFile.bsv index 971ff22..34de083 100644 --- a/src_Core/CPU/CsrFile.bsv +++ b/src_Core/CPU/CsrFile.bsv @@ -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; diff --git a/src_Core/ISA/ISA_Decls_CHERI.bsv b/src_Core/ISA/ISA_Decls_CHERI.bsv index 2f62243..13db74d 100755 --- a/src_Core/ISA/ISA_Decls_CHERI.bsv +++ b/src_Core/ISA/ISA_Decls_CHERI.bsv @@ -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); diff --git a/src_Core/RISCY_OOO/procs/RV64G_OOO/MemExePipeline.bsv b/src_Core/RISCY_OOO/procs/RV64G_OOO/MemExePipeline.bsv index 98a6796..ee391f6 100644 --- a/src_Core/RISCY_OOO/procs/RV64G_OOO/MemExePipeline.bsv +++ b/src_Core/RISCY_OOO/procs/RV64G_OOO/MemExePipeline.bsv @@ -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; diff --git a/src_Core/RISCY_OOO/procs/lib/Decode.bsv b/src_Core/RISCY_OOO/procs/lib/Decode.bsv index 4cbce16..0fef1b8 100644 --- a/src_Core/RISCY_OOO/procs/lib/Decode.bsv +++ b/src_Core/RISCY_OOO/procs/lib/Decode.bsv @@ -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; diff --git a/src_Core/RISCY_OOO/procs/lib/Exec.bsv b/src_Core/RISCY_OOO/procs/lib/Exec.bsv index b6bc4c0..39007d8 100644 --- a/src_Core/RISCY_OOO/procs/lib/Exec.bsv +++ b/src_Core/RISCY_OOO/procs/lib/Exec.bsv @@ -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;