本文整理汇总了Python中cocotb.binary.BinaryValue.binstr方法的典型用法代码示例。如果您正苦于以下问题:Python BinaryValue.binstr方法的具体用法?Python BinaryValue.binstr怎么用?Python BinaryValue.binstr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocotb.binary.BinaryValue
的用法示例。
在下文中一共展示了BinaryValue.binstr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import binstr [as 别名]
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
示例2: __init__
# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import binstr [as 别名]
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
示例3: __init__
# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import binstr [as 别名]
def __init__(self, entity, name, clock):
BusDriver.__init__(self, entity, name, clock)
word = BinaryValue(bits=32)
single = BinaryValue(bits=1)
word.binstr = ("x" * 32)
single.binstr = ("x")
self.bus.load_i <= single
self.bus.rst_i <= single
self.bus.dat_i <= word
示例4: _driver_send
# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import binstr [as 别名]
def _driver_send(self, value, sync=True):
"""Send a transmission over the bus.
Args:
value: data to drive onto the bus.
"""
self.log.debug("Sending Avalon transmission: %d" % value)
# Avoid spurious object creation by recycling
clkedge = RisingEdge(self.clock)
word = BinaryValue(n_bits=len(self.bus.data), bigEndian=False)
# Drive some defaults since we don't know what state we're in
self.bus.valid <= 0
if 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
word.assign(value)
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
word.binstr = ("x"*len(self.bus.data))
self.bus.data <= word
self.log.debug("Successfully sent Avalon transmission: %d" % value)
示例5: _getvalue
# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import binstr [as 别名]
def _getvalue(self):
result = BinaryValue()
result.binstr = simulator.get_signal_val_binstr(self._handle)
return result
示例6: _send_string
# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import binstr [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)
#.........这里部分代码省略.........
示例7: _send_string
# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import binstr [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
示例8: getvalue
# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import binstr [as 别名]
def getvalue(self):
result = BinaryValue()
result.binstr = self._get_value_str()
return result