Module 4: Coverage and Assertions | Intermediate UVM

Coverpoints and Bins

Turn planned functional behaviors into measurable coverage using SystemVerilog coverpoints and meaningful bins.

Learning objectives

  • Explain the relationship between a coverpoint, bins, and a coverage goal.
  • Create coverpoints for transaction fields and derived functional categories.
  • Define explicit bins, range bins, automatically generated bins, and transition bins.
  • Use ignore_bins and illegal_bins appropriately.
  • Understand how bin definitions affect the meaning of a coverage percentage.
  • Connect a covergroup to a UVM subscriber that samples monitored transactions.
  • Diagnose common coverage-modeling mistakes such as overly broad bins, meaningless bins, and incorrect sampling.
  • Prepare coverpoints that can later be combined with crosses in Lesson 33.

Step 1: Understand the relationship between coverpoints and bins

Lesson 31 established the coverage plan: first decide which functional behaviors matter, then decide how those behaviors should be measured.

In SystemVerilog, a coverpoint identifies a value or expression that should be measured. Bins divide the possible sampled values into categories that represent the coverage goals.

Functional requirement
    │
    ▼


Coverage dimension
│
▼
Coverpoint expression
│
▼
Bins
│
▼
Coverage result

For example, suppose a packet protocol supports four packet sizes: small, medium, large, and jumbo. The requirement is not "execute every possible value of size." The requirement is to exercise each meaningful size category.

coverpoint pkt.size {


bins small  = {64};
bins medium = {128};
bins large  = {512};
bins jumbo  = {1500};
}

Each bin represents a verification target. When a sampled transaction falls into a bin, that bin becomes covered.

Important: A coverpoint does not automatically know which values are important. The bin structure is part of the verification intent.

Step 2: Start with a simple coverpoint

Consider a transaction with a read/write field:

class packet extends uvm_sequence_item;


rand bit        write;
rand bit [31:0] addr;
rand bit [31:0] data;

// Other transaction fields...

endclass

A simple coverpoint can measure whether both operation types occurred:

covergroup packet_cg with function sample(packet pkt);


operation_cp: coverpoint pkt.write;

endgroup

For a two-state bit, SystemVerilog can automatically create bins for the values. However, relying on implicit behavior can hide the intended coverage plan. Explicit bins are often clearer when the categories have verification meaning.

operation_cp: coverpoint pkt.write {


bins read  = {0};
bins write = {1};
}

Now the coverage report communicates the intent directly: the environment wants to see both reads and writes.

Step 3: Create bins for value ranges

Many fields contain far more values than the verification plan needs to distinguish. For example, an address field may be 32 bits wide, but the specification may divide it into functional regions.

address_region_cp: coverpoint pkt.addr {


bins control = {[32'h0000_0000 : 32'h0000_00FF]};
bins status  = {[32'h0000_0100 : 32'h0000_01FF]};
bins data    = {[32'h0000_1000 : 32'h0000_1FFF]};
}

This is usually more useful than creating a separate bin for every address. The bins represent functional regions rather than raw implementation values.

Range bins are especially useful for:

  • address regions
  • packet sizes
  • burst lengths
  • FIFO occupancy levels
  • priority levels
  • latency categories

Step 4: Use bins for boundary conditions

Boundary values deserve deliberate attention because bugs frequently occur at limits.

Suppose a packet length is legal from 64 through 1500 bytes. A useful coverage model might distinguish the boundaries from the interior:

length_cp: coverpoint pkt.length {


bins minimum = {64};
bins near_min = {[65:127]};
bins typical = {[128:1499]};
bins maximum = {1500};
}

The exact categories should come from the specification and verification risk. The goal is not to make arbitrary numerical categories but to expose meaningful cases.

Coverage-design question: If a bin becomes covered, what verification claim does that let you make? If the answer is unclear, the bin may not represent a useful functional requirement.

Step 5: Understand automatically generated bins

SystemVerilog can automatically divide a coverpoint into bins when an explicit bin definition is not supplied or when options such as auto_bin_max are used.

