bits, sign = self._bitwise_binary_shape(*op_shapes)
return bits + 1, sign
if self.op == "*":
- if not a_sign and not b_sign:
- # both operands unsigned
- return a_bits + b_bits, False
- if a_sign and b_sign:
- # both operands signed
- return a_bits + b_bits - 1, True
- # one operand signed, the other unsigned (add sign bit)
- return a_bits + b_bits + 1 - 1, True
+ return a_bits + b_bits, a_sign or b_sign
if self.op == "%":
return a_bits, a_sign
if self.op in ("<", "<=", "==", "!=", ">", ">=", "b"):
self.assertEqual(repr(v1), "(* (const 4'd0) (const 6'd0))")
self.assertEqual(v1.shape(), (10, False))
v2 = Const(0, (4, True)) * Const(0, (6, True))
- self.assertEqual(v2.shape(), (9, True))
+ self.assertEqual(v2.shape(), (10, True))
v3 = Const(0, (4, True)) * Const(0, (4, False))
self.assertEqual(v3.shape(), (8, True))
v5 = 10 * Const(0, 4)