← Design Verification Interviews

Interview Question · Concept

Weight, Goal and Minimum Hits

L1 JuniorL2 Mid-Levelfunctional coveragecoverage options

The Question

The interviewer asks

What do option.weight, option.goal and option.at_least change? Which of them change the number get_coverage() returns?

Reveal the Model Answer

at_least sets how many hits a bin needs to count as covered; the default is 1. weight sets how much a coverpoint or cross counts in the covergroup average; the default is 1, and 0 takes it out. goal is a target that reports compare against, 100 by default. So at_least and weight change the number, and goal does not.

From One Sample to the Covergroup TotalOne packet is sampled into two coverpoints and their cross. Each item scores its own percentage, and get_coverage() averages the items, each counted by its weight.
From one sample to the covergroup totalOne packet is sampled into two coverpoints and their cross. Each item scores its own percentage, and `get_coverage()` averages the items, each counted by its `weight`. call sample(p) one packet coverpoint cp_kind READ, WRITE,CONFIG coverpoint cp_len one, short_, long_ cross kind_x_len 3 x 3 = 9 cells exclusion ignore_binsconfig_multi CONFIG with short_or long_ result get_coverage() average of 3 items p.kindp.lenbin hitbin hitremoves 2 cells
Read the diagram as text
  • sample(p): one packet
  • cp_kind: READ, WRITE, CONFIG
  • cp_len: one, short_, long_
  • kind_x_len: 3 x 3 = 9 cells
  • ignore_bins config_multi: CONFIG with short_ or long_
  • get_coverage(): average of 3 items
  • sample(p) → cp_kind: p.kind
  • sample(p) → cp_len: p.len
  • cp_kind → kind_x_len: bin hit
  • cp_len → kind_x_len: bin hit
  • ignore_bins config_multi → kind_x_len: removes 2 cells
  • cp_kind → get_coverage()
  • kind_x_len → get_coverage()
  • cp_len → get_coverage()

With default weights each coverpoint and the cross count once. at_least decides when one bin counts as covered.

OptionDefaultWhat it changesChanges get_coverage()?
option.at_least1How many hits a bin needs before it counts as coveredYes
option.weight1How much a coverpoint or cross counts in the average; 0 takes it outYes
option.goal100The target that a report compares the number againstNo

Only the first two change the number itself.

Self-Check

Tick each key point you covered in your answer.

What Interviewers Listen For (Junior)

A good junior answer explains each option in one line. It then works out the covergroup number as the average of its coverpoints.

Cross-Questions

Where the interviewer goes next. Open a node to practise that follow-up.

