Ejemplo n.º 1
0
 def __init__(self, waitstartcycles=0, *args, **kwargs):
     '''
     Constructor is overloaded only to ensure the correct
     parameters are used such that the Bus is configured properly.
     '''
     self.__waitstartcycles = waitstartcycles
     BusMonitor.__init__(self, name="", bus_separator="", *args, **kwargs)
Ejemplo n.º 2
0
    def __init__(self,
                 entity,
                 name,
                 clock,
                 lsb_first=True,
                 tuser_bytewise=False,
                 **kwargs):
        self._init_done = Event(
            "Init Done"
        )  # workaround for scheduler immediately running newly added coroutines
        BusMonitor.__init__(self, entity, name, clock, **kwargs)

        if hasattr(self.bus, 'tdata'):
            self._n_bytes, rem = divmod(len(self.bus.tdata), 8)
            if rem:
                raise AttributeError("tdata width has to be multiple of 8")
        else:
            self._n_bytes = 1

        if hasattr(self.bus, 'tuser'):
            self._tuser_bytewise = tuser_bytewise
            if tuser_bytewise and self._n_bytes:
                self._user_bits, rem = divmod(len(self.bus.tuser),
                                              self._n_bytes)
                if rem:
                    raise AttributeError(
                        "in byte-wise mode tuser width has to be multiple of tdata width"
                    )
            else:
                self._user_bits = len(self.bus.tuser)

        self._lsb_first = lsb_first
        self._init_done.set()
Ejemplo n.º 3
0
Archivo: monitor.py Proyecto: grgbr/rtl
    def __init__(self, entity, clock, scoreboard):
        BusMonitor.__init__(self, entity, "", clock)

        self._expected = None
        self._log = getLogger(scoreboard.log.name + '.' + self.name)
        self._scoreboard = scoreboard
        scoreboard.add_interface(self, [], compare_fn=self.compare)
Ejemplo n.º 4
0
 def __init__(self, entity, name, clock, callback=None, reset_n=None):
     BusMonitor.__init__(self,
                         entity,
                         name,
                         clock,
                         callback=callback,
                         event=None,
                         reset_n=None)
Ejemplo n.º 5
0
    def __init__(self, entity, name, clock, *, config={}, **kwargs):
        BusMonitor.__init__(self, entity, name, clock, **kwargs)

        self.config = self._default_config.copy()

        for configoption, value in config.items():
            self.config[configoption] = value
            self.log.debug("Setting config option %s to %s", configoption, str(value))
Ejemplo n.º 6
0
 def __init__(self, *args, **kwargs):
     BusMonitor.__init__(self, *args, **kwargs)
     # Drive some sensible defaults (setimmediatevalue to avoid x asserts)
     self.bus.ack.setimmediatevalue(0)
     self.bus.datrd.setimmediatevalue(0)
     if hasattr(self.bus, "err"):
         self.bus.err.setimmediatevalue(0)
     if hasattr(self.bus, "stall"):
         self.bus.stall.setimmediatevalue(0)
Ejemplo n.º 7
0
    def __init__(self, *args, **kwargs):
        config = kwargs.pop('config', {})
        BusMonitor.__init__(self, *args, **kwargs)

        self.config = AvalonSTPkts._default_config.copy()

        for configoption, value in config.items():
            self.config[configoption] = value
            self.log.debug("Setting config option %s to %s" % (configoption, str(value)))
Ejemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        config = kwargs.pop('config', {})
        BusMonitor.__init__(self, *args, **kwargs)

        self.config = self._default_config.copy()

        for configoption, value in config.items():
            self.config[configoption] = value
            self.log.debug("Setting config option %s to %s", configoption, str(value))
Ejemplo n.º 9
0
 def __init__(self, dut, callback=None, event=None):
     BusMonitor.__init__(self,
                         dut,
                         None,
                         dut.Clock,
                         dut.Reset,
                         callback=callback,
                         event=event)
     self.name = "out"
