Coverage Collector Basics
Measure what your tests actually exercise by building a reusable UVM coverage collector for the FIFO environment.
Learning objectives
- Explain why passing tests do not necessarily mean sufficient verification.
- Distinguish functional coverage from code coverage.
- Build a reusable coverage collector using
uvm_subscriberand a SystemVerilog covergroup. - Create meaningful coverpoints and bins for FIFO behavior.
- Use cross coverage to measure combinations of behaviors.
- Interpret coverage results and identify missing stimulus.
- Understand why coverage measures should be derived from verification intent rather than added randomly.
Step 1: A passing test is not the finish line
In Lesson 57, you built a FIFO scoreboard that answered an important question:
“Was the behavior correct?”
Now ask a different question:
“What behavior did we actually exercise?”
Imagine this test:
WRITE A1
READ A1
PASS
The scoreboard correctly reports success.
But what has the test actually verified?
- It did not fill the FIFO.
- It did not drain the FIFO.
- It did not exercise the full condition.
- It did not exercise the empty condition.
- It did not exercise multiple entries.
- It did not test mixed traffic.
The test passed, but the verification space is still mostly unexplored.
Step 2: Understand functional coverage
Functional coverage measures whether behaviors defined by the verification plan have occurred.
For the FIFO, useful questions include:
| Coverage question | Example |
|---|---|
| Did we perform writes? | Write operation occurred. |
| Did we perform reads? | Read operation occurred. |
| Did we reach empty? | FIFO occupancy became zero. |
| Did we reach full? | FIFO occupancy reached its maximum. |
| Did we exercise mixed traffic? | Read and write behavior occurred across changing occupancy. |
| Did important combinations occur? | Read/write behavior crossed with FIFO state. |
Functional coverage is therefore closely connected to the verification plan.
Verification requirement
|
v
Coverage goal
|
v
Test stimulus
|
v
DUT behavior
|
v
Coverage result
|
v
Missing scenarios
Step 3: Functional coverage vs. code coverage
Do not confuse functional coverage with code coverage.
| Functional coverage | Code coverage |
|---|---|
| Measures planned behaviors. | Measures exercised implementation structures. |
| Defined by verification intent. | Collected from simulation activity by coverage tools. |
| Example: FIFO became full. | Example: a particular branch executed. |
| Answers “Did we test the behavior?” | Answers “Did execution reach this implementation?” |
A design can have high code coverage while still missing important functional scenarios. Conversely, functional coverage can identify a behavior that requires more targeted stimulus even when the corresponding RTL lines have already executed.
Step 4: Choose coverage points from the verification plan
Do not start by writing random covergroups and hoping the percentage looks good.
Start with the behaviors you care about.
For this FIFO lab, imagine the verification plan contains:
FIFO verification plan
|
+-- Write behavior
|
+-- Read behavior
|
+-- Empty state
|
+-- Full state
|
+-- Partial occupancy
|
+-- Read/write combinations
|
+-- Boundary transitions
These requirements can become coverage points.
A coverage model should answer a verification question, not merely count signals changing.
Step 5: Use a UVM subscriber as the collector
Lesson 45 introduced uvm_subscriber. It is a natural fit for a reusable coverage collector because it receives transactions through an analysis connection.
class fifo_coverage extends uvm_subscriber #(fifo_transaction);
`uvm_component_utils(fifo_coverage)
function new(string name = "fifo_coverage",
uvm_component parent = null);
super.new(name, parent);
endfunction
function void write(fifo_transaction t);
// Sample coverage here.
endfunction
endclass
The architecture becomes:
FIFO Monitor
|
| analysis_port.write(transaction)
|
+--------------------+
| |
v v
Scoreboard Coverage
| |
v v
Correctness Behavior measured
This is an important UVM pattern:
One observation can feed multiple independent verification consumers.
Step 6: Create a simple covergroup
SystemVerilog functional coverage is commonly described with covergroups, coverpoints, and bins.
A simple example:
covergroup fifo_cg;
cp_write : coverpoint write {
bins no_write = {0};
bins do_write = {1};
}
endgroup
The coverpoint divides the sampled values into bins.
write
|
+-- 0 -> no_write
|
+-- 1 -> do_write
When the covergroup samples a transaction, the appropriate bin is hit.
Coverage therefore becomes a record of which interesting values have actually occurred.
Step 7: Build a FIFO coverage model
For the lab, imagine that the observed transaction contains:
write
read
full
empty
wdata
rdata
A useful introductory coverage model can classify the FIFO's operation and state.
class fifo_coverage extends uvm_subscriber #(fifo_transaction);
`uvm_component_utils(fifo_coverage)
bit write;
bit read;
bit full;
bit empty;
bit [7:0] wdata;
covergroup fifo_cg;
cp_write : coverpoint write {
bins no_write = {0};
bins write_op = {1};
}
cp_read : coverpoint read {
bins no_read = {0};
bins read_op = {1};
}
cp_state : coverpoint {full, empty} {
bins normal = {2'b00};
bins full_state = {2'b10};
bins empty_state = {2'b01};
}
endgroup
function new(string name = "fifo_coverage",
uvm_component parent = null);
super.new(name, parent);
fifo_cg = new();
endfunction
function void write(fifo_transaction t);
write = t.write;
read = t.read;
full = t.full;
empty = t.empty;
wdata = t.wdata;
fifo_cg.sample();
endfunction
endclass
The collector receives an observed transaction, copies the relevant values into its sampling variables, and calls:
fifo_cg.sample();
That sampling point is important. Coverage only records a value when the covergroup is sampled.
Step 8: Understand bins
Bins define the categories that matter for a coverpoint.
For example:
cp_write : coverpoint write {
bins no_write = {0};
bins write_op = {1};
}
There are two possible bins:
+-------------------+
| write = 0 |
| no_write |
+-------------------+
+-------------------+
| write = 1 |
| write_op |
+-------------------+
For a small lab, explicit bins are useful because they make the coverage intent easy to understand.
Later, larger designs may use ranges, arrays of bins, wildcard bins, transition bins, or other more advanced coverage constructs.
Step 9: Cover FIFO states
The FIFO's full and empty signals are especially interesting because they represent boundary states.
A combined coverpoint can describe their legal combinations:
cp_state : coverpoint {full, empty} {
bins normal = {2'b00};
bins full_state = {2'b10};
bins empty_state = {2'b01};
}
The three intended states are:
full empty Meaning
0 0 FIFO contains some data but is neither full nor empty
1 0 FIFO is full
0 1 FIFO is empty
If your FIFO specification permits or represents full=1 and empty=1, that state should be modeled according to the specification rather than silently ignored.
Step 10: Add cross coverage
Individual coverage points tell you whether each behavior occurred. Cross coverage asks whether important behaviors occurred together.
For example:
cross cp_write, cp_read;
This asks whether the testbench exercised combinations such as:
| Write | Read | Meaning |
|---|---|---|
| 0 | 0 | Idle cycle |
| 1 | 0 | Write only |
| 0 | 1 | Read only |
| 1 | 1 | Simultaneous read/write |
Cross coverage can reveal a hole that individual coverpoints hide.
You may have 100% write coverage and 100% read coverage while never exercising simultaneous read/write.
Write coverage = 100%
Read coverage = 100%
But:
Write + Read simultaneously = NEVER
Therefore:
Important scenario still missing.
This is why coverage should measure meaningful combinations, not only isolated signals.
Step 11: Connect coverage to the monitor
The environment connects the monitor's analysis port to the coverage subscriber.
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
agent.monitor.analysis_port.connect(
scoreboard.analysis_imp
);
agent.monitor.analysis_port.connect(
coverage.analysis_export
);
endfunction
Now one observed transaction can be consumed by both components:
Monitor
|
analysis_port
|
+--------+--------+
| |
v v
Scoreboard Coverage
| |
v v
Is it correct? Did we exercise it?
The scoreboard and coverage collector should remain independent. One determines correctness; the other measures exercised behavior.
Step 12: Coverage does not create stimulus
A common beginner mistake is to think that adding a coverpoint somehow causes the DUT to exercise that behavior.
It does not.
Sequence
|
v
Stimulus
|
v
DUT
|
v
Monitor
|
v
Coverage
|
v
Measurement
Coverage is a measurement system. It observes what happened; it does not make it happen.
If the full_state bin is never hit, adding the bin does not solve the problem. You need stimulus capable of filling the FIFO.
Step 13: Use coverage to find missing tests
Imagine the coverage report shows:
Write operation 100%
Read operation 100%
Normal state 100%
Empty state 100%
Full state 0%
Simultaneous R/W 0%
This immediately tells you something useful.
Your tests perform reads and writes, but they do not reach the full condition or exercise simultaneous operations.
The next action should not be “change the coverage model until the percentage becomes 100%.”
The correct question is:
Are these missing scenarios required?
|
+--+--+
| |
YES NO
| |
v v
Add Document
stimulus why excluded
This is the beginning of coverage-driven verification.
Step 14: Coverage holes are not automatically bugs
A coverage bin that has never been hit is called a coverage hole.
But a hole can have several causes:
| Cause | Response |
|---|---|
| Missing stimulus | Add or modify a test/sequence. |
| Unreachable behavior | Investigate the design and constraints. |
| Incorrect coverage model | Fix the coverage definition. |
| Illegal scenario | Document or exclude it according to the verification plan. |
| Insufficient simulation | Run additional meaningful scenarios. |
Coverage analysis therefore requires engineering judgment.
Step 15: Coverage and the FIFO test plan
Connect the coverage model directly to the scenarios from Lesson 57.
| Test scenario | Expected coverage |
|---|---|
| Reset | Empty-state behavior. |
| Single write/read | Basic write/read bins. |
| Fill FIFO | Full-state bin. |
| Drain FIFO | Empty-state and read bins. |
| Mixed traffic | Multiple operation/state combinations. |
| Simultaneous read/write | Cross coverage for concurrent operations. |
Now coverage has a purpose: it tells you whether the verification plan has actually been exercised.
Step 16: Add meaningful data coverage
Data values can also be covered, but avoid creating thousands of meaningless bins without a reason.
For an 8-bit FIFO, interesting values might include:
00 minimum
01 small non-zero
7F lower boundary
80 upper-half boundary
FE near maximum
FF maximum
A simple coverpoint might be:
cp_wdata : coverpoint wdata {
bins zero = {8'h00};
bins low_values = {[8'h01:8'h0F]};
bins mid_values = {[8'h10:8'hEF]};
bins high_values = {[8'hF0:8'hFE]};
bins max_value = {8'hFF};
}
The exact bins should come from the design's meaningful behavior. If particular values have no verification significance, there may be little value in creating separate bins for them.
Step 17: Coverage is not checking
This distinction is worth repeating.
Scoreboard:
“Was the result correct?”
Coverage:
“Did this behavior occur?”
Consider a broken FIFO that returns the wrong value but still reaches every coverage bin.
The coverage can be excellent while the design is completely wrong.
Likewise, a perfectly correct FIFO may have poor coverage because the tests never fill it.
Correct? Exercised?
-------- ----------
Scoreboard YES -
Coverage - YES
You need both dimensions.
Step 18: Coverage should influence stimulus
Once coverage is available, use it to guide the next test.
Run tests
|
v
Review coverage
|
v
Find holes
|
v
Ask why they exist
|
v
Improve stimulus
|
v
Run again
|
v
Review coverage again
For example:
Coverage hole:
FIFO full state never reached
Possible response:
Generate DEPTH accepted writes
without intervening reads.
Another hole:
Coverage hole:
simultaneous read/write never exercised
Possible response:
Create a sequence that deliberately
requests both operations together.
This is the beginning of a coverage-driven stimulus loop.
Coverage lab challenge
Extend the FIFO environment from Lesson 57 with a reusable coverage collector.
- Create a
fifo_coverageclass extendinguvm_subscriber #(fifo_transaction). - Add coverpoints for read and write operations.
- Add coverage for empty, full, and normal FIFO states.
- Add cross coverage for read and write combinations.
- Add meaningful data-value bins.
- Connect the monitor's analysis port to both the scoreboard and coverage collector.
- Run the existing FIFO smoke test and inspect which bins are hit.
- Write additional directed sequences to hit missing bins.
- Document any intentionally unreachable or excluded scenarios.
Challenge: predict the holes first
Before running the simulation, look at your existing test and predict which bins will remain uncovered.
Existing test:
WRITE A1
WRITE B2
WRITE C3
READ
READ
READ
Predict:
Full state? ______
Empty state? ______
Write-only? ______
Read-only? ______
Simultaneous R/W? ______
Then run the test and compare your prediction with the coverage report.
Stretch challenge
Create a sequence specifically designed to reach the full-state bin and another designed to exercise simultaneous read/write behavior. Compare coverage before and after the new tests.
Common mistakes
| Mistake | Why it causes trouble | Better approach |
|---|---|---|
| Adding coverage without a verification plan | The model measures activity without telling you whether meaningful behavior was tested. | Derive coverage goals from requirements and scenarios. |
| Thinking coverage checks correctness | A broken DUT can still achieve high coverage. | Use coverage alongside scoreboards and assertions. |
| Expecting coverage to create stimulus | Coverage only measures sampled behavior. | Change sequences and tests to hit missing bins. |
| Sampling at the wrong time | Coverage can record values that do not represent valid transactions. | Sample complete, correctly reconstructed observations. |
| Creating too many meaningless bins | The coverage model becomes noisy and difficult to interpret. | Group values according to verification significance. |
| Ignoring cross coverage | Individual behaviors may be covered while important combinations are missing. | Cross only combinations that represent meaningful scenarios. |
| Changing bins to increase the percentage | The number becomes misleading. | Investigate the reason behind every important coverage hole. |
| Using coverage as the only success criterion | High coverage does not prove functional correctness. | Combine stimulus, checking, assertions, coverage, and debugging evidence. |
Key takeaways
- Scoreboard: Was the observed behavior correct?
- Coverage: What behavior did we actually exercise?
- Functional coverage should be derived from the verification plan.
uvm_subscriberprovides a reusable way to consume monitored transactions for coverage.- Coverpoints measure individual behaviors; bins classify meaningful values or states.
- Cross coverage measures important combinations of behaviors.
- A coverage hole is a question to investigate, not automatically a bug.
- Coverage should guide the next stimulus rather than merely produce a percentage.
- High coverage and correct behavior are complementary goals, not interchangeable ones.
Core mental model
Coverage turns the verification plan into measurable evidence.
Verification Plan
|
v
Coverage Model
|
v
Stimulus
|
v
DUT
|
v
Monitor
|
v
Coverage Sample
|
v
+----------------------+
| What did we hit? |
| What did we miss? |
+----------------------+
|
v
Better Stimulus
Think of the scoreboard and coverage collector as two different lenses looking at the same observed transaction stream.
Observed Transaction
|
+-------+-------+
| |
v v
Scoreboard Coverage
| |
v v
Correctness Exercise
| |
+-------+-------+
|
v
Verification Evidence
Passing checks tell you that something was correct. Coverage tells you what you actually exercised.
What comes next?
In Lesson 59, Debugging a Basic UVM Testbench, you will bring together the debugging techniques from the previous labs.
You will learn how to diagnose failures across the entire path:
Sequence
|
Sequencer
|
Driver
|
DUT
|
Monitor
|
Analysis
|
Scoreboard / Coverage
Coverage tells you what is missing. Debugging tells you why something went wrong.