Description
When a coverpoint contains bins that can match the same value simultaneously (e.g. wildcard bins with overlapping patterns), a cross that includes that coverpoint only records a hit for the first matching bin. All other matching bins are silently ignored.
Minimal Reproducible Example
@vsc.randobj
class Item:
def __init__(self):
self.data = vsc.rand_uint8_t()
@vsc.covergroup
class Cg:
def __init__(self):
self.with_sample(dict(it=Item()))
self.options.name = "cg"
self.multi_cp = vsc.coverpoint(
self.it.data,
bins={
"has_bit0": vsc.wildcard_bin("0b???????1"),
"has_bit1": vsc.wildcard_bin("0b??????1?"),
}
)
self.plain_cp = vsc.coverpoint(
self.it.data,
bins={
"low": vsc.bin([0, 127]),
"high": vsc.bin([128, 255])
}
)
self.cross = vsc.cross([self.multi_cp, self.plain_cp])
cg = Cg()
item = Item()
# 0b00000011 matches both has_bit0 and has_bit1
item.data = 0b00000011
cg.sample(item)
for i in range(cg.get_model().cross_l[0].get_n_bins()):
hits = cg.get_model().cross_l[0].get_bin_hits(i)
name = cg.get_model().cross_l[0].get_bin_name(i)
if hits > 0:
print(f"{name}: {hits}")
Expected output
<has_bit0,low>: 1
<has_bit1,low>: 1
Actual output
Root Cause
In CoverpointCrossModel.sample(), the loop over bin_model_l breaks after the first matching bin:
for b in cp.bin_model_l:
if b.hit_idx() != -1:
key_m.append(b.hit_idx() + idx)
have_bin_hit = True
break # <- stops at first match
This means only the first bin that matches is recorded for the cross, even when multiple bins match the same sampled value simultaneously.
Description
When a coverpoint contains bins that can match the same value simultaneously (e.g. wildcard bins with overlapping patterns), a cross that includes that coverpoint only records a hit for the first matching bin. All other matching bins are silently ignored.
Minimal Reproducible Example
Expected output
Actual output
Root Cause
In
CoverpointCrossModel.sample(), the loop overbin_model_lbreaks after the first matching bin:This means only the first bin that matches is recorded for the cross, even when multiple bins match the same sampled value simultaneously.