Ejemplo n.º 10
0
 def __init__(self, entity, name, clock):
     BusDriver.__init__(self, entity, name, clock)
     BusMonitor.__init__(self, entity, name, clock)
     self.clock = clock
     self.bus.PWRITE.setimmediatevalue(0)
     self.bus.PSELx.setimmediatevalue(0)
     self.bus.PENABLE.setimmediatevalue(0)
     self.bus.PADDR.setimmediatevalue(0)
     self.bus.PWDATA.setimmediatevalue(0)
Ejemplo n.º 11
0
    def __init__(self,
                 entity,
                 name,
                 clock,
                 registers,
                 signals=None,
                 pkg=False,
                 random_ready_probability=0,
                 random_error_probability=0,
                 **kwargs):

        # has the signals been explicitely defined?
        if signals:
            self._signals = signals

        else:

            # a SystemVerilog package is used
            if pkg:
                self._signals = {}
                for signal_name in [
                        'psel', 'pwrite', 'penable', 'paddr', 'pwdata', 'pstrb'
                ]:
                    self._signals[
                        signal_name.upper()] = name + '_h2d.' + signal_name

                for signal_name in ['prdata', 'pready', 'pslverr']:
                    self._signals[
                        signal_name.upper()] = name + '_d2h.' + signal_name
                name = None

            # just use the default APB names
            else:
                self._signals = [
                    "PSEL", "PWRITE", "PENABLE", "PADDR", "PWDATA", "PRDATA",
                    "PREADY"
                ]

                self._optional_signals = ["PSLVERR", "PSTRB"]

        BusMonitor.__init__(self, entity, name, clock, **kwargs)
        self.clock = clock

        # initialise all outputs to zero
        self.bus.PRDATA.setimmediatevalue(0)
        self.bus.PREADY.setimmediatevalue(0)
        self.bus.PSLVERR.setimmediatevalue(0)

        # store the default registers value
        self.registers_init = registers

        # setting for the probability of PREADY delay
        self.random_ready_probability = random_ready_probability
        self.random_error_probability = random_error_probability

        self.reset()
Ejemplo n.º 12
0
 def __init__(self, dut, tb, callback=None, event=None):
     """tb must be an instance of the Testbench class."""
     BusMonitor.__init__(self,
                         dut,
                         None,
                         dut.Clock,
                         dut.Reset,
                         callback=callback,
                         event=event)
     self.name = "out"
     self.tb = tb
Ejemplo n.º 13
0
 def __init__(self,
              entity,
              name,
              clock,
              baud_rate,
              reset=None,
              reset_n=None,
              callback=None,
              event=None,
              bus_seperator="_"):
     BusMonitor.__init__(self, entity, name, clock, reset, reset_n,
                         callback, event, bus_seperator)
     self.baud_rate = baud_rate
     self.receiving = False
Ejemplo n.º 14
0
 def __init__(self, entity, name, clock, signals_dict=None, **kwargs):
     if signals_dict is not None:
         self._signals=signals_dict
     self._width = kwargs.pop('width', 32)
     BusMonitor.__init__(self, entity, name, clock, **kwargs)
     # Drive some sensible defaults (setimmediatevalue to avoid x asserts)
     self.bus.ack.setimmediatevalue(0)
     self.bus.datrd.setimmediatevalue(0)
     if hasattr(self.bus, "err"):        
         self.bus.err.setimmediatevalue(0)
     if hasattr(self.bus, "stall"): 
         self.bus.stall.setimmediatevalue(0)
     if hasattr(self.bus, "rty"):        
         self.bus.rty.setimmediatevalue(0)    
