Coverage closure cover: cross coverage stuck at 75% across seeds, closed by a targeted test and a waiver, measured on VCS

Functional Coverage Closure: A Practical Method, Tested on VCS

In short: Functional coverage closure is a loop. Measure coverage, list the empty bins, find out why each one is empty, then either fix the stimulus or waive the bin with a written reason. Repeat until nothing is left. In my run, five seeds all stopped at 75% cross coverage. One forgotten constraint was the cause, and a 20-item targeted test closed the hole.

Coverage closure is where a lot of verification schedules quietly slip. The number climbs fast for a week, then sits at 90-something and won’t move.

The usual reaction is to throw more seeds at it. I built a small UVM bench to show why that often does nothing, and what to do instead. Every number below comes from one run on VCS.

A simple way to picture it

Think of a building inspector with a checklist of rooms. Walking around at random, you’ll pass the lobby a hundred times. But if one door is locked, you’ll never get into that room, however long you walk.

More seeds is more walking. Closure means looking at the checklist, finding the rooms you never entered, and asking why. Sometimes the door is locked: you find the key and open it. Sometimes the room was knocked down in the new floor plan: you cross it off the list and write down why.

Functional coverage closure loop measured on VCS: measure, list holes, find the cause, target or waive, re-measure, from 75% to 100% cross coverage
The closure loop, with the numbers from one VCS run

The setup

The bench models a burst on a simple bus. Each item has an op (read or write), a len of 1, 2, 4, 8 or 16 beats, and an 8-bit addr aligned to its own size.

constraint c_op       { op dist {TAV_RD := 3, TAV_WR := 1}; }
constraint c_len      { len dist {1 := 40, 2 := 30, 4 := 20, 8 := 9, 16 := 1}; }
constraint c_align    { addr % len == 0; }
// Added "for now" while an RTL bug on long writes was open. Never removed.
constraint c_wr_short { op == TAV_WR -> len <= 8; }

That last constraint is the planted bug. It’s the kind of thing someone adds to get past a known RTL issue, meaning to delete it later.

The covergroup has coverpoints on op, len and addr, and a cross of op and len. cp_len also has a bin for 32 beats, which the old spec allowed and the new one dropped. That gives 12 cross bins in all.

Step 1: one seed, and a number that looks fine

[TAV_1] seed 1, 200 items: cg = 89.58%, cp_len = 83.33%, x_op_len = 75.00%
[TAV_1] 3 empty cross bins: TAV_RD x len32, TAV_WR x len16, TAV_WR x len32

The covergroup said 89.58%. That sounds close to done. But the cross, the part that says which combinations actually happened, was at 75%, with 3 of its 12 bins empty.

Why the gap? The covergroup number averages its parts: cp_op at 100%, cp_len at 83.33%, cp_addr at 100% and the cross at 75%. (100 + 83.33 + 100 + 75) / 4 = 89.58. The average hides the hole.

So the first habit of closure: never sign off on the top-level number. Look at the crosses, and list the empty bins by name.

Step 2: more seeds, same number

[TAV_2] seed 2 alone: cg = 89.58%
[TAV_2] seed 3 alone: cg = 89.58%
[TAV_2] seed 4 alone: cg = 89.58%
[TAV_2] seed 5 alone: cg = 89.58%
[TAV_2] merged, 5 seeds x 200 items: cg = 89.58%, x_op_len = 75.00%
[TAV_2] hits so far: WR x len16 = 0, RD x len16 = 5, WR x len8 = 16
[TAV_2] 3 empty cross bins: TAV_RD x len32, TAV_WR x len16, TAV_WR x len32

Five seeds, 1,000 items, and the merged number didn’t move. Every seed hit exactly the same bins.

The hit counts are the tell. Reads of 16 beats happened 5 times, and writes of 8 beats 16 times. So long bursts and writes both worked. Only the one combination, a write of 16 beats, never showed up.

When coverage stays flat across seeds, it’s not bad luck. Something is blocking that bin, and more seeds won’t fix it.

Step 3: find the cause, then target it

The fastest way to find a blocker is to ask the solver for the missing combination directly:

if (!it.randomize() with { op == TAV_WR; len == 16; })

It failed, and VCS printed exactly which constraints clashed:

