fixed bug in value_bits_sign of mul operatiors

This commit is contained in:
Yves Delley 2015-09-09 15:32:09 +02:00
parent 5253b0c06e
commit 6e9d6d7a8e

View file

@ -50,13 +50,13 @@ def value_bits_sign(v):
elif v.op == "*": elif v.op == "*":
if not obs[0][1] and not obs[1][1]: if not obs[0][1] and not obs[1][1]:
# both operands unsigned # both operands unsigned
return obs[0][0] + obs[1][0] return obs[0][0] + obs[1][0], False
elif obs[0][1] and obs[1][1]: elif obs[0][1] and obs[1][1]:
# both operands signed # both operands signed
return obs[0][0] + obs[1][0] - 1 return obs[0][0] + obs[1][0] - 1, True
else: else:
# one operand signed, the other unsigned (add sign bit) # one operand signed, the other unsigned (add sign bit)
return obs[0][0] + obs[1][0] + 1 - 1 return obs[0][0] + obs[1][0] + 1 - 1, True
elif v.op == "<<<": elif v.op == "<<<":
if obs[1][1]: if obs[1][1]:
extra = 2**(obs[1][0] - 1) - 1 extra = 2**(obs[1][0] - 1) - 1