Working branching.

This commit is contained in:
Sebastian Bugge 2024-11-11 17:49:10 +01:00
parent 23656db068
commit cfce1b6b54
Signed by: kaholaz
GPG key ID: 2EFFEDEE03519691
7 changed files with 31 additions and 23 deletions

View file

@ -11,6 +11,7 @@ class IFBarrier extends MultiIOModule {
val instructionIn = Input(new Instruction)
val instructionOut = Output(new Instruction)
val stall = Input(Bool())
val flush = Input(Bool())
})
val PC = RegInit(UInt(32.W), 0.U)
@ -19,11 +20,22 @@ class IFBarrier extends MultiIOModule {
val instruction = Reg(new Instruction)
val replay = RegInit(Bool(), false.B)
val flushRemaining = RegInit(UInt(2.W), 0.U)
flushRemaining := Mux(
io.flush,
2.U,
Mux(
flushRemaining === 0.U,
0.U,
flushRemaining - 1.U
)
)
replay := io.stall
instruction := io.instructionIn
io.instructionOut := Mux(
io.stall,
io.stall || io.flush || flushRemaining > 0.U,
Instruction.NOP,
Mux(
replay,