Module 4: Coverage and Assertions | Intermediate UVM

Coverage Sampling Architecture

Learn how to choose the right source, event, and architectural boundary for functional coverage so that coverage reflects meaningful DUT behavior.

Learning objectives

  • Explain why the sampling point is part of a functional coverage model.
  • Distinguish sequence intent from behavior actually observed at the DUT interface.
  • Choose between transaction-level and signal-level sampling for a requirement.
  • Build a reusable UVM coverage subscriber using transaction-level sampling.
  • Identify when a derived event or explicit sampling trigger is more appropriate than sampling every transaction.
  • Prevent duplicate, premature, and incorrectly timed coverage samples.
  • Handle reset and protocol acceptance boundaries correctly.
  • Debug suspicious coverage by tracing the path from DUT behavior to the coverage collector.

Step 1: Coverage is defined by both "what" and "when"

Lessons 31–33 focused primarily on what to measure:

  • requirements and coverage dimensions,
  • coverpoints and bins,
  • cross coverage and meaningful combinations.

This lesson focuses on a different question:

When should the coverage model sample the behavior?

The same coverpoint can produce very different results depending on where and when it is sampled.

For example, suppose a sequence attempts to generate a write:

Sequence intent
  |
  v


Driver places request
|
v
DUT sees valid
|
v
DUT accepts transfer
|
v
Monitor reconstructs transaction
|
v
Coverage samples

These are not necessarily the same event.

If the requirement is "a write accepted by the DUT", sampling the sequence item when the sequence creates it may measure intent, not actual DUT behavior.

Sampling the monitor transaction at the accepted-transfer boundary is usually a much better representation of that requirement.

Step 2: Separate stimulus intent from observed behavior

A sequence knows what it attempted to do. A monitor knows what it observed at the interface.

Consider a ready/valid-style interface:

valid = 1


ready = 0

// Request is presented but not accepted.

If coverage samples every sequence item, it may count the transaction even though the DUT did not accept it.

The protocol acceptance condition might instead be:

accept = valid && ready;

A monitor can wait for that condition and publish one transaction representing the accepted transfer.

The architectural distinction is:

Source What it represents Typical coverage use
Sequence Stimulus intent Useful for scenario-generation metrics or stimulus-specific analysis
Driver What the testbench attempted to drive Occasionally useful, but can still differ from accepted DUT behavior
Monitor Observed interface transaction Common choice for functional coverage of DUT behavior
Scoreboard/reference model Predicted or checked behavior Useful for coverage of derived results or checking-specific scenarios
Signals/clocking event Cycle-level behavior Useful when the requirement is inherently temporal or signal-based

There is no universal rule that the monitor must always be the sampling source. The correct source depends on the requirement being measured.

Step 3: Choose the sampling boundary from the requirement

Start with the requirement, then determine the event that makes the requirement true.

Requirement Likely sampling boundary
Every accepted bus transfer uses each operation type Monitor transaction at transfer acceptance
Every response class occurs Monitor response transaction
Each mode transition occurs State transition event
A signal remains stable while stalled Cycle-level sampling or assertion
Latency falls into each required range Completed transaction with measured latency
A command is eventually followed by a completion Derived transaction/correlation event

This is an architectural decision, not merely a syntax decision.

Rule: Define the event that makes the requirement true before deciding where to call sample().

Step 4: Transaction-level sampling with a UVM subscriber

For many protocol-oriented environments, a reusable coverage collector can subscribe to the monitor's analysis stream.

class packet_coverage extends uvm_subscriber #(packet);

