hwt.synthesizer.interfaceLevel package

interfaceLevel is responsible for manipulation of high-level interfaces.

Submodules

hwt.synthesizer.interfaceLevel.emptyUnit module

class hwt.synthesizer.interfaceLevel.emptyUnit.EmptyUnit(hdl_name_override: Optional[str] = None)[source]

Bases: hwt.synthesizer.unit.Unit

hwt.synthesizer.unit.Unit used for prototyping all output interfaces are connected to _def_val and this is only think which architecture contains

Variables:_def_val – this value is used to initialize all signals
_def_val = None
_impl()[source]

Implementation - construct main body of the component in this function.

  • called after _declr
hwt.synthesizer.interfaceLevel.emptyUnit._connect_to_const_it(val, intf: hwt.synthesizer.interface.Interface, exclude: Optional[Set[hwt.synthesizer.interface.Interface]])[source]

Connect constant to all output ports, used mainly during the debbug to dissable interface

hwt.synthesizer.interfaceLevel.emptyUnit.connect_to_const(val, intf: hwt.synthesizer.interface.Interface, exclude=None)[source]

hwt.synthesizer.interfaceLevel.getDefaultClkRts module

hwt.synthesizer.interfaceLevel.getDefaultClkRts.getClk(unit: hwt.synthesizer.interfaceLevel.mainBases.UnitBase)[source]

Get clock signal from unit instance

hwt.synthesizer.interfaceLevel.getDefaultClkRts.getRst(unit: hwt.synthesizer.interfaceLevel.mainBases.UnitBase)[source]

Get reset signal from unit instance

hwt.synthesizer.interfaceLevel.mainBases module

class hwt.synthesizer.interfaceLevel.mainBases.InterfaceBase[source]

Bases: object

Main base class for all interfaces

class hwt.synthesizer.interfaceLevel.mainBases.UnitBase[source]

Bases: object

Main base class for all units

hwt.synthesizer.interfaceLevel.propDeclrCollector module

class hwt.synthesizer.interfaceLevel.propDeclrCollector.MakeClkRstAssociations(unit, clk=None, rst=None)[source]

Bases: object

All newly added interfaces will be associated with clk, rst specified in constructor of this object.

__init__(unit, clk=None, rst=None)[source]

Initialize self. See help(type(self)) for accurate signature.

class hwt.synthesizer.interfaceLevel.propDeclrCollector.MakeParamsShared(unit, exclude, prefix)[source]

Bases: object

All newly added interfaces and units will share all parametes with unit specified in constructor of this object.

__init__(unit, exclude, prefix)[source]

Initialize self. See help(type(self)) for accurate signature.

class hwt.synthesizer.interfaceLevel.propDeclrCollector.PropDeclrCollector[source]

Bases: object

Class which manages the registration of components and interfaces in specified elaboration phases.

It uses __setattr__ listeners to detect new properties and then calls a litener function to process the registration.

Used for Unit, Interface classes to detect and load interfaces and components.

_associated(clk=None, rst=None) → hwt.synthesizer.interfaceLevel.propDeclrCollector.MakeClkRstAssociations[source]

associate newly added interfaces to “self” with selected clk, rst (if interface is not associated agents try to find clk/rst by _getAssociatedClk/_getAssociatedRst which will search for any clk/rst on parent recursively) Usage:

with self._associated(clk=self.myClk, rst=self.myRst):
    self.myAxi = AxiStrem()
    # this interface is associated with myClk and myRst
    # simulation agents and component builders will use them
Parameters:exclude – params which should not be shared
_config() → None[source]

Configure object parameters

  • setup all parameters on this object, use Param class instances to allow use of parameter inheritance
  • called in __init__ of class
_declr() → None[source]

In this function user should specify the declaration of interfaces for communication with outside word. It is also better to declare sub components there as it allows for better paralelization during the build.

  • _declr method is called after _config
  • if this object is hwt.synthesizer.unit.Unit all interfaces are threated as externally accessible interfaces if this object is Interface instance all subinterfaces are loaded as well
_declrCollector(name: str, prop: object)[source]
_impl() → None[source]

Implementation - construct main body of the component in this function.

  • called after _declr
_implCollector(name, prop)[source]

Handle property definitions in _impl phase

_loadConfig() → None[source]

Load params in _config()

_loadImpl()[source]
_make_association(clk=None, rst=None) → None[source]

Associate this object with specified clk/rst

_paramCollector(pName, prop)[source]
_paramsShared(exclude: Optional[Tuple[Set[str], Set[str]]] = None, prefix='') → hwt.synthesizer.interfaceLevel.propDeclrCollector.MakeParamsShared[source]

Auto-propagate params by name to child components and interfaces Usage:

with self._paramsShared():
    # your interfaces and unit which should share all params with "self" there
Parameters:
  • exclude – tuple (src param names to exclude, dst param names to exclude)
  • prefix – prefix which should be added to name of child parameters before parameter name matching
_registerArray(name, items: hwt.synthesizer.hObjList.HObjList)[source]

Register array of items on interface level object

_registerArray_append(h_obj_list: hwt.synthesizer.hObjList.HObjList, item, index: int)[source]

Register a single object in the list

_registerInterface(iName, intf, isPrivate=False)[source]

Register interface object on interface level object

_registerIntfInImpl(iName, i)[source]

Register interface in implementation phase

_registerParameter(pName, parameter: hwt.synthesizer.param.Param) → None[source]

Register Param object on interface level object

_registerUnit(uName, unit)[source]

Register unit object on interface level object