constraint c_wr_short    // (from this) (constraint_mode = ON) (testbench.sv:28)
{
   (op == TAV_WR) -> (len <= 8);
}
constraint WITH_CONSTRAINT    // (from this) (constraint_mode = ON) (testbench.sv:188)
{
   (op == TAV_WR);
   (len == 16);
}

Error-[CNST-CIF] Constraints inconsistency failure
testbench.sv, 188
  Constraints are inconsistent and cannot be solved.

There’s the culprit, with its file and line: c_wr_short. I turned it off for the targeted test only, with it.c_wr_short.constraint_mode(0), and sent 20 writes of 16 beats.

[TAV_3] targeted: 20 items with op == WR, len == 16, addr of the last one = 240
[TAV_3] merged after targeted test: cg = 91.67%, x_op_len = 83.33%
[TAV_3] 2 empty cross bins: TAV_RD x len32, TAV_WR x len32

Twenty items did what 1,000 random ones couldn’t. The cross went from 75% to 83.33%, and only the two len32 bins are left.

Two cautions here. First, constraint_mode(0) in one test is a patch. The real fix is to find out if the RTL bug is fixed, then delete c_wr_short so every random test can make long writes. Second, a hit bin only proves the stimulus happened. It doesn’t prove the design handled it right. That’s the scoreboard’s job, so check the targeted test passed its checks, not just its coverage.

A trap in the log: the solver error isn’t a UVM error

Look at the UVM summary at the end of the same run:

UVM_ERROR :    0
UVM_FATAL :    0

Zero errors, even though VCS printed Error-[CNST-CIF] twice. The solver’s error comes from the simulator, not from UVM, so the UVM counters never see it.

