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
|
IF.io.branchAddress := EXBarrier.out.ALUResult
|
||||||
|
|
||||||
// Stall
|
// Stall
|
||||||
IF.io.stall := ID.io.stall
|
IF.io.stall := IDBarrier.stall || ID.io.stall
|
||||||
|
IFBarrier.stall := IDBarrier.stall
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,16 +94,12 @@ class InstructionDecode extends MultiIOModule {
|
||||||
stallDelay,
|
stallDelay,
|
||||||
stallsRemaining - 1.U,
|
stallsRemaining - 1.U,
|
||||||
Mux(
|
Mux(
|
||||||
decoder.controlSignals.memRead,
|
decoder.controlSignals.branch,
|
||||||
1.U,
|
3.U,
|
||||||
Mux(
|
0.U
|
||||||
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.stall := stall
|
||||||
|
|
||||||
io.jump := Mux(stallDelay, false.B, decoder.controlSignals.jump)
|
io.jump := Mux(stallDelay, false.B, decoder.controlSignals.jump)
|
||||||
|
|
|
@ -27,9 +27,11 @@ class IDBarrier extends MultiIOModule {
|
||||||
new Bundle {
|
new Bundle {
|
||||||
val in = Input(new IDBarrierIO)
|
val in = Input(new IDBarrierIO)
|
||||||
val out = Output(new IDBarrierIO)
|
val out = Output(new IDBarrierIO)
|
||||||
|
val stall = Output(Bool())
|
||||||
})
|
})
|
||||||
|
|
||||||
val delay = Reg(new IDBarrierIO)
|
val delay = Reg(new IDBarrierIO)
|
||||||
delay := io.in
|
delay := io.in
|
||||||
io.out := delay
|
io.out := delay
|
||||||
|
io.stall := io.out.memRead
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,25 @@ class IFBarrier extends MultiIOModule {
|
||||||
val PCout = Output(UInt(32.W))
|
val PCout = Output(UInt(32.W))
|
||||||
val instructionIn = Input(new Instruction)
|
val instructionIn = Input(new Instruction)
|
||||||
val instructionOut = Output(new Instruction)
|
val instructionOut = Output(new Instruction)
|
||||||
|
val stall = Input(Bool())
|
||||||
})
|
})
|
||||||
|
|
||||||
val PC = RegInit(UInt(32.W), 0.U)
|
val PC = RegInit(UInt(32.W), 0.U)
|
||||||
PC := io.PCin
|
PC := Mux(io.stall, PC, io.PCin)
|
||||||
io.PCout := PC
|
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 {
|
object Manifest {
|
||||||
|
|
||||||
val singleTest = "fucked.s"
|
val singleTest = "simpleload.s"
|
||||||
|
|
||||||
val nopPadded = false
|
val nopPadded = false
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue