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-Tag: working~342 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6d5878a0ee8125aa346a15a12df7039e14d39181;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):