If your regression script decides pass or fail from UVM_ERROR alone, a test whose randomization fails can still pass. In real tests, check the return value of randomize() and raise a uvm_error when it fails, and have the script grep for Error-[ too. In this bench the failures were on purpose, so I printed a uvm_info instead.

Step 4: a bin nothing can reach

What about len32? The same trick answers it:

constraint c_len    // (from this) (constraint_mode = ON) (testbench.sv:24)
{
   (len dist {1 := 40, 2 := 30, 4 := 20, 8 := 9, 16 := 1});
}
constraint WITH_CONSTRAINT    // (from this) (constraint_mode = ON) (testbench.sv:205)
{
   (len == 32);
}

The dist list doesn’t include 32, so len can never be 32. Unlike step 3, this isn’t a forgotten constraint. The new spec dropped 32-beat bursts, so the stimulus is right and the coverage model is out of date.

Step 5: waive it, with a reason

A bin that can’t be hit should leave the coverage model, with a written reason. In the waived version of the covergroup, the len32 bin becomes an ignore_bins:

ignore_bins b32_dropped = {32};   // waiver: removed from spec v2

I measured the same five seeds plus the targeted test against it:

[TAV_5] same traffic, len32 waived: cg = 100.00%, cp_len = 100.00%, x_op_len = 100.00%

The ignored value also dropped out of the cross, so both len32 cross bins went with it. Every number is now 100%, and every remaining bin was actually hit.

The rule for waivers: waive a bin because the spec says it can’t happen, never because it’s hard to hit. Each waiver should name its reason, like a spec version or section, and someone other than the author should review it.

The closure loop, in short

StepWhat you doWhat this run showed
1. MeasureRead the crosses, not just the top number89.58% overall hid a 75% cross
2. List holesName every empty bin3 empty bins, the same in all 5 seeds
3. Find the causeAsk the solver for the missing combinationVCS named c_wr_short, line 28
4. Target or fixA short targeted test, then fix the root cause20 items took the cross to 83.33%
5. Waiveignore_bins only for what the spec rules out, with a reason100% once len32 was waived

Coverage closure sign-off checklist

  • Every cross reviewed, with its empty bins listed by name.
  • Every empty bin either hit, or waived with a spec reference and a reviewer.
  • No stimulus constraint marked “temporary” still in the code.
  • Every targeted test passed its checks, not only its coverage.
  • The regression treats simulator errors such as Error-[CNST-CIF] as failures.
  • Code coverage reviewed too: functional coverage only measures what you thought to write down.

The bench: one file, one run

Everything above comes from one file, tav_cov_closure.sv: one UVM test with five steps, every number printed with `uvm_info. The covergroup samples each item the way a monitor would, so there’s no DUT.

On EDA Playground, paste it into testbench.sv, leave design.sv empty, pick UVM 1.2 and press Run (download it as a zip).

// tav_cov_closure.sv
// The Art of Verification: functional coverage closure, one loop, real numbers
// One UVM test, 5 steps. Every result is printed with `uvm_info.
// The covergroup samples each burst item, the way a monitor would.
// EDA Playground: paste into testbench.sv, leave design.sv empty,
// pick UVM 1.2 and press Run.

`include "uvm_macros.svh"
import uvm_pkg::*;

typedef enum bit {TAV_RD = 0, TAV_WR = 1} tav_op_e;

// ---------------------------------------------------------------
// The transaction: a burst on a simple bus
// ---------------------------------------------------------------
class tav_burst_item extends uvm_sequence_item;
  rand tav_op_e     op;
  rand int unsigned len;      // beats: 1, 2, 4, 8 or 16
  rand bit [7:0]    addr;     // word address

  // Reads are more common than writes, like most real traffic
  constraint c_op    { op dist {TAV_RD := 3, TAV_WR := 1}; }
  // Long bursts are rare
  constraint c_len   { len dist {1 := 40, 2 := 30, 4 := 20, 8 := 9, 16 := 1}; }
  // A burst must start on a boundary of its own size
  constraint c_align { addr % len == 0; }
  // Added "for now" while an RTL bug on long writes was open. Never removed.
  constraint c_wr_short { op == TAV_WR -> len <= 8; }

  `uvm_object_utils(tav_burst_item)
  function new(string name = "tav_burst_item");
    super.new(name);
  endfunction
endclass

// ---------------------------------------------------------------
// The coverage model
// ---------------------------------------------------------------
class tav_burst_cov;
  tav_op_e     op;
  int unsigned len;
  bit [7:0]    addr;

  covergroup cg;
    option.per_instance        = 1;
    type_option.merge_instances = 1;  // merged number = union of all seeds
    cp_op   : coverpoint op;
    cp_len  : coverpoint len {
      bins b1  = {1};
      bins b2  = {2};
      bins b4  = {4};
      bins b8  = {8};
      bins b16 = {16};
      bins b32 = {32};        // in the old spec; the new spec dropped it
    }
    cp_addr : coverpoint addr {
      bins low  = {[0:63]};
      bins mid  = {[64:191]};
      bins top  = {[192:255]};
    }
    x_op_len : cross cp_op, cp_len;
  endgroup

  function new(string name);
    cg = new();
    cg.set_inst_name(name);
  endfunction

  function void sample(tav_burst_item it);
    op = it.op; len = it.len; addr = it.addr;
    cg.sample();
  endfunction
endclass

// Same model with the dead bin waived, for step 5
class tav_burst_cov_waived;
  tav_op_e     op;
  int unsigned len;
  bit [7:0]    addr;

  covergroup cg;
    option.per_instance        = 1;
    type_option.merge_instances = 1;  // merged number = union of all seeds
    cp_op   : coverpoint op;
    cp_len  : coverpoint len {
      bins b1  = {1};
      bins b2  = {2};
      bins b4  = {4};
      bins b8  = {8};
      bins b16 = {16};
      ignore_bins b32_dropped = {32};   // waiver: removed from spec v2
    }
    cp_addr : coverpoint addr {
      bins low  = {[0:63]};
      bins mid  = {[64:191]};
      bins top  = {[192:255]};
    }
    x_op_len : cross cp_op, cp_len;
  endgroup

  function new(string name);
    cg = new();
    cg.set_inst_name(name);
  endfunction

  function void sample(tav_burst_item it);
    op = it.op; len = it.len; addr = it.addr;
    cg.sample();
  endfunction
endclass

// ---------------------------------------------------------------
// The test
// ---------------------------------------------------------------
class tav_cov_test extends uvm_test;
  `uvm_component_utils(tav_cov_test)

  int unsigned  hits[string];   // op x len hit counts, to list holes by name
  tav_burst_cov runs[$];

  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction

  function string key(tav_op_e op, int unsigned len);
    return $sformatf("%s x len%0d", op.name(), len);
  endfunction

  // Run n random items into one covergroup instance with a given seed
  function tav_burst_cov run_seed(int seed, int n);
    tav_burst_cov  cov = new($sformatf("seed_%0d", seed));
    tav_burst_item it  = tav_burst_item::type_id::create("it");
    it.srandom(seed);
    repeat (n) begin
      if (!it.randomize()) `uvm_error("TAV", "randomize failed")
      cov.sample(it);
      hits[key(it.op, it.len)]++;
    end
    return cov;
  endfunction

  function void print_holes(string tag);
    string list;
    int    n;
    for (int o = 0; o < 2; o++) begin
      int unsigned lens[] = '{1, 2, 4, 8, 16, 32};
      foreach (lens[j]) begin
        string k = key(tav_op_e'(o), lens[j]);
        if (!hits.exists(k)) begin
          list = {list, (n ? ", " : ""), k};
          n++;
        end
      end
    end
    `uvm_info(tag, $sformatf("%0d empty cross bins: %s", n, list), UVM_LOW)
  endfunction

  virtual task run_phase(uvm_phase phase);
    tav_burst_cov        tgt;
    tav_burst_cov_waived w;
    tav_burst_item       it;
    int unsigned         n16w;
    phase.raise_objection(this);

    // Step 1: one seed, 200 random items
    runs.push_back(run_seed(1, 200));
    `uvm_info("TAV_1", $sformatf("seed 1, 200 items: cg = %0.2f%%, cp_len = %0.2f%%, x_op_len = %0.2f%%",
              runs[0].cg.get_inst_coverage(), runs[0].cg.cp_len.get_inst_coverage(),
              runs[0].cg.x_op_len.get_inst_coverage()), UVM_LOW)
    print_holes("TAV_1");

    // Step 2: a small regression, 4 more seeds, then the merged number
    for (int s = 2; s <= 5; s++) begin
      runs.push_back(run_seed(s, 200));
      `uvm_info("TAV_2", $sformatf("seed %0d alone: cg = %0.2f%%", s, runs[$].cg.get_inst_coverage()), UVM_LOW)
    end
    `uvm_info("TAV_2", $sformatf("merged, 5 seeds x 200 items: cg = %0.2f%%, x_op_len = %0.2f%%",
              runs[0].cg.get_coverage(), runs[0].cg.x_op_len.get_coverage()), UVM_LOW)
    `uvm_info("TAV_2", $sformatf("hits so far: WR x len16 = %0d, RD x len16 = %0d, WR x len8 = %0d",
              hits.exists("TAV_WR x len16") ? hits["TAV_WR x len16"] : 0,
              hits.exists("TAV_RD x len16") ? hits["TAV_RD x len16"] : 0,
              hits.exists("TAV_WR x len8")  ? hits["TAV_WR x len8"]  : 0), UVM_LOW)
    print_holes("TAV_2");

    // Step 3: a targeted test for the hole, not more seeds
    tgt = new("targeted");
    it  = tav_burst_item::type_id::create("it");
    if (!it.randomize() with { op == TAV_WR; len == 16; })
      `uvm_info("TAV_3", "first try: randomize() with { op == WR; len == 16; } FAILED, a constraint blocks it", UVM_LOW)
    it.c_wr_short.constraint_mode(0);   // the culprit, found by reading the constraints
    `uvm_info("TAV_3", "c_wr_short turned off for this test only", UVM_LOW)
    repeat (20) begin
      if (!it.randomize() with { op == TAV_WR; len == 16; }) `uvm_error("TAV", "randomize failed")
      tgt.sample(it);
      hits[key(it.op, it.len)]++;
      n16w++;
    end
    `uvm_info("TAV_3", $sformatf("targeted: %0d items with op == WR, len == 16, addr of the last one = %0d",
              n16w, it.addr), UVM_LOW)
    `uvm_info("TAV_3", $sformatf("merged after targeted test: cg = %0.2f%%, x_op_len = %0.2f%%",
              runs[0].cg.get_coverage(), runs[0].cg.x_op_len.get_coverage()), UVM_LOW)
    print_holes("TAV_3");

    // Step 4: try to hit len32 with randomize; the constraint can't produce it
    if (!it.randomize() with { len == 32; })
      `uvm_info("TAV_4", "randomize() with { len == 32; } failed: len32 is unreachable by design", UVM_LOW)
    else
      `uvm_info("TAV_4", $sformatf("randomize() with { len == 32; } passed, len = %0d", it.len), UVM_LOW)

    // Step 5: waive the dead bin and re-measure the same traffic
    w = new("waived");
    for (int s = 1; s <= 5; s++) begin
      tav_burst_item wi = tav_burst_item::type_id::create("wi");
      wi.srandom(s);
      repeat (200) begin
        void'(wi.randomize());
        w.sample(wi);
      end
    end
    repeat (20) begin
      void'(it.randomize() with { op == TAV_WR; len == 16; });
      w.sample(it);
    end
    `uvm_info("TAV_5", $sformatf("same traffic, len32 waived: cg = %0.2f%%, cp_len = %0.2f%%, x_op_len = %0.2f%%",
              w.cg.get_inst_coverage(), w.cg.cp_len.get_inst_coverage(),
              w.cg.x_op_len.get_inst_coverage()), UVM_LOW)

    phase.drop_objection(this);
  endtask
endclass

module tb;
  initial run_test("tav_cov_test");
endmodule

What VCS printed

VCS X-2025.06-SP1 with UVM 1.2. The run finished with UVM_ERROR : 0 and UVM_WARNING : 0, plus the two Error-[CNST-CIF] solver messages from steps 3 and 4, which were on purpose. Every TAV line is shown in its step above, with the UVM_INFO testbench.sv(NN) @ 0: uvm_test_top prefix trimmed.

Common mistakes (and the fix for each)

1. Signing off on the covergroup number. In step 1, 89.58% hid 3 empty cross bins. Fix: review every cross and list its empty bins.

2. Adding seeds to a flat curve. In step 2, five seeds gave the same number. Fix: if coverage doesn’t move across seeds, look for a blocker.

3. Leaving a “temporary” constraint in. In step 3, c_wr_short hid a whole class of stimulus. Fix: tag temporary constraints with a ticket, and remove them when the ticket closes.

4. Trusting UVM_ERROR : 0. The solver errors never reached the UVM summary. Fix: check every randomize() return value, and grep for simulator errors too.

5. Waiving what’s hard instead of what’s impossible. Fix: waive only with a spec reason, and get the waiver reviewed.

6. Counting a hit bin as a pass. Fix: a bin says the stimulus happened. The scoreboard says the design got it right.

Where AI helps, and where it doesn’t

An AI assistant is useful at the boring end of closure. Give it a coverage report and your constraints, and it can suggest which constraint blocks a hole, or draft the inline constraint for a targeted test.

It can’t tell you whether a bin should be waived. That needs the spec and a person who understands it. I’d also never let it write waivers in bulk: a waiver nobody understood is just a hole with a label on it.

Practice challenge

Add a second planted blocker: constraint c_top_rd { addr >= 192 -> op == TAV_RD; }. Then add a cross of cp_op and cp_addr. Run five seeds, find the empty bin by name, and use the solver trick from step 3 to make VCS name the constraint.

FAQ

What is functional coverage closure? The loop of measuring functional coverage, listing the empty bins, finding why each is empty, and either fixing the stimulus or waiving the bin with a reason, until no unexplained holes remain.

Why doesn’t coverage go up with more seeds? If every seed misses the same bins, something blocks them, usually a constraint. In my run, five seeds all stopped at 75% cross coverage.

How do I find which constraint blocks a coverage bin? Call randomize() with the exact missing combination. If it fails, VCS prints the clashing constraints with file and line.

When should I use ignore_bins? When the spec rules a value out, like a burst length a new spec version dropped. Never just because a bin is hard to hit.

Why is the covergroup coverage higher than the cross coverage? The covergroup number averages its coverpoints and crosses. In my run, 100%, 83.33%, 100% and 75% averaged to 89.58%.

Does a constraint solver failure show up as a UVM_ERROR? No. VCS printed Error-[CNST-CIF] twice, and the UVM summary still showed UVM_ERROR : 0.

References

  • IEEE 1800-2023, SystemVerilog standard: clause 19 (functional coverage, including coverage options and ignore_bins) and clause 18 (constrained random, including constraint_mode() and inline constraints).
  • Accellera, Universal Verification Methodology (UVM) 1.2 class reference.

Keep learning

If covergroups are new to you, start with functional coverage in SystemVerilog, then the coverage options and types of coverage metrics.

For the stimulus side, read rand_mode vs constraint_mode, weighted distribution and why SystemVerilog randomization fails. Closure starts long before the regression, in the verification plan.

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *