当前位置: 首页>>代码示例>>Python>>正文


Python BinaryValue.buff方法代码示例

本文整理汇总了Python中cocotb.binary.BinaryValue.buff方法的典型用法代码示例。如果您正苦于以下问题:Python BinaryValue.buff方法的具体用法?Python BinaryValue.buff怎么用?Python BinaryValue.buff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cocotb.binary.BinaryValue的用法示例。


在下文中一共展示了BinaryValue.buff方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _read_data

# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import buff [as 别名]
    def _read_data(self):
        clock_re = RisingEdge(self.clock)

        while True:
            while True:
                yield ReadOnly()
                if self.bus.ARVALID.value:
                    break
                yield clock_re

            yield ReadOnly()
            self._araddr = int(self.bus.ARADDR)
            _arlen = int(self.bus.ARLEN)
            _arsize = int(self.bus.ARSIZE)
            _arburst = int(self.bus.ARBURST)
            _arprot = int(self.bus.ARPROT)

            burst_length = _arlen + 1
            bytes_in_beat = self._size_to_bytes_in_beat(_arsize)

            word = BinaryValue(bits=bytes_in_beat*8, bigEndian=self.big_endain)

            if __debug__:
                self.log.debug(
                    "ARLEN   %d\n" % _arlen +
                    "ARSIZE  %d\n" % _arsize +
                    "ARBURST %d\n" % _arburst +
                    "BURST_LENGTH %d\n" % burst_length +
                    "Bytes in beat %d\n" % bytes_in_beat)

            burst_count = burst_length

            word.buff = self._read_memory(burst_length,
                                          burst_count,
                                          bytes_in_beat)
            yield clock_re

            self.bus.RDATA <= word
            while True:
                self.bus.RVALID <= 1
                yield clock_re
                if self.bus.RREADY.value:
                    word.buff = self._read_memory(burst_length,
                                                  burst_count,
                                                  bytes_in_beat)
                    self.bus.RDATA <= word
                    if burst_count == 1:
                        self.bus.RLAST <= 1
                        yield clock_re
                        self.bus.RLAST <= 0
                        self.bus.RVALID <= 0
                        break
                burst_count -= 1
开发者ID:Martoni,项目名称:cocotb,代码行数:55,代码来源:amba.py

示例2: _read_data

# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import buff [as 别名]
    def _read_data(self):
        clock_re = RisingEdge(self.clock)

        while True:
            while True:
                yield ReadOnly()
                if self.bus.ARVALID.value:
                    break
                yield clock_re

            yield ReadOnly()
            _araddr = int(self.bus.ARADDR)
            _arlen = int(self.bus.ARLEN)
            _arsize = int(self.bus.ARSIZE)
            _arburst = int(self.bus.ARBURST)
            _arprot = int(self.bus.ARPROT)

            burst_length = _arlen + 1
            bytes_in_beat = self._size_to_bytes_in_beat(_arsize)

            word = BinaryValue(n_bits=bytes_in_beat*8, bigEndian=self.big_endian)

            if __debug__:
                self.log.debug(
                    "ARADDR  %d\n" % _araddr +
                    "ARLEN   %d\n" % _arlen +
                    "ARSIZE  %d\n" % _arsize +
                    "ARBURST %d\n" % _arburst +
                    "BURST_LENGTH %d\n" % burst_length +
                    "Bytes in beat %d\n" % bytes_in_beat)

            burst_count = burst_length

            yield clock_re

            while True:
                self.bus.RVALID <= 1
                yield ReadOnly()
                if self.bus.RREADY.value:
                    _burst_diff = burst_length - burst_count
                    _st = _araddr + (_burst_diff * bytes_in_beat)
                    _end = _araddr + ((_burst_diff + 1) * bytes_in_beat)
                    word.buff = self._memory[_st:_end].tostring()
                    self.bus.RDATA <= word
                    if burst_count == 1:
                        self.bus.RLAST <= 1
                yield clock_re
                burst_count -= 1
                self.bus.RLAST <= 0
                if burst_count == 0:
                    break
开发者ID:zpan007,项目名称:cocotb,代码行数:53,代码来源:amba.py

示例3: _send_string

# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import buff [as 别名]
    def _send_string(self, string, sync=True, channel=None):
        """Args:
            string (str): A string of bytes to send over the bus.
            channel (int): Channel to send the data on.
        """
        # Avoid spurious object creation by recycling
        clkedge = RisingEdge(self.clock)
        firstword = True

        # FIXME busses that aren't integer numbers of bytes
        bus_width = int(len(self.bus.data) / 8)

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

        single = BinaryValue(n_bits=1, bigEndian=False)
        if self.use_empty:
            empty = BinaryValue(n_bits=len(self.bus.empty), bigEndian=False)

        # Drive some defaults since we don't know what state we're in
        if self.use_empty:
            self.bus.empty <= 0
        self.bus.startofpacket <= 0
        self.bus.endofpacket <= 0
        self.bus.valid <= 0
        if hasattr(self.bus, 'error'):
            self.bus.error <= 0

        if hasattr(self.bus, 'channel'):
            self.bus.channel <= 0
        elif channel is not None:
            raise TestError("%s does not have a channel signal" % self.name)

        while string:
            if not firstword or (firstword and sync):
                yield clkedge

            # Insert a gap where valid is low
            if not self.on:
                self.bus.valid <= 0
                for i in range(self.off):
                    yield clkedge

                # Grab the next set of on/off values
                self._next_valids()

            # Consume a valid cycle
            if self.on is not True and self.on:
                self.on -= 1

            self.bus.valid <= 1
            if hasattr(self.bus, 'channel'):
                if channel is None:
                    self.bus.channel <= 0
                elif channel > self.config['maxChannel'] or channel < 0:
                    raise TestError(
                            "%s: Channel value %d is outside range 0-%d" %
                            (self.name,channel,self.config['maxChannel']))
                else:
                    self.bus.channel <= channel

            if firstword:
                self.bus.startofpacket <= 1
                firstword = False
            else:
                self.bus.startofpacket <= 0

            nbytes = min(len(string), bus_width)
            data = string[:nbytes]
            word.buff = data

            if len(string) <= bus_width:
                self.bus.endofpacket <= 1
                if self.use_empty:
                    self.bus.empty <= bus_width - len(string)
                string = ""
            else:
                string = string[bus_width:]

            self.bus.data <= word

            # If this is a bus with a ready signal, wait for this word to
            # be acknowledged
            if hasattr(self.bus, "ready"):
                yield self._wait_ready()

        yield clkedge
        self.bus.valid <= 0
        self.bus.endofpacket <= 0
        word.binstr   = ("x"*len(self.bus.data))
        single.binstr = ("x")
        self.bus.data <= word
        self.bus.startofpacket <= single
        self.bus.endofpacket <= single

        if self.use_empty:
            empty.binstr  = ("x"*len(self.bus.empty))
            self.bus.empty <= empty
        if hasattr(self.bus, 'channel'):
            channel_value = BinaryValue(n_bits=len(self.bus.channel), bigEndian=False)
#.........这里部分代码省略.........
开发者ID:TC01,项目名称:cocotb,代码行数:103,代码来源:avalon.py

示例4: _send_string

# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import buff [as 别名]
    def _send_string(self, string, sync=True):
        """
        Args:
            string (str): A string of bytes to send over the bus
        """
        # Avoid spurious object creation by recycling
        clkedge = RisingEdge(self.clock)
        firstword = True

        # FIXME busses that aren't integer numbers of bytes
        bus_width = int(len(self.bus.data) / 8)

        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)


        # Drive some defaults since we don't know what state we're in
        # self.bus.empty <= 0
        self.bus.startofpacket <= 0
        self.bus.endofpacket <= 0
        self.bus.valid <= 0
        if hasattr(self.bus, 'error'):
            self.bus.error <= 0

        while string:
            if not firstword or (firstword and sync):
                yield clkedge

            # Insert a gap where valid is low
            if not self.on:
                self.bus.valid <= 0
                for i in range(self.off):
                    yield clkedge

                # Grab the next set of on/off values
                self._next_valids()

            # Consume a valid cycle
            if self.on is not True and self.on:
                self.on -= 1

            self.bus.valid <= 1

            if firstword:
                #self.bus.empty <= 0
                self.bus.startofpacket <= 1
                firstword = False
            else:
                self.bus.startofpacket <= 0

            nbytes = min(len(string), bus_width)
            data = string[:nbytes]
            word.buff = data

            if len(string) <= bus_width:
                self.bus.endofpacket <= 1
                self.bus.empty <= bus_width - len(string)
                string = ""
            else:
                string = string[bus_width:]

            self.bus.data <= word

            # If this is a bus with a ready signal, wait for this word to
            # be acknowledged
            if hasattr(self.bus, "ready"):
                yield self._wait_ready()

        yield clkedge
        self.bus.valid <= 0
        self.bus.endofpacket <= 0
        word.binstr   = ("x"*len(self.bus.data))
        empty.binstr  = ("x"*len(self.bus.empty))
        single.binstr = ("x")
        self.bus.data <= word
        self.bus.empty <= empty
        self.bus.startofpacket <= single
        self.bus.endofpacket <= single
开发者ID:Martoni,项目名称:cocotb,代码行数:83,代码来源:avalon.py


注:本文中的cocotb.binary.BinaryValue.buff方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。