From: awygle Date: Tue, 17 Nov 2020 19:36:58 +0000 (-0800) Subject: nmigen.hdl.rec: restore Record.shape(). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c1ed90807be2d4973338b951413f636836a5dfce;p=nmigen.git nmigen.hdl.rec: restore Record.shape(). This method was lost in commit abbebf8e. --- 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)