Skip to content

Commit c1ed908

Browse files
authored
nmigen.hdl.rec: restore Record.shape().
This method was lost in commit abbebf8.
1 parent 4431814 commit c1ed908

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

nmigen/hdl/rec.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ def __repr__(self):
198198
name = "<unnamed>"
199199
return "(rec {} {})".format(name, " ".join(fields))
200200

201+
def shape(self):
202+
return self.as_value().shape()
203+
201204
def connect(self, *subordinates, include=None, exclude=None):
202205
def rec_name(record):
203206
if record.name is None:

tests/test_hdl_rec.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ def test_construct_with_fields(self):
176176
self.assertIs(r.stb, ns)
177177
self.assertIs(r.info, nr)
178178

179+
def test_shape(self):
180+
r1 = Record([("a", 1), ("b", 2)])
181+
self.assertEqual(r1.shape(), unsigned(3))
182+
179183
def test_like(self):
180184
r1 = Record([("a", 1), ("b", 2)])
181185
r2 = Record.like(r1)

0 commit comments

Comments
 (0)