Working branching.

This commit is contained in:
Sebastian Bugge 2024-10-04 02:16:17 +02:00
parent 934593fb6f
commit 92d0dfd9eb
Signed by: kaholaz
GPG key ID: 2EFFEDEE03519691
9 changed files with 102 additions and 32 deletions

View file

@ -25,6 +25,8 @@ class InstructionFetch extends MultiIOModule {
new Bundle {
val PC = Output(UInt(32.W))
val instruction = Output(new Instruction)
val branch = Input(Bool())
val branchAddress = Input(UInt(32.W))
})
val IMEM = Module(new IMEM)
@ -45,7 +47,7 @@ class InstructionFetch extends MultiIOModule {
*/
io.PC := PC
IMEM.io.instructionAddress := PC
PC := PC + 4.U
PC := Mux(io.branch, io.branchAddress, PC + 4.U)
val instruction = Wire(new Instruction)
instruction := IMEM.io.instruction.asTypeOf(new Instruction)