Difficulty: Medium · Puzzle 1 of 6 · Topic: Cross Coverage Puzzles
The six cross products (2 lengths x 3 bursts) are each selected by exactly one of the three named cross bins, so no automatic bins are left over. How many cross bins are scored, and what is the cross coverage? 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] burst);
cp_len: coverpoint len {
bins short = {[0:3]};
bins long = {[4:7]};
}
cp_burst: coverpoint burst {
bins incr = {0};
bins wrap = {1};
bins fixed = {2};
}
x_len_burst: cross cp_len, cp_burst {
bins short_any = binsof(cp_len.short);
bins long_incr = binsof(cp_len.long) && binsof(cp_burst.incr);
bins long_other = binsof(cp_len.long) && (binsof(cp_burst.wrap) || binsof(cp_burst.fixed));
}
endgroup
initial begin
cg c = new();
c.sample(1,0);
c.sample(7,1);
c.sample(5,2);
endA user-defined cross bin is one bin, however many tuples its select expression covers. Map each sample to its bin.
1) short_any selects (short,incr), (short,wrap), (short,fixed); long_incr selects 1 tuple; long_other selects (long,wrap), (long,fixed). Together they cover all 6 tuples exactly once, so the scored denominator is the 3 named bins.
2) sample(1,0) is short + incr -> short_any.
3) sample(7,1) is long + wrap -> long_other.
4) sample(5,2) is long + fixed -> long_other again.
5) Hit bins = short_any and long_other = 2 of 3 -> 66.67%.Answer: 3 cross bins are scored; 2 are hit (short_any, long_other), so cross coverage is 66.67%.
Checked by running a model of the rule in a Python model. A model of the cross rule: three named bins cover all six tuples, and two of them are hit.
A named cross bin counts once however many tuples it groups. Counting the 3 distinct tuples hit out of 6 gives 50%, which is wrong here; (7,1) and (5,2) are two tuples but the same bin long_other.
Which single further sample closes this cross? Model answer: Any long length with the incr burst, for example sample(4,0): it hits long_incr, so 3 of 3 bins are hit = 100%.
I would count the named cross bins, not the tuples. Three named bins cover all six products, so three bins are scored, and two are hit, short_any and long_other, giving 66.67 percent. A named cross bin counts once however many tuples it groups. The trap is counting three distinct tuples out of six and saying 50 percent, so I would check which bin each tuple falls into.