Ejemplo n.º 15
0
    def __init__(self,
                 entity,
                 name,
                 clock,
                 *,
                 config={},
                 report_channel=False,
                 **kwargs):
        BusMonitor.__init__(self, entity, name, clock, **kwargs)

        self.config = self._default_config.copy()
        self.report_channel = report_channel

        # Set default config maxChannel to max value on channel bus
        if hasattr(self.bus, 'channel'):
            self.config['maxChannel'] = (2**len(self.bus.channel)) - 1
        else:
            if report_channel:
                raise ValueError(
                    "Channel reporting asked on bus without channel signal")

        for configoption, value in config.items():
            self.config[configoption] = value
            self.log.debug("Setting config option %s to %s", configoption,
                           str(value))

        num_data_symbols = (len(self.bus.data) /
                            self.config["dataBitsPerSymbol"])
        if (num_data_symbols > 1 and not hasattr(self.bus, 'empty')):
            raise AttributeError(
                "%s has %i data symbols, but contains no object named empty" %
                (self.name, num_data_symbols))

        self.config["useEmpty"] = (num_data_symbols > 1)

        if hasattr(self.bus, 'channel'):
            if len(self.bus.channel) > 128:
                raise AttributeError(
                    "AvalonST interface specification defines channel width as 1-128. "
                    "%d channel width is %d" %
                    (self.name, len(self.bus.channel)))
            maxChannel = (2**len(self.bus.channel)) - 1
            if self.config['maxChannel'] > maxChannel:
                raise AttributeError(
                    "%s has maxChannel=%d, but can only support a maximum channel of "
                    "(2**channel_width)-1=%d, channel_width=%d" %
                    (self.name, self.config['maxChannel'], maxChannel,
                     len(self.bus.channel)))
Ejemplo n.º 16
0
    def __init__(self, wrrddriver, waitstartcycles=0, *args, **kwargs):
        '''
        Takes a WrRdDriver as an inputer so that its read
        method can be utilized. 

        waitstartcycles can be used to have the monitor wait the specified
        amount of the clock cycles before it starts blocking on reset.
        '''
        self.__driver = wrrddriver
        self.__waitstartcycles = waitstartcycles
        BusMonitor.__init__(self,
                            entity=wrrddriver.entity,
                            clock=wrrddriver.clock,
                            name="",
                            bus_separator="",
                            *args,
                            **kwargs)
Ejemplo n.º 17
0
    def __init__(self, entity, scoreboard):
        # declare signals to be monitored
        self._signals = [
            "awvalid", "awaddr", "awready", "wvalid", "wready", "wdata",
            "wstrb", "bvalid", "bready", "bresp", "arvalid", "araddr",
            "arready", "rvalid", "rready", "rresp", "rdata", "stor0_a",
            "stor1_a", "stor2_a"
        ]
        BusMonitor.__init__(self,
                            entity,
                            "",
                            entity.aclk,
                            reset_n=entity.areset_n)

        self._expected = None
        self._log = logging.getLogger(scoreboard.log.name + '.' + self.name)
        self._scoreboard = scoreboard
        scoreboard.add_interface(self, [], compare_fn=self.compare)
Ejemplo n.º 18
0
    def __init__(self,
                 entity,
                 name,
                 clock,
                 pkg=False,
                 signals=None,
                 bus_width=32,
                 **kwargs):

        # has the signals been explicitely defined?
        if signals:
            self._signals = signals

        else:

            # a SystemVerilog package is used
            if pkg:
                self._signals = {}
                for signal_name in [
                        'psel', 'pwrite', 'penable', 'paddr', 'pwdata', 'pstrb'
                ]:
                    self._signals[
                        signal_name.upper()] = name + '_h2d_i.' + signal_name

                for signal_name in ['prdata', 'pready', 'pslverr']:
                    self._signals[
                        signal_name.upper()] = name + '_d2h_o.' + signal_name
                name = None

            # just use the default APB names
            else:
                self._signals = [
                    "PSEL", "PWRITE", "PENABLE", "PADDR", "PWDATA", "PRDATA",
                    "PREADY"
                ]

                self._optional_signals = ["PSLVERR", "PSTRB"]

        BusMonitor.__init__(self, entity, name, clock, **kwargs)
        self.clock = clock
        self.bus_width = bus_width

        # prime the monitor to begin
        self.reset()
Ejemplo n.º 19
0
    def __init__(self, *args, **kwargs):
        config = kwargs.pop('config', {})
        BusMonitor.__init__(self, *args, **kwargs)

        self.config = self._default_config.copy()

        for configoption, value in config.items():
            self.config[configoption] = value
            self.log.debug("Setting config option %s to %s" %
                           (configoption, str(value)))

        num_data_symbols = (len(self.bus.data) /
                            self.config["dataBitsPerSymbol"])
        if (num_data_symbols > 1 and not hasattr(self.bus, 'empty')):
            raise AttributeError(
                "%s has %i data symbols, but contains no object named empty" %
                (self.name, num_data_symbols))

        self.config["useEmpty"] = (num_data_symbols > 1)
