<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from hwt.interfaces.std import RegCntrl
from hwt.interfaces.utils import addClkRstn, propagateClkRstn
from hwt.synthesizer.interfaceLevel.unit import Unit
from hwt.synthesizer.param import Param
from hwtLib.ipif.intf import IPIF
from hwtLib.ipif.structEndpoint import IpifStructEndpoint
from hwtLib.ipif.structEndpoint_test import IPIFStructEndpointTC


class IpifRegWithEndpoint(Unit):
    def __init__(self, STRUCT_TEMPLATE):
        super(IpifRegWithEndpoint, self).__init__()
        self.STRUCT_TEMPLATE = STRUCT_TEMPLATE

    def _config(self):
        self.DATA_WIDTH = Param(32)

    def _declr(self):
        addClkRstn(self)
        with self._paramsShared():
            self.bus = IPIF()
            self.ep = IpifStructEndpoint(self.STRUCT_TEMPLATE)
            self.field0 = RegCntrl()
            self.field1 = RegCntrl()
            
    def _impl(self):
        propagateClkRstn(self)
        ep = self.ep
        ep.bus ** self.bus
        self.field0 ** ep.field0
        self.field1 ** ep.field1
        

class IpifRegTC(IPIFStructEndpointTC):
    FIELD_ADDR = [0x0, 0x4]

    def mySetUp(self, data_width=32):<commit_msg>instantiate IpifReg in IpifRegWithEndpoint to test it<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from hwt.interfaces.std import RegCntrl
from hwt.interfaces.utils import addClkRstn, propagateClkRstn
from hwt.synthesizer.interfaceLevel.unit import Unit
from hwt.synthesizer.param import Param
from hwtLib.ipif.intf import IPIF
from hwtLib.ipif.structEndpoint import IpifStructEndpoint
from hwtLib.ipif.structEndpoint_test import IPIFStructEndpointTC
from hwtLib.ipif.reg import IpifReg


class IpifRegWithEndpoint(Unit):
    def __init__(self, STRUCT_TEMPLATE):
        super(IpifRegWithEndpoint, self).__init__()
        self.STRUCT_TEMPLATE = STRUCT_TEMPLATE

    def _config(self):
        self.DATA_WIDTH = Param(32)

    def _declr(self):
        addClkRstn(self)
        with self._paramsShared():
            self.bus = IPIF()
            self.reg = IpifReg()
            self.ep = IpifStructEndpoint(self.STRUCT_TEMPLATE)
            self.field0 = RegCntrl()
            self.field1 = RegCntrl()
            
    def _impl(self):
        propagateClkRstn(self)
        ep = self.ep
        self.reg.dataIn ** self.bus
        ep.bus ** self.reg.dataOut
        self.field0 ** ep.field0
        self.field1 ** ep.field1
        

class IpifRegTC(IPIFStructEndpointTC):
    FIELD_ADDR = [0x0, 0x4]

    def mySetUp(self, data_width=32):
{'fraction_non_alphanumeric': 0.09200779727095516, 'fraction_numerical': 0.012475633528265107, 'mean_word_length': 2.8528528528528527, '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': '3358916', 'n_tokens_mistral': 908, 'n_tokens_neox': 882, 'n_words': 169}