+ with m.Case(InternalOp.OP_B):
+ # Extract target address
+ LI = i_fields.LI[0:-1]
+ imm = exts(LI, LI.shape().width, 64-2) * 4
+
+ # Assert that it always branches
+ comb += Assert(dut.o.nia.ok == 1)
+
+ # Check absolute or relative branching
+ with m.If(AA):
+ comb += Assert(dut.o.nia.data == imm)
+ with m.Else():
+ comb += Assert(dut.o.nia.data == (cia + imm)[0:64])
+
+ # Make sure linking works
+ with m.If(LK & rec.lk):
+ comb += Assert(dut.o.lr.data == (cia + 4)[0:64])
+ comb += Assert(dut.o.lr.ok == 1)
+ with m.Case(InternalOp.OP_BC):
+ # Assert that branches are conditional
+ comb += Assert(dut.o.nia.ok == (cond_ok & ctr_ok))
+
+ # extract target address
+ BD = b_fields.BD[0:-1]
+ imm = exts(BD, BD.shape().width, 64-2) * 4
+
+ # Check absolute or relative branching
+ with m.If(dut.o.nia.ok):
+ with m.If(AA):
+ comb += Assert(dut.o.nia.data == imm)
+ with m.Else():
+ comb += Assert(dut.o.nia.data == (cia + imm)[0:64])
+ with m.If(LK & rec.lk):
+ comb += Assert(dut.o.lr.data == (cia + 4)[0:64])
+ comb += Assert(dut.o.lr.ok == 1)
+
+ # Check that CTR is decremented
+ with m.If(~BO[2]):
+ comb += Assert(dut.o.ctr.data == ctr_next)
+ with m.Case(InternalOp.OP_BCREG):
+ # assert that the condition is good
+ comb += Assert(dut.o.nia.ok == (cond_ok & ctr_ok))
+
+ with m.If(dut.o.nia.ok):
+ # make sure we branch to the spr input
+ comb += Assert(dut.o.nia.data == spr1)
+
+ # make sure branch+link works
+ with m.If(LK & rec.lk):
+ comb += Assert(dut.o.lr.data == (cia + 4)[0:64])
+ comb += Assert(dut.o.lr.ok == 1)
+
+ # Check that CTR is decremented
+ with m.If(~BO[2]):
+ comb += Assert(dut.o.ctr.data == ctr_next)
+