covergroup packet_cg with function sample(packet pkt);


opcode_cp: coverpoint pkt.opcode;

endgroup

This can be useful for exploratory coverage or small value spaces, but it should not replace deliberate planning for important functional dimensions.

For example, a 4-bit opcode has only 16 possible values. Automatic bins may be reasonable during exploration. If the specification defines only six meaningful operation classes, however, explicit bins can communicate the verification intent more clearly.

Avoid assuming that "more bins" automatically means "better coverage." A coverage model with thousands of irrelevant bins can make coverage closure harder without improving verification quality.

Step 6: Exclude values with ignore_bins

Some values may be legal in the field but irrelevant to the functional coverage goal, or the coverage model may intentionally exclude values that are not part of the feature being measured.

opcode_cp: coverpoint pkt.opcode {


bins read  = {4'h1};
bins write = {4'h2};
bins flush = {4'h3};

ignore_bins reserved = {[4'h4 : 4'hF]};
}

An ignore_bins definition tells the coverage model not to count those sampled values toward the coverage goals of that coverpoint.

This should be used deliberately. If a reserved value can indicate a real design requirement or an important negative test, silently ignoring it can hide a verification gap.

Step 7: Distinguish ignore_bins from illegal_bins

ignore_bins and illegal_bins have very different purposes.

Construct Purpose Example use
ignore_bins Exclude values from coverage measurement Values intentionally outside the current coverage goal
illegal_bins Identify values that should never be sampled Protocol-invalid encodings

For example:

opcode_cp: coverpoint pkt.opcode {


bins read  = {4'h1};
bins write = {4'h2};

illegal_bins reserved = {[4'h0, 4'h3 : 4'hF]};
}

An illegal bin is not simply a convenient way to remove a value from the coverage denominator. Sampling an illegal value indicates behavior that deserves attention.

Step 8: Cover transitions when behavior over time matters

A normal value bin answers "Did this value occur?" A transition bin can answer "Did this value change in the required way?"

For example, suppose a protocol has a simple state field:

state_cp: coverpoint pkt.state {


bins idle   = {0};
bins active = {1};
bins error  = {2};

bins idle_to_active = (0 => 1);
bins active_to_idle = (1 => 0);
bins active_to_error = (1 => 2);
}

Transition coverage is useful when the sequence of observed values matters rather than merely whether each value occurred independently.

Typical applications include:

  • protocol state transitions
  • reset-to-active behavior
  • normal-to-error transitions
  • power-state transitions
  • mode changes

Transition coverage has sampling semantics that depend on consecutive samples of the coverpoint. Therefore, the sampling event must be chosen carefully.

Step 9: Build a reusable UVM coverage subscriber

A convenient UVM architecture is to make the coverage collector a uvm_subscriber. It receives transactions through its inherited analysis implementation and samples the covergroup.

class packet_coverage extends uvm_subscriber #(packet);


`uvm_component_utils(packet_coverage)

covergroup packet_cg with function sample(packet pkt);


operation_cp: coverpoint pkt.write {
  bins read  = {0};
  bins write = {1};
}

address_region_cp: coverpoint pkt.addr {
  bins control = {[32'h0000_0000 : 32'h0000_00FF]};
  bins status  = {[32'h0000_0100 : 32'h0000_01FF]};
  bins data    = {[32'h0000_1000 : 32'h0000_1FFF]};
}


endgroup

function new(string name = "packet_coverage",
uvm_component parent = null);
super.new(name, parent);
packet_cg = new();
endfunction

function void write(packet t);
packet_cg.sample(t);
endfunction

endclass

The data flow is straightforward:

Monitor


│
│ analysis_port.write(transaction)
▼
uvm_subscriber
│
▼
covergroup.sample(transaction)
│
▼
coverage bins

The monitor is often an appropriate source because it represents behavior observed at the DUT interface. The exact sampling architecture depends on the requirement and will be examined more deeply in Lesson 34.

Step 10: Connect the subscriber to the monitor

Suppose the agent's monitor exposes:

uvm_analysis_port #(packet) analysis_port;

The environment can connect it to the coverage subscriber:

function void connect_phase(uvm_phase phase);


super.connect_phase(phase);

env.agent.monitor.analysis_port.connect(
env.packet_cov.analysis_export
);
endfunction

Because an analysis port broadcasts transactions, the same observed transaction can also be delivered to the scoreboard, logger, and other analysis components.

                         ┌──► Scoreboard
                     │


Monitor ── analysis ─────┼──► Coverage
│
└──► Transaction logger

This reuses the TLM analysis architecture introduced earlier in the course. Coverage therefore does not need to interfere with the monitor or driver.

Step 11: Understand what the coverage percentage means

Suppose a coverpoint has four bins:

bins read   = {0};


bins write  = {1};
bins error  = {2};
bins retry  = {3};

If three bins have been hit, the coverpoint may report 75% coverage.

That percentage does not mean "75% of the DUT has been verified." It means that 75% of the defined bins for that coverage item have been hit, according to the simulator's coverage accounting rules.

This distinction is critical when interpreting coverage reports.

Think in claims, not percentages: "The error-response bin was hit" is a concrete statement. "Coverage is 83%" is only useful when you understand exactly what the 83% represents.

Step 12: Diagnose common bin-design mistakes

Mistake 1: Covering raw values instead of functional categories

A 32-bit address coverpoint with arbitrary automatically generated bins may produce a large amount of data without measuring the address regions that matter.

Mistake 2: Making every possible value a requirement

Not every legal value deserves its own bin. Group values according to functional meaning and verification risk.

Mistake 3: Ignoring required values

If a scenario is required but difficult to reach, do not hide it with ignore_bins. Investigate the stimulus and constraints instead.

Mistake 4: Using illegal_bins as a coverage filter

An illegal bin communicates that the sampled value is prohibited. It should not be used merely to improve a coverage percentage.

Mistake 5: Sampling the wrong transaction

Coverage of intended stimulus can differ from coverage of behavior actually accepted by the DUT. If the requirement is about accepted transfers, sample an observation that represents accepted transfers.

Mistake 6: Creating crosses too early

First make individual coverpoints meaningful. Lesson 33 will introduce crosses and explain how to select combinations deliberately.

Step 13: Debug an uncovered bin

When a bin remains at zero, do not immediately modify the coverage model. Investigate why the behavior was not observed.

Uncovered bin
 │
 ▼


Is the bin required?
│
┌───┴────┐
No       Yes
│         │
▼         ▼
Revise    Was the scenario generated?
model          │
┌────┴────┐
No        Yes
│          │
▼          ▼
Constraints   Was it accepted/observed?
/ stimulus          │
┌────┴────┐
No        Yes
│          │
▼          ▼
Protocol/   Sampling/
stimulus    coverage-model
issue       issue

This workflow connects coverage debugging to the diagnostic techniques from Lesson 30. A coverage hole is evidence that something needs to be understood, not merely a number that needs to be increased.

Exercise 1: Create meaningful bins

A transaction contains:

bit [1:0]  op;


bit [7:0]  length;
bit [31:0] addr;

The specification defines:

  • op=0 as read
  • op=1 as write
  • op=2 as flush
  • op=3 as reserved
  • lengths 1–16 as short
  • lengths 17–64 as medium
  • lengths 65–255 as long

Write coverpoints with meaningful bins for operation and length. Decide whether the reserved operation should be ignored or treated as illegal, and justify your choice.

Exercise 2: Boundary coverage

A protocol accepts packet lengths from 64 through 1500 bytes. Create bins that distinguish:

  • minimum legal value
  • values near the minimum
  • typical values
  • maximum legal value

Explain why the boundaries deserve explicit coverage rather than being buried inside one large range bin.

Exercise 3: Diagnose the coverage model

An engineer writes:

coverpoint packet.addr;

The resulting report contains many bins, but the verification plan specifically cares about control, status, data, and reserved address regions.

Explain why this model may be weak and rewrite the coverpoint using functional regions.

Exercise 4: Transition coverage

A protocol state machine has states:

IDLE


ACTIVE
ERROR

Create transition bins for:

  • IDLE → ACTIVE
  • ACTIVE → IDLE
  • ACTIVE → ERROR

Explain why simply covering the three state values does not prove that these transitions occurred.

Advanced challenge: Build a reusable coverage collector

Create a uvm_subscriber #(packet) that contains a covergroup with:

  1. explicit read/write operation bins
  2. three meaningful address-region bins
  3. length boundary bins
  4. an error-response bin
  5. at least one transition-oriented coverage item

Connect the subscriber to a monitor's analysis port. Run directed stimulus that intentionally hits each bin.

Then remove one scenario from the stimulus and verify that the corresponding bin becomes uncovered. Do not change the coverage model to compensate.

Finally, document the verification claim represented by each bin.

Knowledge check

  1. What is a coverpoint?
    A coverage item that samples a value or expression so that its occurrence can be measured.
  2. What do bins represent?
    Categories of sampled values or transitions that correspond to coverage targets.
  3. Why are explicit bins often preferable?
    They make the functional intent visible and allow the coverage model to distinguish meaningful categories rather than relying only on automatically generated bins.
  4. When are range bins useful?
    When many raw values have the same functional meaning, such as address regions, packet-size classes, or latency categories.
  5. What is the difference between ignore_bins and illegal_bins?
    Ignore bins exclude values from coverage measurement. Illegal bins identify values that should not occur and therefore deserve attention when sampled.
  6. Why might a raw 32-bit address coverpoint be a poor model?
    It can produce many low-value bins while failing to represent the functional address regions that matter to the verification plan.
  7. What does transition coverage measure?
    It measures whether specified sequences of sampled values or states occurred.
  8. Why can 100% coverpoint coverage still be insufficient?
    The bins may represent only a small or incomplete portion of the functional behavior. Coverage quality depends on the model, not only the percentage.

Connecting the module

Lesson 31 answered "What behavior should we measure?" Lesson 32 now answers "How do we divide that behavior into measurable coverage targets?"

Lesson 31


Functional Coverage Planning
│
│ requirements
▼
Lesson 32
Coverpoints and Bins
│
│ individual functional dimensions
▼
Lesson 33
Cross Coverage
│
│ meaningful combinations
▼
Lesson 34
Coverage Sampling Architecture
│
│ when and where to sample
▼
Lesson 35
Coverage Analysis
│
│ interpret results
▼
Lesson 36
Coverage Closure
│
│ close meaningful gaps
▼
Lessons 37–40
Assertions and Assertion Debugging

Keep the distinction clear:

  • Lesson 31: decide what matters.
  • Lesson 32: define measurable categories.
  • Lesson 33: measure meaningful combinations.
  • Lesson 34: determine the correct sampling architecture.

This separation prevents the coverage model from becoming a collection of syntax examples disconnected from the verification plan.

Key takeaways

  • A coverpoint identifies the functional value or expression being measured.
  • Bins divide that value space into verification-relevant categories.
  • Explicit bins make functional intent visible and are especially valuable for important requirements.
  • Range and boundary bins help represent meaningful classes without creating excessive raw-value coverage.
  • ignore_bins excludes values from coverage; illegal_bins identifies values that should not occur.
  • Transition bins measure behavior across successive samples rather than simply measuring individual values.
  • A UVM subscriber provides a clean way to receive monitored transactions and sample a covergroup.
  • Coverage percentages describe the defined bins; they do not directly measure overall DUT correctness.
  • When a bin is uncovered, investigate stimulus, constraints, protocol behavior, and sampling before modifying the model.
  • Meaningful individual coverpoints are the foundation for the cross-coverage work in Lesson 33.

Next lesson

In Lesson 33, you will combine individual coverage dimensions using cross coverage. You will learn how to identify meaningful combinations, control cross explosion, and distinguish useful scenario coverage from an enormous list of mathematically possible combinations.