Module 2: UVM Foundations | Beginner UVM

Configuration Objects

Learn how to package testbench settings into reusable configuration objects and use them to control UVM components without hard-coding behavior.

Learning objectives

By the end of this lesson, you will be able to:

  • Explain what a UVM configuration object is.
  • Identify settings that belong in a configuration object.
  • Create a configuration class using SystemVerilog.
  • Use a configuration object to control reusable component behavior.
  • Distinguish configuration data from transaction data.
  • Explain why configuration objects improve testbench reuse.
  • Prepare a configuration object for distribution through uvm_config_db.

Before you start

In the previous lessons, you learned how the UVM Factory allows a test to customize which implementation gets created.

Now we need to solve a different problem:

How can a test tell a reusable component how it should behave?

For example, one test might want:

data_width = 32


active     = 1
delay      = 0

while another test might want:

data_width = 64


active     = 1
delay      = 5

We could create separate variables for all of these settings and pass them individually through the testbench. As the environment grows, that becomes difficult to maintain.

A configuration object gives us a better way to group related settings into one reusable object.

Test


↓
Configuration Object
↓
Agent / Driver / Monitor
↓
Behavior controlled by configuration

Step 1: What is a configuration object?

A configuration object is a SystemVerilog class that stores settings used to control the behavior of one or more UVM components.

For example:

class bus_config extends uvm_object;


int data_width;
bit active;
int delay;

endclass

Instead of spreading these settings across many variables, we keep related configuration information together.

Think of a configuration object as a control panel for a part of your verification environment.

The configuration object does not normally perform the protocol operation itself. It describes how a component should operate.

Step 2: Configuration data vs transaction data

Beginners often confuse configuration objects with sequence items. They solve different problems.

Configuration Transaction
Controls how the testbench behaves Represents activity sent to or observed from the DUT
Usually changes less frequently Usually changes from transaction to transaction
Example: data width Example: address
Example: active/passive mode Example: read/write operation
Example: timing or delay settings Example: payload data

A useful rule is:

Configuration
↓


"How should my testbench behave?"

Transaction
↓
"What operation should my testbench perform?"
Common mistake: Putting every piece of test information into a configuration object. Transaction-specific stimulus normally belongs in sequence items, not configuration.

Step 3: Identify configuration settings

Before creating a configuration class, ask:

Which settings should a test be able to change without modifying the reusable component?

Common examples include:

  • Whether an agent is active or passive.
  • Data or address width.
  • Protocol timing settings.
  • Number of transactions to generate.
  • Optional feature enable/disable controls.
  • Protocol mode selection.
  • Timeout values.
  • Environment-specific behavior switches.

The exact settings depend on the design being verified.

Design principle: Put configuration data in the configuration object when that data controls reusable component behavior.

Step 4: Build a configuration class

Let's create a configuration object for a simple bus agent.

class bus_config extends uvm_object;


bit active;
int data_width;
int timeout_cycles;

`uvm_object_utils(bus_config)

function new(string name = "bus_config");
super.new(name);


active        = 1;
data_width    = 32;
timeout_cycles = 100;


endfunction

endclass

There are several important parts here.

  1. bus_config extends uvm_object.
  2. The class contains configuration fields.
  3. The class is registered with the UVM factory.
  4. The constructor provides sensible default values.
Good configuration objects have useful defaults. A component should have a predictable configuration even when a test does not override every setting.

Step 5: Why use defaults?

Suppose a configuration object contains:

bit active;


int data_width;
int timeout_cycles;

Leaving these values undefined can make debugging unnecessarily difficult.

Instead, establish known defaults:

active         = 1;


data_width     = 32;
timeout_cycles = 100;

Now the configuration has a predictable starting state.

Professional habit: Configuration defaults should represent a safe and useful normal operating mode whenever possible.

Step 6: Create and customize the configuration

A test can create a configuration object and change its settings.

bus_config cfg;


cfg = bus_config::type_id::create("cfg");

cfg.active         = 1;
cfg.data_width     = 64;
cfg.timeout_cycles = 200;

Notice that the configuration object itself does not need to know which component will eventually use it.

It simply contains the settings.

Configuration object
    ↓


+-------------------+
| active = 1        |
| data_width = 64   |
| timeout = 200     |
+-------------------+

Later, the configuration can be delivered to the appropriate component.

Step 7: Let the component use the configuration

Imagine a bus agent that needs to know whether it should be active.

class bus_agent extends uvm_agent;


bus_config cfg;

`uvm_component_utils(bus_agent)

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

endclass

The agent now has a place to store its configuration.

It can use settings such as:

cfg.active


cfg.data_width
cfg.timeout_cycles

The important architecture is:

Test


↓
creates/configures bus_config
↓
configuration delivered to agent
↓
agent reads configuration
↓
agent builds the appropriate components
↓
components behave according to configuration

Step 8: Active and passive behavior

A particularly useful configuration setting is whether an agent should be active or passive.

An active agent typically participates in driving stimulus. A passive agent can observe activity without driving the interface.

A configuration object can describe this choice:

cfg.active = 1;

or:

cfg.active = 0;

The same reusable agent can therefore support different testbench modes without creating separate agent classes.

Reuse benefit: One agent implementation can support multiple verification scenarios simply by changing configuration.

Step 9: Configuration belongs to the environment architecture

A common mistake is to put configuration decisions directly inside drivers and monitors.

For example, avoid scattering hard-coded values like:

if (DATA_WIDTH == 32)


...
else
...

throughout the environment.

Instead, centralize the setting:

cfg.data_width

Then components consume the configuration rather than owning independent copies of the same setting.

                 bus_config
            /    |     \
           /     |      \
          ↓      ↓       ↓
      driver   monitor  agent
Think "single source of truth." If several components need the same configuration information, keeping that information in one configuration object reduces duplicated settings and inconsistent behavior.

Step 10: Configuration objects and the factory

Notice something important about our configuration class:

class bus_config extends uvm_object;

Because it is a UVM object, it can also participate in the UVM Factory.

bus_config cfg;


cfg = bus_config::type_id::create("cfg");

This follows the same factory concept you learned in Lessons 17 and 18.

Configuration type
    ↓


Factory registration
↓
type_id::create()
↓
Configuration object

This is useful when a test needs a specialized configuration object without modifying the reusable environment.

Connection to the previous lessons: Factory-based construction is not limited to transactions and components. UVM configuration objects can also use the factory.

Step 11: Keep configuration simple

A configuration object should primarily describe configuration. Avoid turning it into a second environment or a collection of unrelated helper functions.

Good:

class bus_config extends uvm_object;


bit active;
int data_width;
int timeout_cycles;
bit enable_error_injection;

endclass

Less desirable:

class bus_config extends uvm_object;


bit active;

task drive_packet();
...
endtask

function void calculate_score();
...
endfunction

endclass

The second example mixes configuration data with behavior that belongs elsewhere in the verification architecture.

Rule of thumb: Configuration objects describe settings; components implement behavior.

Step 12: How configuration reaches a component

So far, we have created a configuration object and shown that a component can store it.

But how does the configuration object actually travel from the test to the agent?

UVM provides a standard mechanism for this:

uvm_config_db

The configuration database allows configuration information to be placed into a shared UVM configuration mechanism and retrieved by components.

We will learn this next. Lesson 20 focuses specifically on uvm_config_db, including how to set and get configuration values and objects.

For this lesson, remember the architecture rather than memorizing the API:

Test


↓
Create configuration object
↓
Customize configuration
↓
Deliver configuration
↓
Component retrieves configuration
↓
Component uses configuration

Step 13: A complete configuration example

Here is a compact example that brings the main ideas together.

class bus_config extends uvm_object;


bit active;
int data_width;
int timeout_cycles;

`uvm_object_utils_begin(bus_config)
    `uvm_field_int(active,         UVM_DEFAULT)
`uvm_field_int(data_width,     UVM_DEFAULT)
    `uvm_field_int(timeout_cycles, UVM_DEFAULT)
`uvm_object_utils_end

function new(string name = "bus_config");
super.new(name);


active          = 1;
data_width      = 32;
timeout_cycles  = 100;


endfunction

endclass

class bus_agent extends uvm_agent;

bus_config cfg;

`uvm_component_utils(bus_agent)

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

endclass

The configuration object contains the settings. The agent contains the behavior.

bus_config
↓


settings

bus_agent
↓
behavior

Keeping these responsibilities separate is an important UVM architecture principle.

Step 14: Common mistakes

Mistake 1: Hard-coding configuration inside components

If the driver contains dozens of hard-coded settings, every new test may require source-code changes.

Move test-controlled settings into configuration data.

Mistake 2: Confusing configuration with stimulus

A bus address such as 8'h40 for one transaction is normally stimulus. A setting such as data_width = 32 describes how the environment operates.

Mistake 3: Creating too many configuration classes

Do not create a separate class for every single setting. Group related configuration data according to the architecture of the environment.

Mistake 4: Giving configuration objects no defaults

Predictable defaults make environments easier to use and debug.

Mistake 5: Putting component behavior inside configuration

Configuration should describe behavior, not implement the behavior. Keep protocol operations inside the appropriate UVM components.

Quick check

Question 1

What is the primary purpose of a configuration object?

Show answer

To group settings that control how reusable UVM components and environments behave.

Question 2

Which is more likely to belong in a configuration object?

A. The address of the next transaction


B. Whether the agent is active

C. The payload of one transaction
Show answer

B. Whether an agent is active is a configuration setting that controls the environment's behavior.

Question 3

Why should a configuration object have useful default values?

Show answer

Defaults provide predictable behavior and make the environment easier to use and debug.

Question 4

Should a configuration object normally contain the task that drives a packet onto the DUT interface?

Show answer

No. The configuration object should contain settings. Protocol behavior belongs in components such as drivers, monitors, and sequences.

Try it yourself

Create a configuration object for a simple FIFO verification environment.

Include at least these settings:

  • active — whether the agent drives the FIFO.
  • data_width — width of FIFO data.
  • depth — expected FIFO depth.
  • timeout_cycles — maximum wait time.

Then:

  1. Extend uvm_object.
  2. Register the configuration class with UVM.
  3. Add a constructor.
  4. Give every field a useful default value.
  5. Create the configuration using type_id::create().
  6. Change at least two settings.
  7. Print the configuration with sprint().
Challenge: Create two configurations: one for an active agent and one for a passive agent. Compare their printed values.

Professional tip

Design configuration around reuse.

When you find yourself editing a driver, monitor, or agent just to change a test-specific setting, ask whether that setting belongs in a configuration object instead.

Key takeaways

  • A configuration object groups settings that control UVM component behavior.
  • Configuration data describes how the testbench should behave; transaction data describes what operation should occur.
  • Good configuration objects provide sensible defaults.
  • Configuration keeps reusable components from becoming dependent on hard-coded test settings.
  • Configuration objects can themselves be created through the UVM Factory.
  • Configuration objects should contain settings rather than component behavior.
  • uvm_config_db provides a standard mechanism for delivering configuration information through the UVM hierarchy.

What's next?

You now know how to design a configuration object and why it is useful for reusable UVM environments.

But we still have one important question:

How does a test actually pass the configuration object to the component that needs it?

In the next lesson, we will answer that question by learning the uvm_config_db.

Next lesson: Configuration Database Basics — learn how to set and retrieve configuration values and objects through the UVM hierarchy.