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


Python BinaryValue.big_endian方法代码示例

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


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

示例1: _write_data

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

        while True:
            while True:
                self.bus.WREADY <= 0
                yield ReadOnly()
                yield NextTimeStep()
                if self.bus.AWVALID.value:
                    self.bus.WREADY <= 1
                    break
                yield clock_re

            yield ReadOnly()
            _awaddr = int(self.bus.AWADDR)
            _awlen = int(self.bus.AWLEN)
            _awsize = int(self.bus.AWSIZE)
            _awburst = int(self.bus.AWBURST)
            _awprot = int(self.bus.AWPROT)

            burst_length = _awlen + 1
            bytes_in_beat = self._size_to_bytes_in_beat(_awsize)

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

            if __debug__:
                self.log.debug(
                    "AWADDR  0x{:x}\n".format(_awaddr) +
                    "AWLEN   %d\n" % _awlen +
                    "AWSIZE  %d\n" % _awsize +
                    "AWBURST %d\n" % _awburst +
                    "BURST_LENGTH %d\n" % burst_length +
                    "Bytes in beat %d\n" % bytes_in_beat)

            burst_count = burst_length

            yield clock_re

            while True:
                if self.bus.WVALID.value:
                    word = self.bus.WDATA.value
                    word.big_endian = self.big_endain
                    _burst_diff = burst_length - burst_count
                    _st = _awaddr + (_burst_diff * bytes_in_beat)  # start
                    _end = _awaddr + ((_burst_diff + 1) * bytes_in_beat)  # end
                    self._memory[_st:_end] = array.array('B', word.get_buff())
                    burst_count -= 1
                    if burst_count == 0:
                        self.bus.BVALID.value = 1
                        while self.bus.BREADY == 0:
                            yield clock_re
                        self.bus.BVALID.value = 0
                        break
                yield clock_re
开发者ID:Martoni,项目名称:cocotb,代码行数:56,代码来源:amba.py

示例2: _write_data

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

        while True:
            while True:
                self.bus.WREADY <= 0
                yield ReadOnly()
                if self.bus.AWVALID.value:
                    self.bus.WREADY <= 1
                    break
                yield clock_re

            yield ReadOnly()
            _awaddr  = int(self.bus.AWADDR)
            _awlen   = int(self.bus.AWLEN)
            _awsize  = int(self.bus.AWSIZE)
            _awburst = int(self.bus.AWBURST)
            _awprot  = int(self.bus.AWPROT)

            burst_length = _awlen + 1
            bytes_in_beat = self._size_to_bytes_in_beat(_awsize)

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

            if __debug__:
                self.log.debug(
                    "AWADDR  %d\n" % _awaddr +
                    "AWLEN   %d\n" % _awlen  +
                    "AWSIZE  %d\n" % _awsize +
                    "AWBURST %d\n" % _awburst +
                    "BURST_LENGTH %d\n" % burst_length +
                    "Bytes in beat %d\n" % bytes_in_beat)

            burst_count = burst_length

            yield clock_re

            while True:
                if self.bus.WVALID.value:
                    word = self.bus.WDATA.value
                    word.big_endian = self.big_endain
                    self._memory[_awaddr+((burst_length-burst_count)*bytes_in_beat):_awaddr+(((burst_length-burst_count)+1)*bytes_in_beat)] = array.array('B',word.get_buff())
                    burst_count -= 1
                    if burst_count == 0:
                        break
                yield clock_re
开发者ID:enchanter,项目名称:cocotb,代码行数:48,代码来源:amba.py

示例3: _monitor_recv

# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import big_endian [as 别名]
    def _monitor_recv(self):
        """Watch the pins and reconstruct transactions."""

        # Avoid spurious object creation by recycling
        clkedge = RisingEdge(self.clock)
        rdonly = ReadOnly()
        pkt = ""
        in_pkt = False
        invalid_cyclecount = 0
        channel = None

        def valid():
            if hasattr(self.bus, 'ready'):
                return self.bus.valid.value and self.bus.ready.value
            return self.bus.valid.value

        while True:
            yield clkedge
            yield rdonly

            if self.in_reset:
                continue

            if valid():
                invalid_cyclecount = 0

                if self.bus.startofpacket.value:
                    if pkt and self.config['fail_immediately']:
                        raise AvalonProtocolError(
                            "Duplicate start-of-packet received on %s" % (
                                str(self.bus.startofpacket)))
                    pkt = ""
                    in_pkt = True

                if not in_pkt and self.config['fail_immediately']:
                    raise AvalonProtocolError("Data transfer outside of "
                                              "packet")

                # Handle empty and X's in empty / data
                vec = BinaryValue()
                if not self.bus.endofpacket.value:
                    vec = self.bus.data.value
                else:
                    value = self.bus.data.value.get_binstr()
                    if self.config["useEmpty"] and self.bus.empty.value.integer:
                        empty = self.bus.empty.value.integer * self.config["dataBitsPerSymbol"]
                        if self.config["firstSymbolInHighOrderBits"]:
                            value = value[:-empty]
                        else:
                            value = value[empty:]
                    vec.assign(value)
                    if not vec.is_resolvable:
                        raise AvalonProtocolError("After empty masking value is still bad?  Had empty {:d}, got value {:s}".format(empty, self.bus.data.value.get_binstr()))

                vec.big_endian = self.config['firstSymbolInHighOrderBits']
                pkt += vec.buff

                if hasattr(self.bus, 'channel'):
                    if channel is None:
                        channel = self.bus.channel.value.integer
                        if channel > self.config["maxChannel"]:
                            raise AvalonProtocolError("Channel value (%d) is greater than maxChannel (%d)" % (channel,self.config["maxChannel"]))
                    elif self.bus.channel.value.integer != channel:
                        raise AvalonProtocolError("Channel value changed during packet")

                if self.bus.endofpacket.value:
                    self.log.info("Received a packet of %d bytes" % len(pkt))
                    self.log.debug(hexdump(str((pkt))))
                    self.channel = channel
                    self._recv(pkt)
                    pkt = ""
                    in_pkt = False
                    channel = None
            else :
                if in_pkt :
                    invalid_cyclecount += 1
                    if self.config["invalidTimeout"] :
                        if invalid_cyclecount >= self.config["invalidTimeout"] :
                            raise AvalonProtocolError(
                                "In-Packet Timeout. Didn't receive any valid data for %d cycles!" %
                                invalid_cyclecount)
开发者ID:zpan007,项目名称:cocotb,代码行数:83,代码来源:avalon.py


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