Ejemplo n.º 20
0
    def __init__(self, *args, **kwargs):
        config = kwargs.pop('config', {})
        BusMonitor.__init__(self, *args, **kwargs)

        self.config = self._default_config.copy()

        # Set default config maxChannel to max value on channel bus
        if hasattr(self.bus, 'channel'):
            self.config['maxChannel'] = (2**len(self.bus.channel)) - 1

        for configoption, value in config.items():
            self.config[configoption] = value
            self.log.debug("Setting config option %s to %s", configoption,
                           str(value))

        num_data_symbols = (len(self.bus.data) /
                            self.config["dataBitsPerSymbol"])
        if (num_data_symbols > 1 and not hasattr(self.bus, 'empty')):
            raise AttributeError(
                "%s has %i data symbols, but contains no object named empty" %
                (self.name, num_data_symbols))

        self.config["useEmpty"] = (num_data_symbols > 1)

        if hasattr(self.bus, 'channel'):
            if "channel" in self._optional_signals:
                self.log.warning(
                    "Channel is not fully implemented in this monitor. Recommend use of AvalonSTPktsWithChannel."
                )

            if len(self.bus.channel) > 128:
                raise AttributeError(
                    "AvalonST interface specification defines channel width as 1-128. "
                    "%d channel width is %d" %
                    (self.name, len(self.bus.channel)))
            maxChannel = (2**len(self.bus.channel)) - 1
            if self.config['maxChannel'] > maxChannel:
                raise AttributeError(
                    "%s has maxChannel=%d, but can only support a maximum channel of "
                    "(2**channel_width)-1=%d, channel_width=%d" %
                    (self.name, self.config['maxChannel'], maxChannel,
                     len(self.bus.channel)))
Ejemplo n.º 21
0
 def __init__(self,
              entity,
              name,
              clock,
              baud_rate,
              trigger_transmit_state,
              reset=None,
              reset_n=None,
              callback=None,
              event=None,
              bus_seperator="_"):
     BusMonitor.__init__(self, entity, name, clock, reset, reset_n,
                         callback, event, bus_seperator)
     self.tts = trigger_transmit_state
     self.last_transaction = None
     self.baud_count = 0
     self.baud_rate = baud_rate
     self.transmitting = False
     self.bits = 0
     self.start_data = 0
Ejemplo n.º 22
0
    def __init__(self,
                 *args,
                 packets=False,
                 aux_signals=False,
                 data_type="buff",
                 **kwargs):
        """Initialization of Axi4Stream

        Args:
            *args: passed directly to the BusMonitor parent constructor.
            packets (bool, optional): wait for a high TLAST to call _recv.
                Defaults to False (call _recv on every transfer).
            aux_signals (bool, optional): when true, return a dict for each
                AXI4-Stream transfer where the key is the name of the signal
                and the value is the value of it.
                When false, return an int for each transfer representing the
                value of the TDATA signal
            data_type (str, optional): select the data type passed to _recv,
                either "buff" (for binary buffers of bytes) or "integer".
            **kwargs: passed directly to the BusMonitor parent constructor.
        """

        BusMonitor.__init__(self, *args, **kwargs)

        if packets and not hasattr(self.bus, "TLAST"):
            raise AttributeError("\'packets=True\', but \'TLAST\' is missing "
                                 "on this bus")

        if data_type not in ("buff", "integer"):
            raise AttributeError("data_type must be either \"buff\" or "
                                 "\"integer\"")

        self.packets = packets
        self.aux_signals = aux_signals
        self.data_type = data_type

        self.bus_optional_signals = \
            tuple(signal for signal in Axi4Stream._optional_data_signals
                  if hasattr(self.bus, signal) and
                  (signal != "TLAST" or not packets))
