hdl.rec: separate record and signal name with __, not _.
authoranuejn <jarohabiger@googlemail.com>
Mon, 25 Mar 2019 14:26:00 +0000 (15:26 +0100)
committerwhitequark <whitequark@whitequark.org>
Mon, 25 Mar 2019 14:26:00 +0000 (14:26 +0000)
This makes names of signals within records less ambiguous, in case
they themselves have underscores within them.

nmigen/hdl/rec.py
nmigen/test/test_hdl_rec.py

index 999c85bcbac862104c5096ec2940ab5655ba9e6b..f1ddbd2995e26e78db28cd8df7509491e45f8b16 100644 (file)
@@ -72,7 +72,7 @@ class Record(Value):
         def concat(a, b):
             if a is None:
                 return b
-            return "{}_{}".format(a, b)
+            return "{}__{}".format(a, b)
 
         self.layout = Layout.wrap(layout)
         self.fields = OrderedDict()
index 3f68247176336a3fd547ad5c1f3d8747ffe041ea..65e8bf6bc2ea477c4d4de332f3ff48e19d97f05a 100644 (file)
@@ -65,11 +65,11 @@ class RecordTestCase(FHDLTestCase):
             ])
         ])
 
-        self.assertEqual(repr(r), "(rec r stb data (rec r_info a b))")
+        self.assertEqual(repr(r), "(rec r stb data (rec r__info a b))")
         self.assertEqual(len(r),  35)
         self.assertIsInstance(r.stb, Signal)
-        self.assertEqual(r.stb.name, "r_stb")
-        self.assertEqual(r["stb"].name, "r_stb")
+        self.assertEqual(r.stb.name, "r__stb")
+        self.assertEqual(r["stb"].name, "r__stb")
 
     def test_unnamed(self):
         r = [Record([