Skip to content

Configurable Module

Configurable Module.

AConfigurableMod

Bases: BaseTopMod

A Module Which Is Assembled According To A Receipe (AConfig).

See : for arguments, attributes and details.

Additionally the config has to be provided at instantiation. A AConfigurableMod may define a default_config which is taken if no config is provided at instantiaion.

All module parameter, local parameter, ports, signals and submodules MUST be added and created within the _build method depending on the config.

.. attention:: It is forbidden to implement add methods or any other tailored functionality. Use a tailored module instead!

Configurable modules are located next to the python file and use the configuration name in the module name.

Attributes:

Name Type Description
config BaseConfig
AConfigurableMod Example
Basics:

>>> import ucdp as u
>>> class MyConfig(u.AConfig):
...
...     feature: bool = False

>>> class ProcMod(u.AConfigurableMod):
...
...     config: MyConfig = MyConfig('default')
...
...     def _build(self) -> None:
...         if self.config.feature:
...             self.add_port(u.UintType(8), "feature_i")
...             self.add_port(u.UintType(8), "feature_o")
...         else:
...             self.add_port(u.UintType(8), "default_o")

>>> my = ProcMod()
>>> my.modname
'proc_default'
>>> my.ports
Idents([Port(UintType(8), 'default_o', direction=OUT)])

>>> my = ProcMod(config=MyConfig('other', feature=True))
>>> my.modname
'proc_other'
>>> my.ports
Idents([Port(UintType(8), 'feature_i', direction=IN), Port(UintType(8), 'feature_o', direction=OUT)])

modname property

modname

Module Name.

topmodname property

topmodname

Top Module Name.