Reusable Verification Components
Design UVM components that can move between environments without carrying project-specific assumptions with them.
Learning objectives
- Identify which parts of a UVM environment are good candidates for reuse.
- Distinguish reusable agents, checkers, predictors, subscribers, and utility components.
- Design component interfaces around transactions and configuration rather than parent-environment internals.
- Reuse the same verification component in more than one environment.
- Recognize common coupling patterns that make a component difficult to reuse.
- Debug reuse problems involving configuration, TLM connections, factory construction, and assumptions about hierarchy.
Why reusable components matter
By this point, you have built individual agents and learned how environments can be layered. The next production skill is recognizing which verification behavior should become a reusable component instead of being rewritten for every project.
A reusable component is not simply a UVM class that happens to compile. It has a stable interface, explicit configuration, well-defined transaction semantics, and few assumptions about the environment in which it is instantiated.
Step 1: Identify the reusable unit
Different UVM components are reusable in different ways. Start by identifying the responsibility, not the class name.
| Component | Typical responsibility | Good reuse boundary |
|---|---|---|
| Agent | Drive and/or monitor one protocol | Protocol transaction + configuration |
| Predictor | Generate expected transactions | Input transaction + model/configuration |
| Scoreboard | Compare expected and actual behavior | Expected/actual transaction interfaces |
| Subscriber | Consume transactions for coverage or analysis | Analysis transaction type |
| Checker | Detect a specific protocol or functional violation | Observed transaction/event interface |
| Utility component | Provide reusable infrastructure or services | Explicit API and configuration |
Reuse is strongest when the component owns one recognizable responsibility. A scoreboard that also reaches into a driver, controls sequences, and reads arbitrary DUT signals is much harder to reuse than a scoreboard that consumes well-defined expected and actual transactions.
Step 2: Start with the component boundary
Consider a reusable checker that verifies that an interrupt is generated after a qualifying bus transaction. It should not depend directly on a particular environment hierarchy.
class interrupt_checker extends uvm_component;
`uvm_component_utils(interrupt_checker)
uvm_analysis_imp_bus #(bus_item, interrupt_checker) bus_imp;
uvm_analysis_imp_irq #(irq_item, interrupt_checker) irq_imp;
bit enable_check = 1;
function new(string name, uvm_component parent);
super.new(name, parent);
bus_imp = new("bus_imp", this);
irq_imp = new("irq_imp", this);
endfunction
function void write_bus(bus_item item);
if (enable_check) begin
// Save or evaluate the bus transaction.
end
endfunction
function void write_irq(irq_item item);
if (enable_check) begin
// Correlate the observed interrupt with
// previously observed bus activity.
end
endfunction
endclass
The important feature is not the empty checking algorithm. It is the boundary:
the checker consumes typed transaction streams rather than reaching into
bus_agent.driver, irq_agent.monitor, or some project-specific
environment variable.
Because the checker has two differently typed analysis inputs, the example uses distinct
analysis implementation declarations. This avoids pretending that two ordinary
uvm_analysis_imp instances can portably distinguish overloaded
write() methods by transaction type alone.
`uvm_analysis_imp_decl(_bus)
`uvm_analysis_imp_decl(_irq)
The result is a component that can be connected to whatever bus and interrupt agents exist in the current environment, provided they publish the documented transaction types.
Step 3: Keep environment-specific decisions outside the component
A reusable component should not silently assume the hierarchy of the project that originally created it.
Fragile design:
class bad_checker extends uvm_component;
function void check();
// Project-specific hierarchy assumption.
if (uvm_test_top.env.bus_agent.driver.last_item.data == 32'hDEAD_BEEF)
`uvm_error("CHK", "Unexpected value")
endfunction
endclass
This component is coupled to a particular testbench structure and even to the internal state of a driver. Reusing it requires recreating those internals or modifying the checker.
Better design:
class good_checker extends uvm_component;
`uvm_component_utils(good_checker)
uvm_analysis_imp #(bus_item, good_checker) bus_imp;
function new(string name, uvm_component parent);
super.new(name, parent);
bus_imp = new("bus_imp", this);
endfunction
function void write(bus_item item);
if (item.data == 32'hDEAD_BEEF)
`uvm_error("CHK", "Unexpected bus value")
endfunction
endclass
Now the checker depends on the transaction contract rather than on how the agent happens to implement stimulus generation.
Step 4: Make configuration explicit
Reusable components frequently need policy choices. Do not encode every variation as a new subclass or hard-code it into the implementation.
class interrupt_checker_cfg extends uvm_object;
`uvm_object_utils(interrupt_checker_cfg)
bit enable_check = 1;
int unsigned max_latency_cycles = 10;
bit allow_spurious_interrupt = 0;
function new(string name = "interrupt_checker_cfg");
super.new(name);
endfunction
function bit is_valid();
return (max_latency_cycles > 0);
endfunction
endclass
The checker can receive this object through uvm_config_db and validate it
during build_phase.
function void build_phase(uvm_phase phase);
super.build_phase(phase);
if (!uvm_config_db#(interrupt_checker_cfg)::get(
this, "", "cfg", cfg
)) begin
`uvm_fatal("CFG", "interrupt_checker_cfg was not provided")
end
if (!cfg.is_valid())
`uvm_fatal("CFG", "Invalid interrupt checker configuration")
endfunction
This separates component implementation from verification policy. One environment can enable the checker while another can configure different latency limits without maintaining separate checker implementations.
Step 5: Connect the component at the environment layer
The environment that owns the relationships between interfaces should normally perform the connections.
class subsystem_env extends uvm_env;
`uvm_component_utils(subsystem_env)
bus_agent bus;
interrupt_agent irq;
interrupt_checker checker;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
bus = bus_agent::type_id::create("bus", this);
irq = interrupt_agent::type_id::create("irq", this);
checker = interrupt_checker::type_id::create("checker", this);
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
bus.monitor.ap.connect(checker.bus_imp);
irq.monitor.ap.connect(checker.irq_imp);
endfunction
endclass
The checker does not need to know whether it is inside subsystem_env,
system_env, or another verification environment.
The containing environment supplies the connections.
Step 6: Reuse the same component in another environment
Suppose another subsystem has a different hierarchy but exposes the same bus and interrupt transaction contracts.
class peripheral_env extends uvm_env;
`uvm_component_utils(peripheral_env)
bus_agent bus;
interrupt_agent irq;
interrupt_checker checker;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
bus = bus_agent::type_id::create("bus", this);
irq = interrupt_agent::type_id::create("irq", this);
checker = interrupt_checker::type_id::create("checker", this);
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
bus.monitor.ap.connect(checker.bus_imp);
irq.monitor.ap.connect(checker.irq_imp);
endfunction
endclass
The environment hierarchy changed, but the checker did not. That is practical reuse: the same verification behavior can be instantiated in a different context because its dependencies are expressed through stable interfaces.
Step 7: Understand different kinds of reuse
| Reuse type | Example | What must remain stable? |
|---|---|---|
| Protocol reuse | Same APB agent on several blocks | Protocol transactions and agent configuration |
| Checking reuse | Same protocol checker in several environments | Observed transaction semantics |
| Prediction reuse | Same predictor for multiple instances of a block | Input/output model interface |
| Coverage reuse | Same subscriber across tests | Sampled transaction definition |
| Environment reuse | Subsystem environment inside a system environment | Environment configuration and externally visible interfaces |
Reuse does not mean that every component must work everywhere without configuration. Good reuse usually means that differences are expressed through documented configuration or well-defined connections instead of source-code edits.
Step 8: Avoid the most common coupling traps
-
Hard-coded hierarchy:
referencing
uvm_test_top.env.some_agentinside reusable logic. - Driver internals: reading or modifying private driver state instead of consuming monitor transactions.
- Sequence control from checkers: allowing a checker to decide which test sequence should execute.
-
Hidden configuration:
relying on undocumented
config_dbfields or wildcard settings. - Project-specific transaction types: making a generic checker depend on a transaction containing unrelated fields.
- Mixed responsibilities: combining prediction, comparison, coverage, stimulus control, and protocol monitoring into one component.
- Implementation-dependent assumptions: depending on callback order, queue internals, or simulator scheduling instead of an explicit transaction relationship.
Step 9: Reuse does not mean “make everything generic”
Excessive abstraction can be just as harmful as excessive coupling. A component becomes harder to understand when it supports many unrelated protocols, transaction types, configuration modes, and special cases merely because they might be useful someday.
Prefer a narrow component with a clear responsibility over a universal component with dozens of switches.
// Easier to reason about:
apb_protocol_checker
// Potentially over-generalized:
generic_protocol_checker_with_17_modes
A reusable component should have enough flexibility to represent legitimate variations, but not so much flexibility that its behavior becomes difficult to predict.
Architecture: where reusable components fit
system_env
|
+--------------+--------------+
| |
subsystem_env A subsystem_env B
| |
+------+-------+ +-----+------+
| | | |
bus_agent irq_agent bus_agent irq_agent
| | | |
+------+-------+ +-----+------+
| |
reusable checker reusable checker
|
reusable predictor
|
reusable coverage subscriber
Lesson 54 established that environments should be layered according to verification responsibility. Lesson 55 adds another dimension: components within those layers should have boundaries that permit them to move between environments.
A reusable checker can therefore live inside a subsystem environment today and be instantiated directly by a different environment tomorrow, provided its transaction and configuration contracts remain compatible.
Debugging a component that does not reuse cleanly
When a previously reusable component fails after being moved, determine which boundary changed.
-
Check construction:
Was the component created with
type_id::create()and does it exist in the topology? - Check configuration: Did the new environment provide the required configuration object at the expected scope?
- Check transaction types: Are the producer and consumer using compatible transaction classes?
- Check TLM connections: Is the monitor analysis port actually connected to the reusable component?
- Check transaction semantics: Does the new monitor publish the same kind of transaction at the same boundary?
- Check hidden assumptions: Does the component depend on hierarchy, driver state, timing, callback ordering, or a project-specific field?
- Check reset behavior: Does the component clear state when the new environment's reset policy requires it?
Exercise 1: Find the reusable boundary
Consider an environment containing:
- an APB agent,
- a UART agent,
- a register predictor,
- a scoreboard,
- functional coverage,
- a sequence that configures the DUT.
Classify each item as:
- strong candidate for reuse,
- potentially reusable with configuration, or
- primarily scenario-specific.
For every reusable candidate, write down the smallest interface it needs from the rest of the environment.
Exercise 2: Refactor a coupled checker
Start with this design:
class register_checker extends uvm_component;
function void check();
// Reads env.apb_agent.driver.last_item
// Reads env.model.expected_value
// Reads env.uart_agent.monitor.last_irq
endfunction
endclass
Refactor the architecture so the checker receives:
- observed APB transactions through an analysis interface,
- expected transactions from a predictor,
- interrupt observations through a separate analysis interface.
Then identify which relationships belong inside the checker and which should remain owned by the containing environment.
Challenge: Build one reusable checker for two environments
Create a checker that correlates a command transaction with a completion interrupt. Instantiate it in two different environments with different agent hierarchies.
Your solution should:
- use typed analysis interfaces rather than hierarchy references,
- receive policy through a configuration object,
- support reset by clearing outstanding state,
- report the transaction ID when a completion cannot be correlated,
- work without modifying the checker source when moved to the second environment.
As an advanced extension, add a timeout policy for outstanding commands. Keep the timeout mechanism inside the reusable checking component, but keep environment-specific timeout values in configuration.
Knowledge check
- Why is a monitor transaction usually a better dependency for a reusable checker than a driver's internal queue?
- What is the difference between reusing an implementation and reusing a component through a stable interface?
- When should a behavior difference become configuration rather than a new subclass?
- Why can two successfully connected analysis ports still produce an incorrect checker?
- Why should a reusable checker normally avoid controlling test sequences?
- What evidence would you inspect if a reusable component receives no transactions after being moved to another environment?
Production checklist
- Can the component describe its responsibility in one sentence?
- Are its inputs and outputs explicit?
- Does it depend on transaction semantics rather than hierarchy internals?
- Are policy differences represented by validated configuration?
- Does it avoid reaching into sibling or child component implementation details?
- Can it be instantiated in another environment without source changes?
- Does it define reset behavior for any internal state?
- Are failures reported with enough context to debug the component outside its original environment?
- Is the component actually simpler to reuse than to rewrite?
Key takeaways
- Reusable UVM components have explicit transaction, configuration, and connection boundaries.
- Agents, predictors, scoreboards, checkers, and subscribers can all be reusable when their responsibilities are well isolated.
- Connect reusable components from the containing environment instead of making them discover or control their surroundings.
- Configuration is useful for legitimate policy variation; it should not become a collection of hidden project-specific switches.
- Hierarchy references, driver internals, callback ordering, and scenario control are common sources of accidental coupling.
- Reuse is validated by moving the component to another environment and checking that its behavior remains correct without source modification.
Next lesson
In Lesson 56: Register Access Basics, we move from general reusable components to a specific production capability: register access and register-model-based verification. You will learn how register abstractions fit alongside protocol agents, sequences, predictors, and scoreboards without mixing register semantics into low-level bus drivers.