`uvm_component_utils(packet_coverage)

covergroup packet_cg with function sample(packet item);

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

    region_cp: coverpoint item.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]};
    }

    operation_x_region:
        cross operation_cp, region_cp;

endgroup

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

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


endclass

The environment can connect the monitor to the coverage subscriber:

function void connect_phase(uvm_phase phase);
super.connect_phase(phase);

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


endfunction

The resulting data flow is:

                    +------------------+
                |    Scoreboard     |
                +------------------+
                         ^
                         |
                         |


Monitor ---- analysis_port -+-----> Coverage subscriber
|
v
sample(packet)
|
v
+------------------+
| Coverpoints      |
| Crosses           |
+------------------+

This design is attractive because the monitor publishes one transaction and multiple analysis consumers can independently use it.

Step 5: Do not confuse "transaction received" with "transaction accepted"

Even a monitor-based architecture requires careful transaction boundaries.

Suppose a monitor creates a transaction as soon as valid becomes high:

cycle 1: valid=1 ready=0


cycle 2: valid=1 ready=0
cycle 3: valid=1 ready=1 

The request was only accepted in cycle 3.

If the monitor publishes a transaction in cycle 1, downstream coverage may count behavior that the DUT never accepted.

A better monitor architecture reconstructs the transaction according to the protocol's actual acceptance rule.

if (valid && ready) begin
item = packet::type_id::create("item");
item.addr  = addr;
item.write = write;
item.data  = data;

analysis_port.write(item);


end

The exact implementation depends on the protocol, but the principle is general:

The monitor should publish the transaction at the semantic boundary that the coverage requirement describes.

Step 6: When signal-level sampling is appropriate

Transaction-level coverage is not always the correct solution.

Some requirements are inherently about cycles or signal relationships.

For example:

Requirement:


"When the interface is stalled, the payload must remain stable."

This is naturally expressed as a temporal property rather than a transaction coverpoint.

assert property (
@(posedge clk)
valid && !ready |=> $stable(data)


);

Coverage can still be useful for measuring whether stall scenarios occurred, but the correctness rule itself belongs to an assertion.

This gives an important architectural separation:

Cycle-level temporal rule
    |
    +----> Assertion


Transaction scenario occurred
|
+----> Functional coverage

Transaction result was correct
|
+----> Scoreboard

Do not force a covergroup to perform a job better handled by an assertion or scoreboard.

Step 7: Derived sampling events

Some requirements cannot be represented accurately by simply sampling every monitor transaction.

Consider a latency requirement:

Request accepted
   |
   |  7 cycles
   v


Response accepted

A useful coverage dimension might be:

latency:
1-4 cycles
5-8 cycles
9-16 cycles
above 16 cycles

The latency is only known when the response occurs. The coverage sample therefore needs information derived from both events.

A collector might receive a completed transaction containing the measured latency:

class response_coverage extends uvm_subscriber #(response_packet);

`uvm_component_utils(response_coverage)

covergroup response_cg with function sample(response_packet item);

    latency_cp: coverpoint item.latency {
        bins short  = {[1:4]};
        bins medium = {[5:8]};
        bins long   = {[9:16]};
        bins very_long = {[17:1000]};
    }

endgroup

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

function void write(response_packet item);
    response_cg.sample(item);
endfunction


endclass

The coverage collector does not need to calculate the latency itself if another component already owns that responsibility.

This follows a useful architecture:

Monitor request
  |
  v


Latency tracker / predictor
|
+---- request timestamp
|
+---- response timestamp
|
v
Completed transaction
|
v
Coverage subscriber
|
v
Latency bins

Keep derived information close to the component that has the knowledge needed to calculate it, then publish a meaningful transaction for downstream consumers.

Step 8: Avoid duplicate sampling

A common architectural bug is sampling the same logical event more than once.

For example:

Monitor writes transaction
   |
   +--> Coverage samples


Scoreboard receives transaction
|
+--> Coverage samples again

The coverage database may now count the same transaction twice.

Another example occurs when a monitor emits an intermediate transaction and later emits a completed version of the same transaction.

Before adding a coverage connection, ask:

  1. What exactly does one sample represent?
  2. Which component owns the event?
  3. Can the same logical event arrive through another path?
  4. Does the transaction represent an attempt, acceptance, completion, or derived result?
Debugging clue: Unexpectedly high coverage can be just as suspicious as low coverage. If a rare bin reaches 100% immediately, investigate whether the model is sampling the intended event exactly once.

Step 9: Handle reset explicitly

Reset changes the meaning of many transactions and coverage scenarios.

Suppose an outstanding transaction exists when reset occurs:

Request ID 17 accepted
    |
    | outstanding
    |
    +---- RESET ----+
                   |
                   v
             DUT state cleared

If a coverage collector later samples a response associated with the pre-reset operation, the environment needs a defined policy.

Depending on the specification, reset may:

  • cancel the transaction,
  • complete it with a defined error response,
  • allow it to survive reset, or
  • start a new verification epoch.

The coverage architecture should follow that policy.

For simple transaction coverage, this may mean sampling only transactions that the monitor considers valid after reset. For more advanced coverage, the transaction may include an epoch or reset-state field.

class packet extends uvm_sequence_item;

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

bit [15:0]      reset_epoch;

// ...


endclass

The exact reset strategy depends on the environment, but the key question is always:

Does this sampled transaction belong to the same functional state as the coverage requirement?

Step 10: Sampling architecture for multiple consumers

A reusable UVM environment should avoid putting coverage-specific behavior inside the monitor when a separate subscriber is sufficient.

Prefer:

                         +--> Scoreboard
                     |


Monitor -- analysis_port +--> Coverage
|
+--> Transaction recorder
|
+--> Protocol statistics

over tightly coupling the monitor to every consumer:

Monitor


|
+--> explicitly calls scoreboard code
+--> explicitly calls coverage code
+--> explicitly calls logger code
+--> explicitly calls statistics code

The analysis-port architecture allows the monitor to remain focused on reconstructing protocol behavior while subscribers decide how to consume the transaction.

This becomes especially valuable when an agent is reused in another environment.

Step 11: Sampling architecture for different requirements

A mature environment may use several sampling architectures simultaneously.

Coverage requirement Sampling source Reason
Operation type accepted Protocol monitor transaction Represents actual accepted behavior
Address region × operation Monitor transaction Both dimensions exist in one accepted transaction
Response latency Completed/derived response transaction Latency is known only after completion
Mode transition State-transition event The transition itself is the coverage event
Protocol stall occurrence Cycle/event sampling Stall is a signal-level condition
Attempted scenario generation Sequence or test layer Measures stimulus intent rather than DUT acceptance

There is no requirement that every coverage model in a UVM environment use the same sampling source.

Step 12: Debug suspicious coverage

Coverage debugging should follow the data path just as scoreboard debugging follows the transaction path.

For a monitor-based collector:

Coverage result
  |
  v


Was the bin sampled?
|
v
Was sample() called?
|
v
Was the correct transaction supplied?
|
v
Was the transaction reconstructed correctly?
|
v
Was the protocol event accepted?
|
v
Did the DUT actually exhibit the required behavior?

For suspiciously high coverage, ask:

  • Is the same transaction sampled more than once?
  • Are invalid/intermediate transactions being sampled?
  • Are bins too broad?
  • Is the sampling source measuring stimulus intent instead of DUT behavior?

For suspiciously low coverage, ask:

  • Is the transaction ever published?
  • Is sample() being called?
  • Is the acceptance boundary correct?
  • Are constraints preventing the scenario?
  • Is the monitor dropping or misclassifying transactions?
  • Is reset preventing the intended event from being sampled?
  • Does the coverage model correctly represent the requirement?

Common mistakes

Sampling sequence items instead of accepted DUT behavior

A sequence item represents intended stimulus. If the requirement concerns behavior accepted by the DUT, use an appropriate monitor or protocol event as the sampling source.

Sampling before the transaction is complete

Do not sample a transaction before all fields needed by the coverage model are valid and the protocol event has occurred.

Sampling every cycle when one transaction is enough

Repeated cycle-level sampling can distort transaction-oriented coverage. Match the sampling frequency to the requirement.

Sampling the same logical event twice

Multiple analysis connections are useful, but a coverage collector should have a clear definition of one sample and one authoritative event source.

Using functional coverage for temporal correctness

Coverage can measure that a stall or transition occurred. An assertion is usually better for proving that a signal obeyed a temporal rule during that event.

Ignoring reset semantics

Reset can cancel, restart, or transform transactions. The coverage model must sample according to the same functional interpretation used by the rest of the environment.

Exercise 1: Choose the sampling boundary

For each requirement, choose the most appropriate sampling source:

  1. Every read accepted by an APB-like interface.
  2. Every write attempted by a test sequence.
  3. Every response returned by the DUT.
  4. Every cycle in which a ready/valid interface is stalled.
  5. Every completed transaction with latency between 5 and 10 cycles.
  6. Every transition from IDLE to BUSY.

