<commit_before>from typing import List, Tuple, Optional, Union, Dict, Callable

from hwt.pyUtils.uniqList import UniqList
from hwtHls.allocator.time_independent_rtl_resource import TimeIndependentRtlResource, \
    TimeIndependentRtlResourceItem
from hwtHls.clk_math import epsilon
from hwtHls.hlsPipeline import HlsPipeline
from hwtHls.hlsStreamProc.ssa.basicBlock import SsaBasicBlock
from hwtHls.hlsStreamProc.ssa.branchControlLabel import BranchControlLabel
from hwtHls.hlsStreamProc.ssa.translation.toHwtHlsNetlist.syncAndIo import SsaToHwtHlsNetlistSyncAndIo
from hwtHls.netlist.nodes.io import HlsExplicitSyncNode, IO_COMB_REALIZATION
from hwtHls.netlist.nodes.ops import AbstractHlsOp
from hwtHls.netlist.nodes.ports import HlsOperationOut, link_hls_nodes, HlsOperationOutLazy
from hwtHls.netlist.utils import hls_op_not
from ipCorePackager.constants import INTF_DIRECTION
from hwtHls.hlsStreamProc.ssa.translation.toHwtHlsNetlist.opCache import SsaToHwtHlsNetlistOpCache


class HlsLoopGateStatus(AbstractHlsOp):

    def __init__(self, parentHls:"HlsPipeline", loop_gate: "HlsLoopGate", name:str=None):
        AbstractHlsOp.__init__(self, parentHls, name=name)
        self._loop_gate = loop_gate
        self._add_output()

    def resolve_realization(self):
        self.assignRealization(IO_COMB_REALIZATION)

    def allocate_instance(self,
                          allocator: "HlsAllocator",
                          used_signals: UniqList[TimeIndependentRtlResourceItem]
                          ) -> TimeIndependentRtlResource:
        op_out = self._outputs[0]

        try:
            return allocator.node2instance[op_out]
        except KeyError:
            pass

        name = self.name
        status_reg = allocator._reg(name if name else "loop_gate_status", def_val=0)<commit_msg>add todo for HlsLoopGateStatus missing impl<commit_after>from typing import List, Tuple, Optional, Union, Dict, Callable

from hwt.pyUtils.uniqList import UniqList
from hwtHls.allocator.time_independent_rtl_resource import TimeIndependentRtlResource, \
    TimeIndependentRtlResourceItem
from hwtHls.clk_math import epsilon
from hwtHls.hlsPipeline import HlsPipeline
from hwtHls.hlsStreamProc.ssa.basicBlock import SsaBasicBlock
from hwtHls.hlsStreamProc.ssa.branchControlLabel import BranchControlLabel
from hwtHls.hlsStreamProc.ssa.translation.toHwtHlsNetlist.syncAndIo import SsaToHwtHlsNetlistSyncAndIo
from hwtHls.netlist.nodes.io import HlsExplicitSyncNode, IO_COMB_REALIZATION
from hwtHls.netlist.nodes.ops import AbstractHlsOp
from hwtHls.netlist.nodes.ports import HlsOperationOut, link_hls_nodes, HlsOperationOutLazy
from hwtHls.netlist.utils import hls_op_not
from ipCorePackager.constants import INTF_DIRECTION
from hwtHls.hlsStreamProc.ssa.translation.toHwtHlsNetlist.opCache import SsaToHwtHlsNetlistOpCache


class HlsLoopGateStatus(AbstractHlsOp):

    def __init__(self, parentHls:"HlsPipeline", loop_gate: "HlsLoopGate", name:str=None):
        AbstractHlsOp.__init__(self, parentHls, name=name)
        self._loop_gate = loop_gate
        self._add_output()

    def resolve_realization(self):
        self.assignRealization(IO_COMB_REALIZATION)

    def allocate_instance(self,
                          allocator: "HlsAllocator",
                          used_signals: UniqList[TimeIndependentRtlResourceItem]
                          ) -> TimeIndependentRtlResource:
        op_out = self._outputs[0]

        try:
            return allocator.node2instance[op_out]
        except KeyError:
            pass

        name = self.name
        status_reg = allocator._reg(name if name else "loop_gate_status", def_val=0)
        # [todo] set this register based on how data flows on control channels
        # (breaks returns token, predec takes token)

{'fraction_non_alphanumeric': 0.061526274095590174, 'fraction_numerical': 0.0015843675732770002, 'mean_word_length': 4.0439414114513985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1465306', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1201, 'n_words': 234}