Description
Using bitwise operations (e.g. &, |, ^) to combine two comparison expressions in a coverpoint iff condition causes a TypeError during sample() when both operands need to be evaluated.
Minimal Reproducible Example
@vsc.randobj
class Item:
def __init__(self):
self.x = vsc.rand_uint8_t()
self.y = vsc.rand_uint8_t()
@vsc.covergroup
class Cg:
def __init__(self):
self.with_sample(dict(it=Item()))
self.options.name = "cg"
self.cp_and = vsc.coverpoint(
self.it.x,
iff=(self.it.x > 10) & (self.it.y < 100),
bins={"a": vsc.bin([0, 255])}
)
cg = Cg()
item = Item()
for i in range(10):
item.randomize()
try:
cg.sample(item)
print(f"x={item.x}, y={item.y}: OK")
except TypeError as e:
print(f"x={item.x}, y={item.y}: FAILED - {e}")
Expected output
All iterations should complete without error.
Actual output
FAILED - TypeError: unsupported operand type(s) for &: 'ValueBool' and 'ValueBool'
The above exception is thrown.
Root Cause
ExprBinModel.val() applies &/| directly on ValueBool objects returned by comparison expressions, but ValueBool does not implement __and__, __or__, __xor__, __invert__, __rand__, __ror__, or __rxor__.
Description
Using bitwise operations (e.g.
&,|,^) to combine two comparison expressions in a coverpointiffcondition causes aTypeErrorduringsample()when both operands need to be evaluated.Minimal Reproducible Example
Expected output
All iterations should complete without error.
Actual output
The above exception is thrown.
Root Cause
ExprBinModel.val()applies&/|directly onValueBoolobjects returned by comparison expressions, butValueBooldoes not implement__and__,__or__,__xor__,__invert__,__rand__,__ror__, or__rxor__.