Ejemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        config = kwargs.pop('config', {})
        ValidatedBusDriver.__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)))

        word   = BinaryValue(bits=len(self.bus.data),
                             bigEndian=self.config['firstSymbolInHighOrderBits'])

        empty  = BinaryValue(bits=len(self.bus.empty), bigEndian=False)
        single = BinaryValue(bits=1, bigEndian=False)

        word.binstr   = ("x"*len(self.bus.data))
        empty.binstr  = ("x"*len(self.bus.empty))
        single.binstr = ("x")

        self.bus.valid <= 0
        self.bus.data <= word
        self.bus.empty <= empty
        self.bus.startofpacket <= single
        self.bus.endofpacket <= single
Ejemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        config = kwargs.pop('config', {})
        ValidatedBusDriver.__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)))

        word = BinaryValue(bits=len(self.bus.data),
                           bigEndian=self.config['firstSymbolInHighOrderBits'])

        empty = BinaryValue(bits=len(self.bus.empty), bigEndian=False)
        single = BinaryValue(bits=1, bigEndian=False)

        word.binstr = ("x" * len(self.bus.data))
        empty.binstr = ("x" * len(self.bus.empty))
        single.binstr = ("x")

        self.bus.valid <= 0
        self.bus.data <= word
        self.bus.empty <= empty
        self.bus.startofpacket <= single
        self.bus.endofpacket <= single
Ejemplo n.º 3
0
    def __init__(self, entity, name, clock, *, config={}, **kwargs):
        ValidatedBusDriver.__init__(self, entity, name, clock, **kwargs)

        self.config = AvalonSTPkts._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.use_empty = (num_data_symbols > 1)
        self.config["useEmpty"] = self.use_empty

        word = BinaryValue(n_bits=len(self.bus.data),
                           bigEndian=self.config["firstSymbolInHighOrderBits"])

        single = BinaryValue(n_bits=1, bigEndian=False)

        word.binstr = "x" * len(self.bus.data)
        single.binstr = "x"

        self.bus.valid <= 0
        self.bus.data <= word
        self.bus.startofpacket <= single
        self.bus.endofpacket <= single

        if self.use_empty:
            empty = BinaryValue(n_bits=len(self.bus.empty),
                                bigEndian=False,
                                value="x" * len(self.bus.empty))
            self.bus.empty <= empty

        if hasattr(self.bus, 'channel'):
            if len(self.bus.channel) > 128:
                raise AttributeError(
                    "Avalon-ST 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)))
            channel = BinaryValue(n_bits=len(self.bus.channel),
                                  bigEndian=False,
                                  value="x" * len(self.bus.channel))
            self.bus.channel <= channel
Ejemplo n.º 4
0
    def __init__(self, *args, **kwargs):
        config = kwargs.pop('config', {})
        ValidatedBusDriver.__init__(self, *args, **kwargs)

        self.config = AvalonSTPkts._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.use_empty = (num_data_symbols > 1)
        self.config["useEmpty"] = self.use_empty

        word   = BinaryValue(n_bits=len(self.bus.data),
                             bigEndian=self.config['firstSymbolInHighOrderBits'])

        single = BinaryValue(n_bits=1, bigEndian=False)

        word.binstr   = ("x"*len(self.bus.data))
        single.binstr = ("x")

        self.bus.valid <= 0
        self.bus.data <= word
        self.bus.startofpacket <= single
        self.bus.endofpacket <= single

        if self.use_empty:
            empty = BinaryValue(n_bits=len(self.bus.empty), bigEndian=False)
            empty.binstr  = ("x"*len(self.bus.empty))
            self.bus.empty <= empty

        if hasattr(self.bus, 'channel'):
            if len(self.bus.channel) > 128:
                raise AttributeError(
                        "Avalon-ST 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)))
            channel = BinaryValue(n_bits=len(self.bus.channel), bigEndian=False)
            channel.binstr = ("x"*len(self.bus.channel))
            self.bus.channel <= channel
Ejemplo n.º 5
0
    def __init__(self, *args, **kwargs):
        config = kwargs.pop('config', {})
        ValidatedBusDriver.__init__(self, *args, **kwargs)

        self.config = AvalonSTPkts._default_config.copy()

        for configoption, value in config.iteritems():
            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):
        config = kwargs.pop('config', {})
        ValidatedBusDriver.__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.º 7
0
    def __init__(self, entity, name, clock, lsb_first=True, **kwargs):
        ValidatedBusDriver.__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

        self._lsb_first = lsb_first
        self._idle_outputs()
Ejemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        config = kwargs.pop('config', {})
        ValidatedBusDriver.__init__(self, *args, **kwargs)

        self.config = AvalonST._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)))

        word = BinaryValue(n_bits=len(self.bus.data), bigEndian=self.config['firstSymbolInHighOrderBits'])

        self.bus.valid  <= 0
        self.bus.data   <= word
Ejemplo n.º 9
0
    def __init__(self, entity, name, clock, *, config={}, **kwargs):
        ValidatedBusDriver.__init__(self, entity, name, clock, **kwargs)

        self.config = AvalonST._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))

        word = BinaryValue(n_bits=len(self.bus.data), bigEndian=self.config["firstSymbolInHighOrderBits"],
                           value="x" * len(self.bus.data))

        self.bus.valid  <= 0
        self.bus.data   <= word