From c1ed90807be2d4973338b951413f636836a5dfce Mon Sep 17 00:00:00 2001 From: awygle Date: Tue, 17 Nov 2020 11:36:58 -0800 Subject: [PATCH] nmigen.hdl.rec: restore Record.shape(). This method was lost in commit abbebf8e. --- nmigen/hdl/rec.py | 3 +++ tests/test_hdl_rec.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/nmigen/hdl/rec.py b/nmigen/hdl/rec.py index b729400..b5cd0f7 100644 --- a/nmigen/hdl/rec.py +++ b/nmigen/hdl/rec.py @@ -198,6 +198,9 @@ class Record(ValueCastable): name = "" return "(rec {} {})".format(name, " ".join(fields)) + def shape(self): + return self.as_value().shape() + def connect(self, *subordinates, include=None, exclude=None): def rec_name(record): if record.name is None: diff --git a/tests/test_hdl_rec.py b/tests/test_hdl_rec.py index 452abdd..4b14cb6 100644 --- a/tests/test_hdl_rec.py +++ b/tests/test_hdl_rec.py @@ -176,6 +176,10 @@ class RecordTestCase(FHDLTestCase): self.assertIs(r.stb, ns) self.assertIs(r.info, nr) + def test_shape(self): + r1 = Record([("a", 1), ("b", 2)]) + self.assertEqual(r1.shape(), unsigned(3)) + def test_like(self): r1 = Record([("a", 1), ("b", 2)]) r2 = Record.like(r1) -- 2.30.2