Difficulty: Medium · Puzzle 5 of 6 · Topic: Cross Coverage Puzzles
Calculate legal cross coverage and identify illegal activity. Options: none set (all defaults: at_least = 1, weight = 1, auto_bin_max = 64).
covergroup cg with function sample(bit [2:0] len, bit [1:0] typ);
cp_len: coverpoint len {
bins short = {[1:2]};
bins long = {[3:4]};
}
cp_typ: coverpoint typ {
bins rd = {0};
bins wr = {1};
bins probe = {2};
}
x_len_typ: cross cp_len, cp_typ {
illegal_bins short_probe = binsof(cp_len.short) && binsof(cp_typ.probe);
}
endgroup
initial begin
cg c = new();
c.sample(1,0);
c.sample(4,1);
c.sample(2,2);
c.sample(3,2);
c.sample(1,1);
endStart from 2x3 tuples, then remove the illegal tuple from legal denominator.
1) Raw tuple count is 2 * 3 = 6.
2) short_probe is illegal, so legal scored bins are 5.
3) Legal tuples hit: short-rd, long-wr, long-probe, short-wr -> 4 legal bins.
4) short-probe is hit once but is illegal activity, not legal progress.
5) Legal cross coverage = 4/5 = 80%.Answer: Legal cross coverage is 80% with one illegal short-probe hit.
Checked by running a model of the rule in a Python model. A model of the cross rule: the illegal short-probe hit is reported but only legal tuples count, 4 of 5.
An illegal tuple can be frequently exercised while legal closure remains incomplete.
Would you also assert that short+probe is forbidden, and why is that useful beyond coverage? Model answer: Yes. illegal_bins only reports when coverage is enabled and sampled; an assertion is always on, fires at the exact cycle with a message, and can be proven or falsified by formal. Coverage then just records that the legal space was exercised.
I would separate legal and illegal tuples first. Legal cross coverage is 80 percent, and the illegal short-probe tuple was hit once, which is reported as an error. Illegal hits do not move the legal numerator. The trap is that an illegal tuple can be hit very often while legal closure stays incomplete, so I would next find the missing legal tuple.