From 2333c5f0afe51328b38f86412100e396d9369733 Mon Sep 17 00:00:00 2001 From: Catherine Date: Fri, 22 Mar 2024 21:17:38 +0000 Subject: [PATCH] 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. --- amaranth/lib/memory.py | 2 +- tests/test_lib_memory.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amaranth/lib/memory.py b/amaranth/lib/memory.py index 823c5b5..697857a 100644 --- a/amaranth/lib/memory.py +++ b/amaranth/lib/memory.py @@ -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): diff --git a/tests/test_lib_memory.py b/tests/test_lib_memory.py index d0cdcf9..07b26c2 100644 --- a/tests/test_lib_memory.py +++ b/tests/test_lib_memory.py @@ -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, ())