Do memread stalling correctly.
This commit is contained in:
parent
4cfd8268fd
commit
23656db068
5 changed files with 25 additions and 12 deletions
|
@ -136,5 +136,6 @@ class CPU extends MultiIOModule {
|
|||
IF.io.branchAddress := EXBarrier.out.ALUResult
|
||||
|
||||
// Stall
|
||||
IF.io.stall := ID.io.stall
|
||||
IF.io.stall := IDBarrier.stall || ID.io.stall
|
||||
IFBarrier.stall := IDBarrier.stall
|
||||
}
|
||||
|
|
|
@ -93,17 +93,13 @@ class InstructionDecode extends MultiIOModule {
|
|||
stallsRemaining := Mux(
|
||||
stallDelay,
|
||||
stallsRemaining - 1.U,
|
||||
Mux(
|
||||
decoder.controlSignals.memRead,
|
||||
1.U,
|
||||
Mux(
|
||||
decoder.controlSignals.branch,
|
||||
3.U,
|
||||
0.U
|
||||
)
|
||||
))
|
||||
|
||||
val stall = stallsRemaining > 1.U || decoder.controlSignals.memRead && !stallDelay || decoder.controlSignals.branch && !stallDelay
|
||||
val stall = stallsRemaining > 1.U || decoder.controlSignals.branch && !stallDelay
|
||||
io.stall := stall
|
||||
|
||||
io.jump := Mux(stallDelay, false.B, decoder.controlSignals.jump)
|
||||
|
|
|
@ -27,9 +27,11 @@ class IDBarrier extends MultiIOModule {
|
|||
new Bundle {
|
||||
val in = Input(new IDBarrierIO)
|
||||
val out = Output(new IDBarrierIO)
|
||||
val stall = Output(Bool())
|
||||
})
|
||||
|
||||
val delay = Reg(new IDBarrierIO)
|
||||
delay := io.in
|
||||
io.out := delay
|
||||
io.stall := io.out.memRead
|
||||
}
|
||||
|
|
|
@ -10,11 +10,25 @@ class IFBarrier extends MultiIOModule {
|
|||
val PCout = Output(UInt(32.W))
|
||||
val instructionIn = Input(new Instruction)
|
||||
val instructionOut = Output(new Instruction)
|
||||
val stall = Input(Bool())
|
||||
})
|
||||
|
||||
val PC = RegInit(UInt(32.W), 0.U)
|
||||
PC := io.PCin
|
||||
PC := Mux(io.stall, PC, io.PCin)
|
||||
io.PCout := PC
|
||||
|
||||
io.instructionOut := io.instructionIn
|
||||
val instruction = Reg(new Instruction)
|
||||
val replay = RegInit(Bool(), false.B)
|
||||
replay := io.stall
|
||||
instruction := io.instructionIn
|
||||
|
||||
io.instructionOut := Mux(
|
||||
io.stall,
|
||||
Instruction.NOP,
|
||||
Mux(
|
||||
replay,
|
||||
instruction,
|
||||
io.instructionIn
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import LogParser._
|
|||
|
||||
object Manifest {
|
||||
|
||||
val singleTest = "fucked.s"
|
||||
val singleTest = "simpleload.s"
|
||||
|
||||
val nopPadded = false
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue