<commit_before>from hwt.interfaces.utils import propagateClkRstn
from hwt.synthesizer.unit import Unit
from hwtLib.abstract.busEndpoint import BusEndpoint
from hwtLib.amba.axi4Lite import Axi4Lite
from hwtLib.amba.axiLite_comp.endpoint import AxiLiteEndpoint
from hwtLib.amba.axiLite_comp.endpoint_test import AxiLiteEndpointTC
from hwtLib.amba.axiLite_comp.reg import AxiLiteReg


class AxiLiteEpWithReg(Unit):
    """
    Unit with AxiLiteEndpoint and AxiLiteReg together
    """

    def __init__(self, structTemplate, intfCls=Axi4Lite, shouldEnterFn=None):
        BusEndpoint.__init__(self, structTemplate,
                             intfCls=intfCls,
                             shouldEnterFn=shouldEnterFn)

    def _config(self):
        BusEndpoint._config(self)

    def _mkFieldInterface(self, structIntf, field):
        return BusEndpoint._mkFieldInterface(self, structIntf, field)

    @staticmethod
    def _defaultShouldEnterFn(field):
        return BusEndpoint._defaultShouldEnterFn(field)

    def _declr(self):
        BusEndpoint._declr(self)
        with self._paramsShared():
            self.ep = AxiLiteEndpoint(self.STRUCT_TEMPLATE)
            self.reg = AxiLiteReg(self._intfCls)

    def _impl(self):
        propagateClkRstn(self)
        self.decoded(self.ep.decoded)
        self.reg.in_s(self.bus)
        self.ep.bus(self.reg.out_m)


class AxiRegTC(AxiLiteEndpointTC):
    def mySetUp(self, data_width=32):
        u = self.u = AxiLiteEpWithReg(self.STRUCT_TEMPLATE)

        self.DATA_WIDTH = data_width
        u.DATA_WIDTH = self.DATA_WIDTH

        self.compileSimAndStart(self.u, onAfterToRtl=self.mkRegisterMap)
        return u


if __name__ == "__main__":
    import unittest
    suite = unittest.TestSuite()
    # suite.addTest(Axi4_wDatapumpTC('test_singleLong'))
    suite.addTest(unittest.makeSuite(AxiRegTC))
    runner = unittest.TextTestRunner(verbosity=3)
    runner.run(suite)<commit_msg>update AxiLiteBuff tests<commit_after>from hwt.interfaces.utils import propagateClkRstn
from hwt.synthesizer.unit import Unit
from hwtLib.abstract.busEndpoint import BusEndpoint
from hwtLib.amba.axi4Lite import Axi4Lite
from hwtLib.amba.axiLite_comp.endpoint import AxiLiteEndpoint
from hwtLib.amba.axiLite_comp.endpoint_test import AxiLiteEndpointTC
from hwtLib.amba.axi_comp.builder import AxiBuilder


class AxiLiteEpWithReg(Unit):
    """
    Unit with AxiLiteEndpoint and AxiLiteReg together
    """

    def __init__(self, structTemplate, intfCls=Axi4Lite, shouldEnterFn=None):
        BusEndpoint.__init__(self, structTemplate,
                             intfCls=intfCls,
                             shouldEnterFn=shouldEnterFn)

    def _config(self):
        BusEndpoint._config(self)

    def _mkFieldInterface(self, structIntf, field):
        return BusEndpoint._mkFieldInterface(self, structIntf, field)

    @staticmethod
    def _defaultShouldEnterFn(field):
        return BusEndpoint._defaultShouldEnterFn(field)

    def _declr(self):
        BusEndpoint._declr(self)
        with self._paramsShared():
            self.ep = AxiLiteEndpoint(self.STRUCT_TEMPLATE)

    def _impl(self):
        propagateClkRstn(self)
        self.decoded(self.ep.decoded)
        m = AxiBuilder(self, self.bus).buff(addr_items=1, data_items=1).end
        self.ep.bus(m)


class AxiRegTC(AxiLiteEndpointTC):
    def mySetUp(self, data_width=32):
        u = self.u = AxiLiteEpWithReg(self.STRUCT_TEMPLATE)

        self.DATA_WIDTH = data_width
        u.DATA_WIDTH = self.DATA_WIDTH

        self.compileSimAndStart(self.u, onAfterToRtl=self.mkRegisterMap)
        return u


if __name__ == "__main__":
    import unittest
    suite = unittest.TestSuite()
    # suite.addTest(Axi4_wDatapumpTC('test_singleLong'))
    suite.addTest(unittest.makeSuite(AxiRegTC))
    runner = unittest.TextTestRunner(verbosity=3)
    runner.run(suite)
{'fraction_non_alphanumeric': 0.08563322156306423, 'fraction_numerical': 0.0041269022440030955, 'mean_word_length': 3.3671171171171173, 'pattern_counts': {'":': 2, '<': 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': '7643524', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1278, 'n_words': 210}