b = dut.i.b
carry_in = dut.i.carry_in
so_in = dut.i.so
- carry_out = dut.o.carry_out
+ carry_out = dut.o.xer_co.data[0]
+ carry_out32 = dut.o.xer_co.data[1]
o = dut.o.o
# setup random inputs
comb += a_signed.eq(a)
comb += a_signed_32.eq(a[0:32])
+ comb += Assume(a[32:64] == 0)
+ comb += Assume(b[32:64] == 0)
# main assertion of arithmetic operations
with m.Switch(rec.insn_type):
with m.Case(InternalOp.OP_ADD):
+
comb += Assert(Cat(o, carry_out) == (a + b + carry_in))
+ # CA32
+ comb += Assert((a[0:32] + b[0:32] + carry_in)[32]
+ == carry_out32)
+
return m
comb += o.eq(add_output[1:-1])
comb += carry_out.data[0].eq(add_output[-1]) # XER.CO
- # XXX no! wrongggg, see microwatt OP_ADD code
+ # see microwatt OP_ADD code
# https://bugs.libre-soc.org/show_bug.cgi?id=319#c5
- comb += carry_out.data[1].eq(add_output[-1]) # XER.CO32
+ comb += carry_out.data[1].eq(add_output[33] ^
+ (a[32] ^ b[32])) # XER.CO32
#### exts (sign-extend) ####
with m.Case(InternalOp.OP_EXTS):
self.assertEqual(expected_carry, real_carry, code)
expected_carry32 = 1 if sim.spr['XER'][XER_bits['CA32']] else 0
real_carry32 = yield alu.n.data_o.xer_co.data[1] # XXX CO32
- self.assertEqual(expected_carry, real_carry, code)
+ self.assertEqual(expected_carry32, real_carry32, code)