Difficulty: Medium · Puzzle 3 of 6 · Topic: Cross Coverage Puzzles
A cross bin cannot be declared with default, so the three tuples that are not named are removed with an explicit ignore_bins select. Determine the scored bin count and the final percentage. Options: none set (all defaults: at_least = 1, weight = 1, auto_bin_max = 64).
covergroup cg with function sample(bit [2:0] size, bit [1:0] qos);
cp_size: coverpoint size {
bins tiny = {[0:3]};
bins big = {[4:7]};
}
cp_qos: coverpoint qos {
bins low = {0};
bins high = {1};
bins urgent = {2};
}
x_sz_qos: cross cp_size, cp_qos {
bins big_high = binsof(cp_size.big) && binsof(cp_qos.high);
bins big_urgent = binsof(cp_size.big) && binsof(cp_qos.urgent);
bins tiny_low = binsof(cp_size.tiny) && binsof(cp_qos.low);
ignore_bins rest = (binsof(cp_size.tiny) && (binsof(cp_qos.high) || binsof(cp_qos.urgent)))
|| (binsof(cp_size.big) && binsof(cp_qos.low));
}
endgroup
initial begin
cg c = new();
c.sample(6,1);
c.sample(7,2);
c.sample(2,2);
endThe 2 x 3 space has 6 tuples. Three are named, the other three are in ignore_bins rest. Then map each sample.
1) Six tuples. rest ignores (tiny,high), (tiny,urgent) and (big,low); the three named bins are exactly the remaining tuples, so 3 bins are scored.
2) sample(6,1) is big + high -> big_high.
3) sample(7,2) is big + urgent -> big_urgent.
4) sample(2,2) is tiny + urgent, which is in rest: ignored, no bin is hit.
5) Coverage = 2/3 = 66.67%.Answer: 3 bins are scored and coverage is 66.67% (big_high and big_urgent hit, tiny_low missing).
Checked by running a model of the rule in a Python model. A model of the cross rule: the ignored tuple (tiny, urgent) hits nothing, leaving 2 of 3 scored bins.
The sample (2,2) looks like progress on urgent traffic, but tiny + urgent is in ignore_bins rest, so it is neither counted nor reported. Counting all 2 x 3 = 6 tuples in the denominator would give 2/6 = 33.33%.
What single stimulus would close this model to 100%? Model answer: A tiny size with qos 0, for example sample(1,0): it hits tiny_low, giving 3/3 = 100%. Repeating the ignored tuple (2,2) never helps.
I would remove the ignored tuples from the denominator first. Three bins are scored, and big_high and big_urgent are hit, but tiny_low is not, so coverage is 66.67 percent. The sample of tiny with urgent falls in ignore_bins, so it counts for nothing. The trap is keeping all six tuples in the denominator and saying 33.33 percent; I would check that the ignore select matches the plan.