For each answer, explain why the chosen event represents the requirement.

Exercise 2: Find the sampling bug

A testbench reports 100% coverage for writes to the status region after a single short test.

Investigation shows:

Sequence:
Generates 100 write transactions


Driver:
Drives transactions onto the interface

Monitor:
Publishes a transaction whenever valid == 1

DUT:
Can hold ready == 0 for several cycles

Answer:

  1. What is the likely sampling problem?
  2. What event should the monitor use for accepted-transfer coverage?
  3. What evidence would you inspect to prove the fix?

Exercise 3: Prevent duplicate samples

Design a coverage architecture where the same monitor transaction is consumed by:

  • a scoreboard,
  • a functional coverage subscriber, and
  • a transaction logger.

Draw the analysis connections and explain why the transaction should be sampled exactly once by the coverage subscriber even though it has multiple consumers.

Exercise 4: Derived coverage

You need coverage for these latency categories:

1-4 cycles


5-8 cycles
9-16 cycles
17+ cycles

The request and response can be out of order.

Design the data flow that allows the coverage collector to receive a completed transaction containing the correct latency.

Do not put the correlation algorithm inside the coverage model unless there is a strong architectural reason to do so.

Challenge: Design a reusable sampling architecture

Choose a protocol such as APB, UART, SPI, AXI-Lite, or a FIFO interface.

Create a coverage architecture containing:

  1. One monitor-defined transaction coverage model.
  2. One cross based on fields of the observed transaction.
  3. One coverage model whose information is derived from more than one protocol event.
  4. One cycle-level requirement that should not be implemented as ordinary transaction coverage.
  5. A reset policy for outstanding or partially reconstructed transactions.
  6. A diagram showing exactly where each coverage model samples.

For every coverage model, complete this sentence:

"One coverage sample represents __________________."

If that sentence is ambiguous, the sampling architecture probably needs more work.

Knowledge check

  1. Why is the sampling event part of the functional coverage definition?
  2. What is the difference between sequence intent and observed DUT behavior?
  3. Why is a monitor often a useful source for transaction-oriented coverage?
  4. When might signal-level sampling be more appropriate than transaction-level sampling?
  5. Why should a ready/valid transaction generally be sampled at the acceptance event rather than when valid first becomes high?
  6. How can duplicate sampling produce misleading coverage?
  7. Why might latency coverage require a derived transaction rather than direct monitor sampling?
  8. How should reset affect the interpretation of sampled transactions?
  9. What evidence would you inspect if coverage is unexpectedly high after very little stimulus?
  10. What is the difference between measuring that a stall occurred and proving that signals remained stable during the stall?
Self-check: You understand this lesson when you can look at a coverage requirement and identify the exact event that makes the requirement true, the component that can observe that event reliably, and the transaction or data that should be passed to sample().

Key takeaways

  • Coverage quality depends on both the dimensions being measured and the event at which they are sampled.
  • Sequence items describe stimulus intent; monitor transactions commonly represent behavior actually observed at the DUT interface.
  • Choose the sampling boundary from the verification requirement, not from whichever signal or component is easiest to access.
  • Transaction-level sampling works well for protocol scenarios, while cycle-level requirements may need signal-based sampling or assertions.
  • Derived coverage information, such as latency, may require a separate component to correlate or calculate the data before coverage samples it.
  • Every coverage sample should have a clear semantic meaning and should normally represent one logical event.
  • Duplicate, premature, or incorrectly timed samples can produce misleadingly high or low coverage.
  • Reset behavior must be reflected consistently in the sampling architecture.
  • Reusable UVM agents benefit from publishing observed transactions through analysis ports and keeping coverage consumers separate from the monitor.

What comes next

Lesson 35: Coverage Analysis moves from building the coverage model to interpreting the results.

You now know how to define coverage dimensions, build bins and crosses, and choose a sampling architecture that represents meaningful DUT behavior. The next step is learning how to read coverage results critically: distinguish real holes from unreachable scenarios, identify weak coverage models, investigate suspicious bins, and decide what action should follow an uncovered requirement.

The goal is not to make the percentage larger. The goal is to determine whether the coverage data provides convincing evidence that the intended verification space has actually been exercised.