本文整理汇总了Python中cocotb.binary.BinaryValue.__eq__方法的典型用法代码示例。如果您正苦于以下问题:Python BinaryValue.__eq__方法的具体用法?Python BinaryValue.__eq__怎么用?Python BinaryValue.__eq__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocotb.binary.BinaryValue
的用法示例。
在下文中一共展示了BinaryValue.__eq__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConstantObject
# 需要导入模块: from cocotb.binary import BinaryValue [as 别名]
# 或者: from cocotb.binary.BinaryValue import __eq__ [as 别名]
class ConstantObject(NonHierarchyObject):
"""
Constant objects have a value that can be read, but not set.
We can also cache the value since it is elaboration time fixed and won't
change within a simulation
"""
def __init__(self, handle, handle_type):
NonHierarchyObject.__init__(self, handle)
if handle_type in [simulator.INTEGER, simulator.ENUM]:
self._value = simulator.get_signal_val_long(self._handle)
elif handle_type == simulator.REAL:
self._value = simulator.get_signal_val_real(self._handle)
elif handle_type == simulator.STRING:
self._value = simulator.get_signal_val_str(self._handle)
else:
val = simulator.get_signal_val_binstr(self._handle)
self._value = BinaryValue(bits=len(val))
try:
self._value.binstr = val
except:
self._value = val
def __int__(self):
return int(self._value)
def __eq__(self, other):
return self._value.__eq__(other)
def __ne__(self, other):
if isinstance(self._value, str):
return self._value.__ne__(other)
else:
return self._value != other
def __repr__(self):
return str(self._value)
@property
def value(self):
return self._value
def _setcachedvalue(self, *args, **kwargs):
raise ValueError("Not permissible to set values on a constant object")
def __le__(self, *args, **kwargs):
raise ValueError("Not permissible to set values on a constant object")