Difficulty: Medium · Puzzle 4 of 6 · Topic: Covergroup and Coverpoint Puzzles
Determine which transition bins hit and give final percentage. Options: none set (all defaults: at_least = 1, weight = 1, auto_bin_max = 64).
covergroup cg with function sample(bit [1:0] state);
cp_state: coverpoint state {
bins warmup = (0 => 1 => 2);
bins bounce = (2 => 1 => 2);
bins reset = (2 => 0);
}
endgroup
initial begin
cg c = new();
c.sample(0);
c.sample(1);
c.sample(2);
c.sample(1);
c.sample(2);
c.sample(0);
endWrite the sampled stream first, then slide windows for 3-step and 2-step transitions.
1) Sampled stream is 0,1,2,1,2,0.
2) warmup (0=>1=>2) matches at samples 1..3.
3) bounce (2=>1=>2) matches at samples 3..5.
4) reset (2=>0) matches at samples 5..6.
5) All 3 bins hit -> 3/3 = 100%.Answer: warmup, bounce, and reset all hit, so coverage is 100% (3/3).
Checked by running a model of the rule in a Python model. A model of transition matching over the sampled stream 0,1,2,1,2,0: all three sequences occur, so 3 of 3.
Candidates often count only non-overlapping windows and miss valid overlapping transition matches.
How many bins remain hit if the last sample c.sample(0) is removed? Model answer: Two: warmup (0=>1=>2) and bounce (2=>1=>2) still match the stream 0,1,2,1,2; reset (2=>0) is lost, so 2/3 = 66.67%.
I would slide a window over the sampled sequence and test every starting position. Warmup, bounce and reset all match, so coverage is 100 percent, three of three. The reason is that transition matches can overlap, because every sample can start a new attempt. The trap is counting only non-overlapping windows and missing a valid match, so I would recheck the sequence by hand.