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

@ -10,6 +10,11 @@ class Execute extends MultiIOModule {
new Bundle {
val op1 = Input(SInt(32.W))
val op2 = Input(SInt(32.W))
val rs1ValueIn = Input(SInt(32.W))
val rs2ValueIn = Input(SInt(32.W))
val rs2ValueOut = Output(SInt(32.W))
val branchType = Input(UInt(3.W))
val branch = Output(Bool())
val ALUOp = Input(UInt(4.W))
val ALUResult = Output(SInt(32.W))
}
@ -30,5 +35,17 @@ class Execute extends MultiIOModule {
ALUOps.COPY_B -> io.op2,
)
val BranchALUOpsMap = Array (
branchType.beq -> (io.rs1ValueIn === io.rs2ValueIn),
branchType.neq -> !(io.rs1ValueIn === io.rs2ValueIn),
branchType.lt -> (io.rs1ValueIn < io.rs2ValueIn),
branchType.gte -> (io.rs1ValueIn >= io.rs2ValueIn),
branchType.ltu -> (io.rs1ValueIn.asUInt() < io.rs2ValueIn.asUInt()),
branchType.gteu -> (io.rs1ValueIn.asUInt() >= io.rs2ValueIn.asUInt()),
branchType.jump -> true.B,
)
io.rs2ValueOut := io.rs2ValueIn
io.branch := MuxLookup(io.branchType, false.B, BranchALUOpsMap)
io.ALUResult := MuxLookup(io.ALUOp, 0.S(32.W), ALUOpsMap)
}