_registerUnitInImpl(uName, u)[source]
Attention:unit has to be parametrized before it is registered (some components can change interface by parametrization)
_updateParamsFrom(otherObj: hwt.synthesizer.interfaceLevel.propDeclrCollector.PropDeclrCollector, updater, exclude: Optional[Tuple[Set[str], Set[str]]], prefix: str) → hwt.synthesizer.interfaceLevel.propDeclrCollector.PropDeclrCollector[source]

Update all parameters which are defined on self from otherObj

Parameters:
  • otherObj – other object which Param instances should be updated
  • updater – updater function(self, myParameter, onOtherParameterName, otherParameter)
  • exclude – tuple of set of param names for src and dst which which should be excluded
  • prefix – prefix which should be added to name of paramters of this object before matching parameter name on parent
hwt.synthesizer.interfaceLevel.propDeclrCollector.nameAvailabilityCheck(obj, propName, prop)[source]

Check if not redefining property on obj but allow to cast current property to a parameter

hwt.synthesizer.interfaceLevel.unitImplHelpers module

hwt.synthesizer.interfaceLevel.unitImplHelpers.Interface_without_registration(parent: hwt.synthesizer.interfaceLevel.mainBases.UnitBase, container: Union[hwt.synthesizer.interfaceLevel.mainBases.InterfaceBase, hwt.synthesizer.hObjList.HObjList], suggested_name: str, def_val: Union[int, None, dict, list] = None, nop_val: Union[int, None, dict, list, NOT_SPECIFIED] = <class 'hwt.synthesizer.rtlLevel.constants.NOT_SPECIFIED'>)[source]

Load all parts of interface and construct signals in RtlNetlist context with an automatic name check, without need to explicitly add the interface in _interfaces list.

class hwt.synthesizer.interfaceLevel.unitImplHelpers.UnitImplHelpers[source]

Bases: hwt.synthesizer.interfaceLevel.mainBases.UnitBase

_cleanAsSubunit()[source]

Disconnect internal signals so unit can be reused by parent unit

_reg(name: str, dtype: hwt.hdl.types.hdlType.HdlType = <Bits, 1bit>, def_val: Union[int, None, dict, list] = None, clk: Union[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, None, Tuple[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase, hwt.hdl.operatorDefs.OpDefinition]] = None, rst: Optional[hwt.synthesizer.rtlLevel.mainBases.RtlSignalBase] = None) → hwt.synthesizer.rtlLevel.rtlSyncSignal.RtlSyncSignal[source]

Create RTL FF register in this unit

Parameters:
  • def_val – s default value of this register, if this value is specified reset signal of this component is used to generate a reset logic
  • clk – optional clock signal specification, (signal or tuple(signal, edge type (AllOps.RISING_EDGE/FALLING_EDGE)))
  • rst – optional reset signal specification
Note:

rst/rst_n resolution is done from signal type, if it is negated type the reset signal is interpreted as rst_n

Note:

if clk or rst is not specified default signal from parent unit instance will be used

_sig(name: str, dtype: hwt.hdl.types.hdlType.HdlType = <Bits, 1bit>, def_val: Union[int, None, dict, list] = None, nop_val: Union[int, None, dict, list, NOT_SPECIFIED] = <class 'hwt.synthesizer.rtlLevel.constants.NOT_SPECIFIED'>) → hwt.synthesizer.rtlLevel.rtlSignal.RtlSignal[source]

Create signal in this unit

See:hwt.synthesizer.rtlLevel.netlist.RtlNetlist.sig()
_signalsForSubUnitEntity(context: hwt.synthesizer.rtlLevel.netlist.RtlNetlist, prefix: str)[source]

generate signals in this context for all ports of this subunit

hwt.synthesizer.interfaceLevel.unitImplHelpers._default_param_updater(self, myP, otherP_val)[source]
hwt.synthesizer.interfaceLevel.unitImplHelpers._instantiate_signals(intf: Union[hwt.interfaces.std.Signal, hwt.synthesizer.hObjList.HObjList, hwt.interfaces.structIntf.StructIntf], clk: hwt.interfaces.std.Clk, rst: Union[hwt.interfaces.std.Rst, hwt.interfaces.std.Rst_n], def_val, nop_val, signal_create_fn)[source]
hwt.synthesizer.interfaceLevel.unitImplHelpers._loadDeclarations(intf_or_list: Union[hwt.synthesizer.hObjList.HObjList, hwt.synthesizer.interfaceLevel.mainBases.InterfaceBase], suggested_name: str)[source]
hwt.synthesizer.interfaceLevel.unitImplHelpers._normalize_default_value_dict_for_interface_array(root_val: dict, val: Union[dict, list, None], name_prefix: str, hobj_list: hwt.synthesizer.hObjList.HObjList, neutral_value)[source]

This function is called to convert data in format .. code-block:: python

{“x”: [3, 4]} # into {“x_0”: 3, “x_1”: 4}

This is required because the items of HObjList are stored in _interfaces as a separate items and thus we can not resolve the value association otherwise.

hwt.synthesizer.interfaceLevel.unitImplHelpers.getInterfaceName(top: Unit, io: Union[hwt.synthesizer.interfaceLevel.mainBases.InterfaceBase, hwt.synthesizer.rtlLevel.rtlSignal.RtlSignal, Tuple[Union[hwt.synthesizer.interfaceLevel.mainBases.InterfaceBase, hwt.synthesizer.rtlLevel.rtlSignal.RtlSignal]]])[source]
hwt.synthesizer.interfaceLevel.unitImplHelpers.getSignalName(sig)[source]

Name getter which works for RtlSignal and Interface instances as well