hdl.ast: fix Const.cast(Cat(...)) handling for signed numbers.

This commit is contained in:
Wanda 2023-12-30 12:09:28 +01:00 committed by Catherine
parent 82d35fb932
commit 6780c838b2
2 changed files with 12 additions and 1 deletions

View file

@ -935,6 +935,16 @@ class CatTestCase(FHDLTestCase):
r"specify the width explicitly using C\(2, 2\)$"):
Cat(2)
def test_const(self):
a = Const.cast(Cat(Const(1, 1), Const(0, 1), Const(3, 2), Const(2, 2)))
self.assertEqual(a.value, 0x2d)
self.assertEqual(a.width, 6)
self.assertEqual(a.signed, False)
a = Const.cast(Cat(Const(-4, 8), Const(-3, 8)))
self.assertEqual(a.value, 0xfdfc)
self.assertEqual(a.width, 16)
self.assertEqual(a.signed, False)
class ReplTestCase(FHDLTestCase):
@_ignore_deprecated