nmigen.hdl.rec: restore Record.shape().
authorawygle <awygle@gmail.com>
Tue, 17 Nov 2020 19:36:58 +0000 (11:36 -0800)
committerGitHub <noreply@github.com>
Tue, 17 Nov 2020 19:36:58 +0000 (19:36 +0000)
This method was lost in commit abbebf8e.

nmigen/hdl/rec.py
tests/test_hdl_rec.py

index b72940070122db877bb389a6908db9c6a1e9fbbb..b5cd0f7cfb0fdc3413e771e4f47e46e580abd526 100644 (file)
@@ -198,6 +198,9 @@ class Record(ValueCastable):
             name = "<unnamed>"
         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:
index 452abdd52915fee65efbdcaa57715bccfd64ca7e..4b14cb6f25bf42dada748aa674d1c5b87a4ffe78 100644 (file)
@@ -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)