<commit_before>from typing import Union, List

from hwt.hdl.value import HValue
from hwt.synthesizer.interface import Interface
from hwt.synthesizer.interfaceLevel.unitImplHelpers import getSignalName
from hwt.synthesizer.rtlLevel.rtlSignal import RtlSignal
from hwtHls.clk_math import start_clk, end_clk, epsilon
from hwt.synthesizer.rtlLevel.rtlSyncSignal import RtlSyncSignal


class TimeIndependentRtlResourceItem():

    def __init__(self, parent:"TimeIndependentRtlResource", data:Interface):
        self.parent = parent
        self.data = data

    def is_rlt_register(self) -> bool:
        return (self.parent.valuesInTime[0] is not self or
                isinstance(self.parent.valuesInTime[0].data, RtlSyncSignal))

    def __repr__(self):
        return f"<{self.__class__.__name__:s} {self.data}>"


class TimeIndependentRtlResource():
    """
    Container of resource which manages access to resource
    in different times

    (dynamically generates register chains and synchronization
     to pass values to specified clk periods)
    """
    INVARIANT_TIME = "INVARIANT_TIME"
    # time constant, which means that item is not time dependent
    # and can be accessed any time

    def __init__(self, data: Union[RtlSignal, Interface, HValue],
                 time: Union[int, "TimeIndependentRtlResource.INVARIANT_TIME"],
                 hlsAllocator: "HlsAllocator"):
        """
        :param data: signal with value in initial time
        :param time: number of clock form start when valid data appears on "signal"
            (constant INVARIANT_TIME is used if input signal is constant
             and does not require any registers and synchronizations)
        :param hlsAllocator: HlsAllocator instance to generate registers an synchronization logic

        :ivar valuesInTime: list (chain) of signals (register outputs) for clk periods specified by index
        """
        self.timeOffset = time
        self.allocator = hlsAllocator
        self.valuesInTime: List[TimeIndependentRtlResourceItem] = [
            TimeIndependentRtlResourceItem(self, data),
        ]<commit_msg>TimeIndependentRtlResourceItem: use __slots__<commit_after>from typing import Union, List

from hwt.hdl.value import HValue
from hwt.synthesizer.interface import Interface
from hwt.synthesizer.interfaceLevel.unitImplHelpers import getSignalName
from hwt.synthesizer.rtlLevel.rtlSignal import RtlSignal
from hwtHls.clk_math import start_clk, end_clk, epsilon
from hwt.synthesizer.rtlLevel.rtlSyncSignal import RtlSyncSignal


class TimeIndependentRtlResourceItem():
    __slots__ = ["parent", "data"]

    def __init__(self, parent:"TimeIndependentRtlResource", data:Interface):
        self.parent = parent
        self.data = data

    def is_rlt_register(self) -> bool:
        return (self.parent.valuesInTime[0] is not self or
                isinstance(self.parent.valuesInTime[0].data, RtlSyncSignal))

    def __repr__(self):
        return f"<{self.__class__.__name__:s} {self.data}>"


class TimeIndependentRtlResource():
    """
    Container of resource which manages access to resource
    in different times

    (dynamically generates register chains and synchronization
     to pass values to specified clk periods)
    """
    INVARIANT_TIME = "INVARIANT_TIME"
    # time constant, which means that item is not time dependent
    # and can be accessed any time
    __slots__ = ["timeOffset", "allocator", "valuesInTime"]

    def __init__(self, data: Union[RtlSignal, Interface, HValue],
                 time: Union[int, "TimeIndependentRtlResource.INVARIANT_TIME"],
                 hlsAllocator: "HlsAllocator"):
        """
        :param data: signal with value in initial time
        :param time: number of clock form start when valid data appears on "signal"
            (constant INVARIANT_TIME is used if input signal is constant
             and does not require any registers and synchronizations)
        :param hlsAllocator: HlsAllocator instance to generate registers an synchronization logic

        :ivar valuesInTime: list (chain) of signals (register outputs) for clk periods specified by index
        """
        self.timeOffset = time
        self.allocator = hlsAllocator
        self.valuesInTime: List[TimeIndependentRtlResourceItem] = [
            TimeIndependentRtlResourceItem(self, data),
        ]
{'fraction_non_alphanumeric': 0.07105202842081138, 'fraction_numerical': 0.0009168003667201467, 'mean_word_length': 3.3815261044176705, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1783588', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1180, 'n_words': 373}