<commit_before>from inspect import isgenerator

from hwt.code import connect
from hwtLib.amba.axi4_rDatapump import Axi_rDatapump
from hwtLib.amba.axi4_wDatapump import Axi_wDatapump
from hwtLib.amba.interconnect.rStricOrder import RStrictOrderInterconnect
from hwtLib.amba.interconnect.wStrictOrder import WStrictOrderInterconnect


def connectDp(parent, controller, datapump, axi):
    """
    Connect datapump with it's controller(s) and axi

    :param controller: (controller compatible with Axi_wDatapump or Axi_rDatapump)
                        or list/tuple/generator of them

    :param datapump: Axi_wDatapump or Axi_rDatapump

    :param axi: axi(3/4) interface which datapump should use
    """
    if isgenerator(controller):
        controller = list(controller)

    if isinstance(controller, (list, tuple)) and len(controller) == 1:
        controller = controller[0]

    if isinstance(datapump, Axi_rDatapump):
        axi.ar(datapump.a)
        datapump.r(axi.r)

        if isinstance(controller, (list, tuple)):
            interconnect = RStrictOrderInterconnect()
            # @for cntrl, reqIn in zip(controller, req_join.dataIn):
            # @    reqIn(HsBuilder(parent, cntrl.rDatapump.req).reg().end)

            # datapump.driver.req(req_join.dataOut)
        else:
            datapump.driver(controller.rDatapump)
            return

    elif isinstance(datapump, Axi_wDatapump):
        axi.aw(datapump.a)
        # axi3/4 connection
        if not hasattr(axi.w, "id") and hasattr(datapump.w, "id"):
            exclude = [datapump.w.id]
        else:
            exclude = []
        connect(datapump.w, axi.w, exclude=exclude)
        datapump.b(axi.b)

        if isinstance(controller, (list, tuple)):
            interconnect = WStrictOrderInterconnect()
        else:
            datapump.driver(controller.wDatapump)
            return

    else:
        raise TypeError("Unsupported datapump type %r" % (datapump.__class__))

    interconnect.configureFromDrivers(controller, datapump, byInterfaces=True)
    setattr(parent, datapump._name + "_interconnect", interconnect)<commit_msg>connectDp add exclude to params<commit_after>from inspect import isgenerator

from hwt.code import connect
from hwtLib.amba.axi4_rDatapump import Axi_rDatapump
from hwtLib.amba.axi4_wDatapump import Axi_wDatapump
from hwtLib.amba.interconnect.rStricOrder import RStrictOrderInterconnect
from hwtLib.amba.interconnect.wStrictOrder import WStrictOrderInterconnect


def connectDp(parent, controller, datapump, axi, exclude=None):
    """
    Connect datapump with it's controller(s) and axi

    :param controller: (controller compatible with Axi_wDatapump or Axi_rDatapump)
                        or list/tuple/generator of them

    :param datapump: Axi_wDatapump or Axi_rDatapump

    :param axi: axi(3/4) interface which datapump should use
    """
    if isgenerator(controller):
        controller = list(controller)

    if isinstance(controller, (list, tuple)) and len(controller) == 1:
        controller = controller[0]

    if isinstance(datapump, Axi_rDatapump):
        connect(datapump.a, axi.ar, exclude=exclude)
        datapump.r(axi.r)

        if isinstance(controller, (list, tuple)):
            interconnect = RStrictOrderInterconnect()
            # @for cntrl, reqIn in zip(controller, req_join.dataIn):
            # @    reqIn(HsBuilder(parent, cntrl.rDatapump.req).reg().end)

            # datapump.driver.req(req_join.dataOut)
        else:
            datapump.driver(controller.rDatapump)
            return

    elif isinstance(datapump, Axi_wDatapump):
        connect(datapump.a, axi.aw, exclude=exclude)
        # axi3/4 connection
        if not hasattr(axi.w, "id") and hasattr(datapump.w, "id"):
            exclude_ = [datapump.w.id]
        else:
            exclude_ = []
        if exclude:
            exclude_.extend(exclude)

        connect(datapump.w, axi.w, exclude=exclude_)
        datapump.b(axi.b)

        if isinstance(controller, (list, tuple)):
            interconnect = WStrictOrderInterconnect()
        else:
            datapump.driver(controller.wDatapump)
            return

    else:
        raise TypeError("Unsupported datapump type %r" % (datapump.__class__))

    interconnect.configureFromDrivers(controller, datapump, byInterfaces=True)
    setattr(parent, datapump._name + "_interconnect", interconnect)
{'fraction_non_alphanumeric': 0.09266409266409266, 'fraction_numerical': 0.0036338859868271633, 'mean_word_length': 2.907719609582964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4718395', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1370, 'n_words': 293}