Working branching.
This commit is contained in:
parent
23656db068
commit
cfce1b6b54
7 changed files with 31 additions and 23 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue