UVM Configuration Database
Summary
The uvm_config_db is a UVM utility class that is used to pass configuration data
objects between component objects in a UVM testbench.
Methods
To understand better how to use the get() and set() methods, let's first take a look at
their definitions.
set
Description
Creates or updates a configuration setting in the UVM configuration database. This method allows you to store configuration values that can be retrieved by components during the build phase or runtime.
| Parameter | Type | Description |
|---|---|---|
cntxt |
uvm_component |
The context component from which the configuration scope is determined. Can be null for absolute paths. |
inst_name |
string |
The instance path, either relative to cntxt or absolute when cntxt is null. |
field_name |
string |
The name of the configuration field to set. |
value |
T |
The value to assign to the configuration field. Type T is parameterized. |
Scope Resolution
The full scope of the configuration setting is determined by the combination of cntxt and inst_name:
With Context (cntxt != null)
When a context component is provided, the full scope is constructed as:
Example:
Without Context (cntxt == null)
When cntxt is null, inst_name must provide the complete hierarchical path:
Example:
Notes
- The
set()method is typically called during the build phase or in the testbench top module - Wildcards (
*) can be used ininst_namefor pattern matching - Settings must be made before the components retrieve them using
get - Later
set()calls to the same scope will override earlier values
get
Description
Retrieves a configuration value from the UVM configuration database. This method searches for a configuration setting that matches the specified scope and field name, starting from the given context component. Returns 1 (true) if the value is found, 0 (false) otherwise.
| Parameter | Type | Description |
|---|---|---|
cntxt |
uvm_component |
The starting point for the configuration search. Typically this in the calling component. |
inst_name |
string |
The instance path relative to cntxt. Can be an empty string "" if the configuration applies directly to cntxt. |
field_name |
string |
The name of the configuration field to retrieve. |
value |
inout T |
Reference parameter that receives the retrieved value if found. Type T is parameterized. |
Notes
Real examples
1. Connecting a UVM testbench to a DUT using the uvm_config_db
From tb.sv we declare an interface called rst_if() and then we push into de uvm_config_db the
interface
| tb.sv | |
|---|---|
| gpio_uvc_config.sv | |
|---|---|
- The
uvm_config_db::get()method is a function that returns a bit value to indicate whether the object retrieval was been successful or not; this is tested to ensure that the testbench does not proceed if the lookup fails.
Coding Guidelines
Reference Material
Accellera
Verification Methodology Cookbooks
Source Code