@@ -18,32 +18,44 @@ class BEU extends Module with InstConfig {
1818 val tgt = Output (UInt (XLen .W ))
1919 })
2020
21- protected val beq = (io.isa === instBEQ) && (io.src1 === io.src2)
22- protected val bne = (io.isa === instBNE) && (io.src1 =/= io.src2)
23- protected val bgeu = (io.isa === instBGEU) && (io.src1 >= io.src2)
24- protected val bltu = (io.isa === instBLTU) && (io.src1 < io.src2)
25- protected val bge = (io.isa === instBGE) && (io.src1.asSInt >= io.src2.asSInt)
26- protected val blt = (io.isa === instBLT) && (io.src1.asSInt < io.src2.asSInt)
27- protected val b = beq | bne | bgeu | bltu | bge | blt
28- protected val bInst = (io.isa === instBEQ) || (io.isa === instBNE) || (io.isa === instBGEU) || (io.isa === instBLTU) ||
29- (io.isa === instBGE) || (io.isa === instBLT) || (io.isa === instJAL) || (io.isa === instJALR)
21+ protected val b = MuxLookup (
22+ io.isa,
23+ false .B ,
24+ Seq (
25+ instBEQ -> (io.src1 === io.src2),
26+ instBNE -> (io.src1 =/= io.src2),
27+ instBGEU -> (io.src1 >= io.src2),
28+ instBLTU -> (io.src1 < io.src2),
29+ instBGE -> (io.src1.asSInt >= io.src2.asSInt),
30+ instBLT -> (io.src1.asSInt < io.src2.asSInt)
31+ )
32+ )
33+
34+ protected val bInst = MuxLookup (
35+ io.isa,
36+ false .B ,
37+ Seq (
38+ instBEQ -> true .B ,
39+ instBNE -> true .B ,
40+ instBGEU -> true .B ,
41+ instBLTU -> true .B ,
42+ instBGE -> true .B ,
43+ instBLT -> true .B
44+ )
45+ )
3046
3147 protected val jal = io.isa === instJAL
3248 protected val jalr = io.isa === instJALR
33-
34- protected val b_tgt = io.pc + io.imm
35- protected val jal_tgt = io.pc + io.imm
36- protected val jalr_tgt = io.src1 + io.imm
37-
3849 io.branch := b | jal | jalr
3950
40- when(jal) {
41- io.tgt := jal_tgt
42- }.elsewhen(jalr) {
43- io.tgt := jalr_tgt
44- }.otherwise {
45- io.tgt := b_tgt
46- }
51+ io.tgt := MuxLookup (
52+ io.isa,
53+ (io.pc + io.imm), // NOTE: branch target
54+ Seq (
55+ instJAL -> (io.pc + io.imm),
56+ instJALR -> (io.src1 + io.imm),
57+ )
58+ )
4759
4860 io.branchInfo.branch := bInst
4961 io.branchInfo.jump := jal || jalr
0 commit comments