Ejemplo n.º 23
0
    def __init__(self, *args, **kwargs):
        config = kwargs.pop('config', {})
        BusMonitor.__init__(self, *args, **kwargs)

        self.config = self._default_config.copy()
        self.config.update(BusMonitor._default_config)

        # Set default config maxChannel to max value on channel bus
        if hasattr(self.bus, 'channel'):
            self.config['maxChannel'] = (2 ** len(self.bus.channel)) -1

        for configoption, value in config.items():
            self.config[configoption] = value
            self.log.debug("Setting config option %s to %s" %
                           (configoption, str(value)))

        num_data_symbols = (len(self.bus.data) /
                            self.config["dataBitsPerSymbol"])
        if (num_data_symbols > 1 and not hasattr(self.bus, 'empty')):
            raise AttributeError(
                "%s has %i data symbols, but contains no object named empty" %
                (self.name, num_data_symbols))

        self.config["useEmpty"] = (num_data_symbols > 1)

        if hasattr(self.bus, 'channel'):
            if "channel" in self._optional_signals:
                self.log.warning("Channel is not fully implemented in this monitor. Recommend use of AvalonSTPktsWithChannel.")

            if len(self.bus.channel) > 128:
                raise AttributeError(
                        "AvalonST interface specification defines channel width as 1-128. %d channel width is %d" %
                        (self.name, len(self.bus.channel))
                        )
            maxChannel = (2 ** len(self.bus.channel)) -1
            if self.config['maxChannel'] > maxChannel:
                raise AttributeError(
                        "%s has maxChannel=%d, but can only support a maximum channel of (2**channel_width)-1=%d, channel_width=%d" %
                        (self.name,self.config['maxChannel'],maxChannel,len(self.bus.channel)))
Ejemplo n.º 24
0
    def __init__(self, *args, packets=False, aux_signals=False, **kwargs):
        """Initialization of Axi4Stream

        Args:
            *args: passed directly to the BusMonitor parent constructor.
            packets (bool, optional): wait for a high TLAST to call _recv.
                Defaults to False (call _recv on every transaction).
            aux_signals (bool, optional): return an Axi4StreamTransfer named
                tuple containing all the data signals, instead of just TDATA.
                Defaults to False.
            **kwargs: passed directly to the BusMonitor parent constructor.
        """
        BusMonitor.__init__(self, *args, **kwargs)

        if packets and not hasattr(self.bus, "TLAST"):
            raise AttributeError("\'packets=True\', but \'TLAST\' is missing "
                                 "on this bus")

        self.packets = packets
        self.aux_signals = aux_signals

        self.bus_optional_signals = \
            tuple(signal for signal in Axi4Stream._optional_data_signals
                  if hasattr(self.bus, signal))
Ejemplo n.º 25
0
 def __init__(self, entity, name, clock, **kwargs):
     config = kwargs.pop('config', {})
     BusMonitor.__init__(self, entity, name, clock, **kwargs)
Ejemplo n.º 26
0
 def __init__(self, entity, name, clock, data_name, collector, **kwargs):
     BusMonitor.__init__(self, entity, name, clock, **kwargs)
     HasBusValue.__init__(self, entity, data_name)
     self.collector = collector
Ejemplo n.º 27
0
    def __init__(self, entity, name, clock, **kwargs):

        BusMonitor.__init__(self, entity, name, clock, **kwargs)

        self.log.info("Driver start initialization: %s", name)
Ejemplo n.º 28
0
	def __init__(self, dut, callback=None, event=None):
		BusMonitor.__init__(self, dut, None, dut.Clock, dut.Reset, callback=callback, event=event)
		self.name = "out"
Ejemplo n.º 29
0
	def __init__(self, dut, tb, callback=None, event=None):
		"""tb must be an instance of the Testbench class."""
		BusMonitor.__init__(self, dut, None, dut.Clock, dut.Reset, callback=callback, event=event)
		self.name = "out"
		self.tb = tb
Ejemplo n.º 30
0
 def __init__(self, *args, **kwargs):
     BusMonitor.__init__(self, *args, **kwargs)
Ejemplo n.º 31
0
 def __init__(self, entity, name, clock, bank=0, **kwargs):
     BusMonitor.__init__(self, entity, name, clock, **kwargs)
     self.bank = bank
     self.add_callback(self._get_result)
     self.expected = []
Ejemplo n.º 32
0
 def __init__(self, entity, name, clock):
     BusMonitor.__init__(self, entity, name, clock)
     self.clock = clock