Source code for hwt.interfaces.utils

from hwt.interfaces.std import Clk, Rst_n, Rst


[docs]def addClkRstn(obj): """ Construct clk, rst_n signal on object (usually Unit/Interface instance) """ obj.clk = Clk() obj.rst_n = Rst_n()
[docs]def addClkRst(obj): """ Construct clk, rst signal on object (usually Unit/Interface instance) """ obj.clk = Clk() obj.rst = Rst()
[docs]def _tryConnect(src, unit, intfName): """ Try connect src to interface of specified name on unit. Ignore if interface is not present or if it already has driver. """ try: dst = getattr(unit, intfName) except AttributeError: return if not dst._sig.drivers: dst(src)
[docs]def propagateClk(obj): """ Propagate "clk" clock signal to all subcomponents """ clk = obj.clk for u in obj._units: _tryConnect(clk, u, 'clk')
[docs]def propagateClkRstn(obj): """ Propagate "clk" clock and negative reset "rst_n" signal to all subcomponents """ clk = obj.clk rst_n = obj.rst_n for u in obj._units: _tryConnect(clk, u, 'clk') _tryConnect(rst_n, u, 'rst_n') _tryConnect(~rst_n, u, 'rst')
[docs]def propagateClkRst(obj): """ Propagate "clk" clock and reset "rst" signal to all subcomponents """ clk = obj.clk rst = obj.rst for u in obj._units: _tryConnect(clk, u, 'clk') _tryConnect(~rst, u, 'rst_n') _tryConnect(rst, u, 'rst')
[docs]def propagateRstn(obj): """ Propagate negative reset "rst_n" signal to all subcomponents """ rst_n = obj.rst_n for u in obj._units: _tryConnect(rst_n, u, 'rst_n') _tryConnect(~rst_n, u, 'rst')
[docs]def propagateRst(obj): """ Propagate reset "rst" signal to all subcomponents """ rst = obj.rst for u in obj._units: _tryConnect(~rst, u, 'rst_n') _tryConnect(rst, u, 'rst')