Do memread stalling correctly.

This commit is contained in:
Sebastian Bugge 2024-11-11 01:59:20 +01:00
parent 4cfd8268fd
commit 23656db068
Signed by: kaholaz
GPG key ID: 2EFFEDEE03519691
5 changed files with 25 additions and 12 deletions

View file

@ -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
}

View file

@ -94,16 +94,12 @@ class InstructionDecode extends MultiIOModule {
stallDelay,
stallsRemaining - 1.U,
Mux(
decoder.controlSignals.memRead,
1.U,
Mux(
decoder.controlSignals.branch,
3.U,
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.jump := Mux(stallDelay, false.B, decoder.controlSignals.jump)

View file

@ -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
}

View file

@ -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
)
)
}

View file

@ -19,7 +19,7 @@ import LogParser._
object Manifest {
val singleTest = "fucked.s"
val singleTest = "simpleload.s"
val nopPadded = false