WhyBreak ItCompareScale It

  1. Weight, Goal and Minimum Hits
  2. WhyWhy Ask for More Than One HitL1 JuniorL2 Mid-Level

    Why would you set at_least above 1? What does this coverpoint report?

    systemverilog
    module tb;
      bit [1:0] v;
      covergroup cg;
        cp: coverpoint v { bins b[] = {[0:1]}; option.at_least = 2; }
      endgroup
      cg c = new();
      initial begin
        v = 0; c.sample();
        v = 0; c.sample();     // bin b[0]: 2 hits
        v = 1; c.sample();     // bin b[1]: 1 hit, not enough
        $display("coverage=%0.2f with at_least=2", c.get_coverage());
      end
    endmodule
    
    Reveal the Model Answer

    It reports 50%, because b[1] has one hit and needs two. One hit shows a case happened once. It does not show the design handles it again, for example after it has already recovered once. Raise at_least for cases like error recovery or a full FIFO, where a second hit tests a different state. Don't raise it everywhere, or closure slows down for no gain.

    RUNVerilator (coverage build) · simulator service
    Edit the code, then run it
    Expected: coverage=50.00 with at_least=2

    Self-Check

    Tick each key point you covered in your answer.

    Wrong Altitude

    "Set at_least to 10 everywhere to be safe."

    Every bin then needs ten hits, and rare bins take ten times longer. Use it where repeats test something new.

    Source Spear & Tumbush, SystemVerilog for Verification (3rd ed.), §9.10.3 (PDF p394)

  3. Scale ItDifferent Targets for Different FeaturesL2 Mid-LevelL3 Senior

    The plan says error paths need at least 10 hits each, and normal traffic needs one. How do you express that in a large model?

    Reveal the Model Answer

    Put error paths in their own coverpoints or covergroup, with option.at_least = 10 set on those coverpoints. Keep normal traffic at the default. Then each covergroup maps to a line of the plan, and the report shows each feature against its own target. Don't encode the difference in weights, which only blurs one total.

    Self-Check

    Tick each key point you covered in your answer.

    Missed Corner

    "Set at_least = 10 once on the covergroup."

    That raises the bar for normal traffic too. Some tools also ignore the covergroup-level setting, including this site's coverage build.

    Source Spear & Tumbush, SystemVerilog for Verification (3rd ed.), §9.10.3 (PDF p394)

  4. CompareWeight Zero vs Deleting the CoverpointL1 Junior

    Compare setting option.weight = 0 on a coverpoint with deleting it.

    Reveal the Model Answer

    With weight 0, the coverpoint still collects data and appears in the report, but it adds nothing to the covergroup number. That suits diagnostic coverpoints, and coverpoints that exist only to build a cross. Deleting it loses the data, and any cross that uses it no longer compiles.

    option.weight = 0Coverpoint deleted
    Collects dataYesNo
    Shows in the reportYesNo
    Counts in the covergroup numberNoNo
    A cross can still use itYesNo: the cross no longer compiles

    Weight 0 keeps the data and the cross, and only drops the item from the total.

    Self-Check

    Tick each key point you covered in your answer.

    Misconception

    "Weight 0 also removes its crosses from the total."

    Weight is per coverpoint or cross. A cross built on a zero-weight coverpoint keeps its own weight of 1.

    Source Mehta, Introduction to SystemVerilog, Table 15.3 (PDF p614)

  5. Break ItWeights That Make the Number LieL2 Mid-LevelL3 Senior

    How can weights make a coverage number misleading?

    Reveal the Model Answer

    A large weight on an easy coverpoint pulls the total up early. The group then looks nearly done while a hard cross is empty. A zero weight on a hard cross hides it completely. Weights also behave differently between tools. Keep the default weights, and report hard items, such as key crosses, as their own numbers.

    Self-Check

    Tick each key point you covered in your answer.

    What Interviewers Listen For (Senior)

    A good senior answer treats any weight that is not the default as a review item. The plan must give a reason for it.

    Delivery

    "Weights let you show management the important progress."

    They change the arithmetic, not the testing. A tuned total is easy to misread and hard to compare between projects.

    Source Mehta, SystemVerilog Assertions and Functional Coverage (3rd ed.), §26.19 guidelines (PDF p477)

What People Get Wrong

Common wrong answers and why they fail. Run It shows the wrong belief failing on a real simulator.

Misconception

"A covergroup's number is the bins hit divided by all its bins."

It is the weighted average of its coverpoints and crosses. The twin hits 2 of 10 bins and reads 50%, not 20%.

Run It

One closed 2-bin coverpoint, one empty 8-bin coverpoint.

RUNVerilator (coverage build) · simulator service
Edit the code, then run it
Expected: coverage=50.00 with 2 of 10 bins hit FAIL: the covergroup averages its coverpoints (100 and 0), it does not count bins

Misconception

"Setting option.goal = 50 makes a half-covered group report 100%."

The goal only marks when reports call the group done. The twin sets it to 50 and still reads 50%.

Run It

Half the bins hit, with the goal set to 50.

RUNVerilator (coverage build) · simulator service
Edit the code, then run it
Expected: coverage=50.00 with goal=50 FAIL: option.goal does not change get_coverage(); it is a target for reports

Tool as Truth

"at_least set on the covergroup applies everywhere on every tool."

The standard allows it at covergroup level. This site's coverage build ignores the covergroup-level setting, so set it per coverpoint.

Source IEEE 1800-2017 §19.7; ASIC Point engine notes (Verilator master b8e7f1e coverage build)

Learn It, Then Prove It