For six covergroups with illegal bins, find the first sample that raises the illegal-bin error, if any.
Hardware context: Covergroups with illegal values, transitions and cross products. Find the sample at which the illegal-bin error fires.
Each row of the table is a small program: declarations with a covergroup instance c, and numbered samples. Some bins are illegal.
Write answer(q) so it returns the number of the first sample that raises an illegal-bin error. Count from 1, and return 0 if no sample does. Questions 0 to 2 are worked examples; 3 to 8 are graded only by the full check.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 8 | input of each check |
Full specification
| q | Declarations | Samples | Kind |
|---|---|---|---|
| 0 | bit [1:0] v; covergroup cg; coverpoint v { bins a = {1}; illegal_bins bad = {3}; } endgroup cg c = new; | v = 1; c.sample(); v = 2; c.sample(); | worked example |
| 1 | bit [1:0] v; covergroup cg; coverpoint v { bins a = {1}; illegal_bins bad = {3}; } endgroup cg c = new; | v = 1; c.sample(); v = 3; c.sample(); v = 3; c.sample(); | worked example |
| 2 | bit [3:0] v; covergroup cg; coverpoint v { bins lo = {[0:7]}; illegal_bins bad = {[8:$]}; } endgroup cg c = new; | v = 2; c.sample(); v = 9; c.sample(); | worked example |
| 3 | bit [2:0] v; covergroup cg; coverpoint v { bins all = {[0:7]}; illegal_bins bad = {[5:6]}; } endgroup cg c = new; | v = 2; c.sample(); v = 4; c.sample(); v = 6; c.sample(); v = 5; c.sample(); | graded |
| 4 | bit [1:0] v; covergroup cg; coverpoint v { bins a = {3}; ignore_bins ig = {1, 2}; illegal_bins bad = {2}; } endgroup cg c = new; | v = 3; c.sample(); v = 1; c.sample(); v = 2; c.sample(); | graded |
| 5 | bit [1:0] v; bit en; covergroup cg; coverpoint v iff (en) { bins a = {1}; illegal_bins bad = {3}; } endgroup cg c = new; | v = 3; en = 0; c.sample(); v = 3; en = 1; c.sample(); | graded |
| 6 | bit [1:0] v; covergroup cg; coverpoint v { bins a = {1}; illegal_bins bad = (1 => 2); } endgroup cg c = new; | v = 2; c.sample(); v = 1; c.sample(); v = 1; c.sample(); v = 2; c.sample(); | graded |
| 7 | bit [1:0] a, b; covergroup cg; coverpoint a; coverpoint b; x: cross a, b { illegal_bins bad = binsof(a) intersect {3} && binsof(b) intersect {0}; } endgroup cg c = new; | a = 3; b = 1; c.sample(); a = 0; b = 0; c.sample(); a = 3; b = 0; c.sample(); | graded |
| 8 | bit [3:0] v; covergroup cg; coverpoint v { bins lo = {[0:7]}; wildcard illegal_bins odd_hi = {4'b1??1}; } endgroup cg c = new; | v = 8; c.sample(); v = 10; c.sample(); v = 9; c.sample(); | graded |
The standard requires a run-time error at an illegal hit. The coverage build also stops the run there, so later samples never happen.
Examples
Example 1
No Illegal Value- Input
answer(0)
- Output
answer = 0
Neither 1 nor 2 is illegal, so the run reaches the end: answer 0.
Example 2
The Second Sample- Input
answer(1)
- Output
answer = 2
The first 3 is the second sample: answer 2. The coverage build stops there, so the third never happens.
Example 3
An Open Illegal Range- Input
answer(2)
- Output
answer = 2
[8:$] is 8 to 15 on 4 bits, so 9 is illegal: answer 2.
Constraints and Contract
- Return one value per question from answer(q).
- Keep the function header.
Hints
Hint 1
Does an illegal bin lose to another bin that holds the same value?
Hint 2
A coverpoint iff skips the whole sample, illegal bins included.
Hint 3
An illegal transition fires when the whole sequence completes, not at its first value.
What the grader checks: Nine constant answers: three worked examples and six graded questions. The keys follow IEEE 1800-2023 19.5.6 and 19.6.3, and each was measured on the coverage build, which agrees (tools/probes/cov-w1/measure-keys.mjs).
9 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 steps and the final capstone