C25.1 Type Options

MediumDebugIcarus · browser samples / server checksReview the topic

Give the type number, or the instance number, that seven programs print with type options for merging, weights, goals, distribution and strobing.

Hardware context: Covergroup types with merged instances, type weights, goals, distribution and strobing. Give the type number each set of type options produces.

Each row of the table is a small program with covergroup instances c and sometimes y. The last column gives the value it prints. Write answer(q) so it returns what IEEE 1800-2023 says the program prints.

Questions 0 to 2 are worked examples; 3 to 10 are graded only by the full check.

Signals in the Timeline

SignalWidthRole
question8input of each check
Full specification
qDeclarationsStatementsPrinted valueKind
0covergroup cg with function sample(bit [1:0] a); coverpoint a { bins one = {1}; bins two = {2}; } endgroup cg c = new, y = new;c.sample(1); y.sample(1); y.sample(2);int'($rtoi(cg::get_coverage() * 100.0 + 0.5))worked example
1covergroup cg with function sample(bit [1:0] a); type_option.merge_instances = 1; coverpoint a { bins one = {1}; bins two = {2}; } endgroup cg c = new, y = new;c.sample(1); y.sample(1);int'($rtoi(cg::get_coverage() * 100.0 + 0.5))worked example
2covergroup cg (int w) with function sample(bit [1:0] a); option.weight = w; coverpoint a { bins one = {1}; bins two = {2}; } endgroup cg c = new(1), y = new(3);c.sample(1); y.sample(1); y.sample(2);int'($rtoi(cg::get_coverage() * 100.0 + 0.5))worked example
3covergroup cg with function sample(bit [1:0] a); type_option.merge_instances = 1; coverpoint a { bins one = {1}; bins two = {2}; bins three = {3}; } endgroup cg c = new, y = new;c.sample(1); y.sample(3);int'($rtoi(cg::get_coverage() * 100.0 + 0.5))graded
4covergroup cg with function sample(bit [1:0] a, bit [1:0] b); type_option.merge_instances = 1; ca: coverpoint a { type_option.weight = 1; bins one = {1}; bins two = {2}; bins three = {3}; } cb: coverpoint b { type_option.weight = 4; bins one = {1}; } endgroup cg c = new;c.sample(1, 0);int'($rtoi(cg::get_coverage() * 100.0 + 0.5))graded
5covergroup cg with function sample(bit [1:0] a, bit [1:0] b); ca: coverpoint a { type_option.weight = 1; bins one = {1}; bins two = {2}; bins three = {3}; } cb: coverpoint b { type_option.weight = 4; bins one = {1}; } endgroup cg c = new;c.sample(1, 0);int'($rtoi(cg::get_coverage() * 100.0 + 0.5))graded
6covergroup cg with function sample(bit [1:0] a); type_option.goal = 50; coverpoint a { bins one = {1}; bins two = {2}; } endgroup cg c = new, y = new;c.sample(1);int'($rtoi(cg::get_coverage() * 100.0 + 0.5))graded
7bit [3:0] v; covergroup cg; type_option.distribute_first = 1; coverpoint v { bins q[2] = {[0:7]} with (item % 3 == 0); } endgroup cg c = new;v = 0; c.sample(); v = 3; c.sample();int'($rtoi(c.get_inst_coverage() * 100.0 + 0.5))graded
8bit [1:0] v; event e; covergroup cg @(e); type_option.strobe = 1; coverpoint v { bins one = {1}; bins two = {2}; bins three = {3}; } endgroup cg c = new;v = 1; ->e; #0 v = 2; ->e; #0 v = 3; ->e; #1;int'($rtoi(c.get_inst_coverage() * 100.0 + 0.5))graded
9bit v; covergroup cg; type_option.goal = 75; coverpoint v; endgroup cg c = new;v = 0;cg::type_option.goalgraded
10bit v; covergroup cg; type_option.comment = "link model"; coverpoint v; endgroup cg c = new;v = 0;cg::type_option.comment.len()graded

Questions 7, 8 and 9 use type options the coverage build ignores or misreads (lesson C25). Their keys are the standard's. Each program is its own simulation, so no other instance takes part in its type number.

Examples

Example 1

The Average of Instances
Input
answer(0)
Output
answer = 7500

(50 + 100) / 2 = 75.00%: 7500.

Example 2

A Union That Adds Nothing
Input
answer(1)
Output
answer = 5000

Both hit one; the union has 1 of 2 bins: 5000.

Example 3

Weighted Instances
Input
answer(2)
Output
answer = 8750

(50 x 1 + 100 x 3) / 4 = 87.50%: 8750.

Constraints and Contract

  • Return one value per question from answer(q).
  • Keep the function header.

Hints

Hint 1

Union or average: which does merge_instances choose?

Hint 2

When do coverpoint type weights take part?

Hint 3

Does a goal ever change a number? What does strobe do to two events in one step?

What the grader checks: Eleven constant answers. Questions 3 to 6 were measured on the coverage build, which agrees with the standard. Questions 7 to 10 are standard keys. The build ignores distribute_first (10000) and strobe (10000), and reads the goal as 0 and the comment as empty. See scenarios cov-085, cov-007b and cov-083 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 1 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

The Average of Instances

Input
answer(0)
Expected output
answer = 7500

(50 + 100) / 2 = 75.00%: 7500.

Run samples executes all 3 public checks. Check all tests runs 11 checks on the server.

Icarus · browser samples / server checks