lib.memory: expand Memory.Init.__repr__().

Display `shape` and `depth` also. `depth` is redundant although useful
for ease of reading (there are always `depth` elements shown), but
`shape` was just lost.
This commit is contained in:
Catherine 2024-03-22 21:17:38 +00:00
parent fc84b8decf
commit 2333c5f0af
2 changed files with 2 additions and 2 deletions

View file

@ -117,7 +117,7 @@ class Memory(wiring.Component):
return self._depth
def __repr__(self):
return f"Memory.Init({self._elems!r})"
return f"Memory.Init({self._elems!r}, shape={self._shape!r}, depth={self._depth})"
def __init__(self, *, shape, depth, init, attrs=None, src_loc_at=0):

View file

@ -290,7 +290,7 @@ class MemoryTestCase(FHDLTestCase):
self.assertIsInstance(m.init, memory.Memory.Init)
self.assertEqual(list(m.init), [1, 2, 3, 0])
self.assertEqual(m.init._raw, [1, 2, 3, 0])
self.assertRepr(m.init, "Memory.Init([1, 2, 3, 0])")
self.assertRepr(m.init, "Memory.Init([1, 2, 3, 0], shape=8, depth=4)")
self.assertEqual(m.r_ports, ())
self.assertEqual(m.w_ports, ())