<commit_before># SiLab , Physics Institute of Bonn University
# ------------------------------------------------------------
#
# SVN revision information:
#  $Rev::                       $:
#  $Author::                    $:
#  $Date::                      $:
#

from basil.HL.RegisterHardwareLayer import RegisterHardwareLayer
from struct import pack, unpack_from
from array import array
from time import sleep
import numpy as np


class sram_fifo(RegisterHardwareLayer):
    '''SRAM FIFO controller interface for sram_fifo FPGA module.
    '''

    _registers = {'RESET': {'descr': {'addr': 0, 'size': 8, 'properties': ['writeonly']}},
                  'VERSION': {'descr': {'addr': 0, 'size': 8, 'properties': ['ro']}},
                  'ALMOST_FULL_THRESHOLD': {'descr': {'addr': 1, 'size': 8}},
                  'ALMOST_EMPTY_THRESHOLD': {'descr': {'addr': 2, 'size': 8}},
                  'READ_ERROR_COUNTER': {'descr': {'addr': 3, 'size': 8, 'properties': ['ro']}},
                  'FIFO_SIZE': {'descr': {'addr': 4, 'size': 32, 'properties': ['ro']}}
    }

    def __init__(self, intf, conf):
        super(sram_fifo, self).__init__(intf, conf)

#    def init(self):
#        self.reset()

    def reset(self):
        self._intf.write(self._conf['base_addr'], (0,))
        sleep(0.01)  # wait some time for initialization

    def set_almost_full_threshold(self, value):
        self._intf.write(self._conf['base_addr'] + 1, array('B', pack('B', value)))  # no get function possible

    def set_almost_empty_threshold(self, value):
        self._intf.write(self._conf['base_addr'] + 2, array('B', pack('B', value)))  # no get function possible

    def get_fifo_size(self):
        '''
        Get FIFO size in units of bytes (8 bit).

        Returns
        -------
        fifo_size : int
            FIFO size in units of bytes (8 bit).
        '''
        ret = self._intf.read(self._conf['base_addr'] + 1, size=3)
        ret.append(0)  # increase to 4 bytes to do the conversion
        return unpack_from('I', ret)[0]

    @property
    def FIFO_INT_SIZE(self):
        '''
        Get FIFO size in units of integers (32 bit).<commit_msg>BUG: Return proposer size<commit_after># SiLab , Physics Institute of Bonn University
# ------------------------------------------------------------
#
# SVN revision information:
#  $Rev::                       $:
#  $Author::                    $:
#  $Date::                      $:
#

from basil.HL.RegisterHardwareLayer import RegisterHardwareLayer
from struct import pack, unpack_from
from array import array
from time import sleep
import numpy as np


class sram_fifo(RegisterHardwareLayer):
    '''SRAM FIFO controller interface for sram_fifo FPGA module.
    '''

    _registers = {'RESET': {'descr': {'addr': 0, 'size': 8, 'properties': ['writeonly']}},
                  'VERSION': {'descr': {'addr': 0, 'size': 8, 'properties': ['ro']}},
                  'ALMOST_FULL_THRESHOLD': {'descr': {'addr': 1, 'size': 8}},
                  'ALMOST_EMPTY_THRESHOLD': {'descr': {'addr': 2, 'size': 8}},
                  'READ_ERROR_COUNTER': {'descr': {'addr': 3, 'size': 8, 'properties': ['ro']}},
                  'FIFO_SIZE': {'descr': {'addr': 4, 'size': 32, 'properties': ['ro']}}
    }

    def __init__(self, intf, conf):
        super(sram_fifo, self).__init__(intf, conf)

#    def init(self):
#        self.reset()

    def reset(self):
        self._intf.write(self._conf['base_addr'], (0,))
        sleep(0.01)  # wait some time for initialization

    def set_almost_full_threshold(self, value):
        self._intf.write(self._conf['base_addr'] + 1, array('B', pack('B', value)))  # no get function possible

    def set_almost_empty_threshold(self, value):
        self._intf.write(self._conf['base_addr'] + 2, array('B', pack('B', value)))  # no get function possible

    def get_fifo_size(self):
        '''
        Get FIFO size in units of bytes (8 bit).

        Returns
        -------
        fifo_size : int
            FIFO size in units of bytes (8 bit).
        '''
        return self.FIFO_SIZE

    @property
    def FIFO_INT_SIZE(self):
        '''
        Get FIFO size in units of integers (32 bit).
{'fraction_non_alphanumeric': 0.1814717789949988, 'fraction_numerical': 0.012145748987854251, 'mean_word_length': 2.233256351039261, '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': '4409329', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1254, 'n_words': 354}