hdl.ast: Fix width for unary minus operator on signed argument.
To properly represent a negation of a signed X-bit quantity we may, in general, need a signed (X+1)-bit signal — for example, negation of 3-bit -4 is 4, which is not representable in signed 3 bits.
This commit is contained in:
parent
7650431996
commit
67650214b7
2 changed files with 2 additions and 5 deletions
|
|
@ -252,7 +252,7 @@ class OperatorTestCase(FHDLTestCase):
|
|||
self.assertEqual(v1.shape(), signed(5))
|
||||
v2 = -Const(0, signed(4))
|
||||
self.assertEqual(repr(v2), "(- (const 4'sd0))")
|
||||
self.assertEqual(v2.shape(), signed(4))
|
||||
self.assertEqual(v2.shape(), signed(5))
|
||||
|
||||
def test_add(self):
|
||||
v1 = Const(0, unsigned(4)) + Const(0, unsigned(6))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue