Execute.bsv
Q&A
- How does it caculate the memory access address?
- where does it access TLB?
Global Functions:
- function Bit#(a) arithmeticShift(Bit#(a) toShift, Bit#(b) shiftAmount)
- function Bit#(a) arithmeticShift2(Bit#(a) toShift, Bit#(b) shiftAmount)
mkExecute module s
Input:
- MIPSRegFileIfc rf
- WritebackIfc writeback
- CP0Ifc cp0
- CoProIfc cop1
- CapCopIfc capCop
- FIFO#(ControlTokenT) inQ
Rules:
- finishMultiplyOrDivide
- deliverPendingOp
Methods:
States:
- FIFO#(ControlTokenT) outQ <- mkFIFO;
- MulDivIfc mul <- mkMulDiv;
- Reg#(MIPSReg) hi <- mkReg(64’b0);
- Reg#(MIPSReg) lo <- mkReg(64’b0);
- FIFOF#(Bool) hiLoPending <- mkFIFOF1;
- FIFOF#(ControlTokenT) pendingOps <- mkFIFOF1;
- Reg#(Bit#(16)) coreid <- mkConfigReg(0);
method Action enq(ControlTokenT di)
Condition:
- !hiOrLoIsBlocking
- !pendingOps.notEmpty
Input:
- ControlTokenT di.{ opA, opB, pc, memSize, mem, inst, …}
Output:
- ControlTokenT er.{opA, opB, }
Steps:
- pre-execute instruction
- check di.inst to see whether the instruction is for COP2, if so set cap=True;
- get cop1 response with opA, opB
- get PC from cap.Cop.getArchPc(er.pc, er.epoch)
- call
capCop.getArchPc(er.pc, er.epoch)
assign to er.archPc
- test the instruction is memory, or branch, or other instruction.
- if instruction is for memory access:
- use opA + opB, or just opB as offset to retrieve CapResponse by calling
capVal <- capCop.getCapResponse(capReq, Memory)
and grab the result from capVal
.
- bring result and store it at er.opA = capVal.data
- go through coprocessor0 (MMU) by
scResult <- cp0.setLlScReg(er.opA[63:0], er.test == LL, di.mem == Write)
- if write, store conditional, get data to be written, either from cop1 (di.storeDatasrc == CoPro1) or from cop2 (di.storeDatasrc == CoPro2)
- set write value
writeVal = er.opB
?? Which one is address to be stored, opA or opB???
- if instruction is for branch:
- what does opA opB mean? which is the target address? It seems to be opA; and opB will be used to store the old PCC.
capReq.offset = unpack(er.opB)
capVal <- capCop.getCapResponse(capReq, Branch)
- check
capVal.valid
and read capability data form Cop2 er.opB = capVal.data
(the old pcc)
- other instruction (not a memory op or a branch, classified as Arithmetic)
capVal <- capCop.getCapResponse(capReq, Arithmetic)
- check capVal.valid.
- do alu and store result to calcResult[64:0];
- copy result to er.opA, er.carryout
- pendingOps.enq(er)
- outQ.enq(er)
If you could revise
the fundmental principles of
computer system design
to improve security...
... what would you change?