From: whitequark Date: Wed, 12 Dec 2018 10:00:00 +0000 (+0000) Subject: fhdl.dsl: allow f.sync["dom"] as a synonym of f.sync.dom. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e58eea0a4634460d34b086be070b49a24127112e;p=nmigen.git fhdl.dsl: allow f.sync["dom"] as a synonym of f.sync.dom. --- diff --git a/nmigen/fhdl/dsl.py b/nmigen/fhdl/dsl.py index b193e12..2b14541 100644 --- a/nmigen/fhdl/dsl.py +++ b/nmigen/fhdl/dsl.py @@ -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):