Give the number each of seven covergroups reports when weights, goals and at_least differ.
Hardware context: Seven covergroups with different weights, goals and at_least options. Compute the number each covergroup reports.
Each row of the table is a small program: a covergroup instance c with options, and its samples. Each program ends by printing c.get_inst_coverage() times 100, rounded.
Write answer(q) so it returns that number, as IEEE 1800-2023 19.7 and 19.11 define it. Questions 0 to 2 are worked examples; 3 to 10 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] a, b; covergroup cg; ca: coverpoint a { bins one = {1}; bins two = {2}; } cb: coverpoint b { bins one = {1}; bins two = {2}; } endgroup cg c = new; | a = 1; c.sample(); a = 2; b = 0; c.sample(); | worked example |
| 1 | bit [1:0] a, b; covergroup cg; ca: coverpoint a { option.weight = 2; bins one = {1}; bins two = {2}; } cb: coverpoint b { bins one = {1}; bins two = {2}; } endgroup cg c = new; | a = 1; c.sample(); a = 2; b = 0; c.sample(); | worked example |
| 2 | bit [1:0] a, b; covergroup cg; ca: coverpoint a { bins one = {1}; bins two = {2}; } cb: coverpoint b { option.weight = 3; bins one = {1}; bins two = {2}; } endgroup cg c = new; | a = 1; b = 1; c.sample(); b = 2; c.sample(); | worked example |
| 3 | bit [1:0] a, b; covergroup cg; ca: coverpoint a { option.weight = 3; bins one = {1}; bins two = {2}; } cb: coverpoint b { bins one = {1}; bins two = {2}; } endgroup cg c = new; | b = 1; c.sample(); b = 2; c.sample(); | graded |
| 4 | bit [1:0] a, b; covergroup cg; ca: coverpoint a { bins one = {1}; bins two = {2}; } cb: coverpoint b { option.weight = 0; bins one = {1}; bins two = {2}; } endgroup cg c = new; | a = 1; c.sample(); | graded |
| 5 | bit [1:0] a, b; covergroup cg; option.goal = 80; ca: coverpoint a { bins one = {1}; bins two = {2}; } cb: coverpoint b { bins one = {1}; bins two = {2}; } endgroup cg c = new; | a = 1; b = 1; c.sample(); b = 2; c.sample(); | graded |
| 6 | bit a, b; covergroup cg; ca: coverpoint a; cb: coverpoint b; x: cross ca, cb { option.weight = 3; } endgroup cg c = new; | a = 0; b = 0; c.sample(); a = 1; b = 1; c.sample(); | graded |
| 7 | bit [1:0] a, b; covergroup cg; option.weight = 0; ca: coverpoint a { option.weight = 0; bins one = {1}; bins two = {2}; } cb: coverpoint b { option.weight = 0; bins one = {1}; bins two = {2}; } endgroup cg c = new; | a = 1; b = 1; c.sample(); | graded |
| 8 | bit [1:0] a; covergroup cg; t: coverpoint a { option.at_least = 3; bins one = {1}; bins two = {2}; bins three = {3}; } endgroup cg c = new; | a = 1; repeat (3) c.sample(); a = 2; repeat (2) c.sample(); a = 3; repeat (2) c.sample(); | graded |
| 9 | bit [1:0] a; covergroup cg; option.at_least = 2; t: coverpoint a { bins one = {1}; bins two = {2}; bins three = {3}; } endgroup cg c = new; | a = 1; c.sample(); c.sample(); a = 2; c.sample(); a = 3; c.sample(); c.sample(); | graded |
| 10 | covergroup cg with function sample(bit [1:0] a); option.per_instance = 0; coverpoint a { bins one = {1}; bins two = {2}; } endgroup cg c = new, y = new; | c.sample(1); y.sample(1); y.sample(2); | graded |
Question 9 sets at_least in the covergroup, where it is the default for every coverpoint. The coverage build ignores it there (lesson C23), so the key is the standard's number.
Examples
Example 1
Equal Weights- Input
answer(0)
- Output
answer = 5000
ca has both bins, cb none: (100 + 0) / 2 = 50.00%.
Example 2
A Heavier Coverpoint- Input
answer(1)
- Output
answer = 6667
(100 x 2 + 0 x 1) / 3 = 66.67%.
Example 3
Weights on Both Sides- Input
answer(2)
- Output
answer = 8750
(50 x 1 + 100 x 3) / 4 = 87.50%.
Constraints and Contract
- Return one value per question from answer(q).
- Keep the function header.
Hints
Hint 1
Weight each item's coverage and divide by the sum of the weights.
Hint 2
Does a goal ever change the number?
Hint 3
A bin with fewer hits than at_least is not covered.
What the grader checks: Eleven constant answers. Questions 3 to 8 and 10 were measured on the coverage build, which agrees with the standard. Question 9 is a standard key: the build ignores a covergroup-level at_least and prints 10000 (scenario cov-074 in docs/sva-standard-traces/CG.md).
11 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 3 steps and the final capstone