gen/fhdl/module: Add add/get_module methods to simplify user design and avoid direct use of setattr/getattr.
This commit is contained in:
parent
9bf276132a
commit
fac9fb81a2
|
@ -49,3 +49,14 @@ class LiteXModule(Module, AutoCSR, AutoDoc):
|
||||||
else:
|
else:
|
||||||
object.__iadd__(m, other)
|
object.__iadd__(m, other)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
def add_module(self, name, module):
|
||||||
|
assert isinstance(module, Module)
|
||||||
|
assert not hasattr(self, name)
|
||||||
|
setattr(self, name, module)
|
||||||
|
|
||||||
|
def get_module(self, name):
|
||||||
|
module = getattr(self, name, None)
|
||||||
|
if module is not None:
|
||||||
|
assert isinstance(module, Module)
|
||||||
|
return module
|
||||||
|
|
Loading…
Reference in New Issue