fhdl.dsl: allow f.sync["dom"] as a synonym of f.sync.dom.
authorwhitequark <whitequark@whitequark.org>
Wed, 12 Dec 2018 10:00:00 +0000 (10:00 +0000)
committerwhitequark <whitequark@whitequark.org>
Wed, 12 Dec 2018 10:00:00 +0000 (10:00 +0000)
nmigen/fhdl/dsl.py

index b193e126141a06fcc04537a9686352a1f132012f..2b145416e3eff7917e4135db16dcd7c346674ae8 100644 (file)
@@ -38,11 +38,17 @@ class _ModuleBuilderSync(_ModuleBuilderProxy):
     def __getattr__(self, name):
         return _ModuleBuilderSyncCD(self._builder, self._depth, name)
 
+    def __getitem__(self, name):
+        return self.__getattr__(name)
+
     def __setattr__(self, name, value):
         if not isinstance(value, _ModuleBuilderSyncCD):
             raise AttributeError("Cannot assign sync.{} attribute - use += instead"
                                  .format(name))
 
+    def __setitem__(self, name, value):
+        return self.__setattr__(name, value)
+
 
 class _ModuleBuilderRoot:
     def __init__(self, builder, depth):