Module 5: Configuration and Extension | Intermediate UVM

Configuration Object Design

Design scalable UVM configuration objects that group related settings, carry interface handles, validate environment policy, and keep reusable agents independent of individual tests.

Learning objectives

  • Explain why reusable UVM agents benefit from dedicated configuration objects.
  • Design a configuration object with sensible defaults and validation.
  • Pass configuration objects through uvm_config_db.
  • Configure active/passive behavior, virtual interfaces, timing limits, and protocol options.
  • Understand ownership and lifetime considerations for configuration objects.
  • Distinguish configuration policy from driver, monitor, and sequence implementation.
  • Configure multiple agent instances independently using the same configuration class.
  • Diagnose incomplete, invalid, or inconsistent configuration.
  • Recognize when an environment-level configuration object should contain multiple agent configurations.

Step 1: Why use a configuration object?

Lesson 41 introduced uvm_config_db as a way to distribute settings through the UVM hierarchy. That works well for a small number of values.

A reusable agent, however, may eventually need:

active/passive mode


virtual interface
timeout policy
protocol mode
maximum outstanding transactions
error injection enable
coverage enable
monitor options

Passing every field independently through the configuration database creates a growing collection of names that must remain consistent.

A configuration object groups related settings into one typed object:

                protocol_agent_config
                     |
      +--------------+--------------+
      |              |              |
   is_active       vif          timeout
      |
  protocol options
      |
  feature enables
Core principle: The configuration object describes how an agent should operate; the agent implementation decides how to implement that behavior.

Step 2: Decide what belongs in configuration

A useful test is to ask: Would changing this value normally require a different testbench policy rather than a different implementation?

Good configuration candidate Usually not configuration
Active/passive mode Individual transaction address
Virtual interface Individual transaction data
Protocol mode Sequence item contents
Timeout policy Runtime transaction stream
Maximum outstanding depth Scoreboard expected queue
Optional feature enable Factory replacement of a component

The distinction is not absolute, but it is a useful architectural starting point.

Step 3: Create a basic configuration object

Start with a small, typed class:

class protocol_agent_config extends uvm_object;


`uvm_object_utils(protocol_agent_config)

uvm_active_passive_enum is_active = UVM_ACTIVE;

int unsigned timeout_cycles = 100;

bit enable_error_injection = 0;

function new(string name = "protocol_agent_config");
super.new(name);
endfunction

endclass

The class extends uvm_object, not uvm_component. Configuration data does not need UVM phases, hierarchy, or TLM ports.

The registered object type can also participate in normal UVM object creation and printing mechanisms.

Step 4: Give configuration fields meaningful defaults

Defaults make configuration objects easier to construct safely.

uvm_active_passive_enum is_active = UVM_ACTIVE;


int unsigned timeout_cycles = 100;
bit enable_error_injection = 0;

A default should represent a sensible and safe behavior, not hide a required project decision.

For example, if an interface is mandatory, do not silently assign a meaningless default to its virtual interface:

virtual protocol_if vif;

Instead, require the testbench to provide it and validate that it is not null.

Step 5: Add a virtual interface

A realistic agent configuration commonly carries the virtual interface used by its driver and monitor.

class protocol_agent_config extends uvm_object;


`uvm_object_utils(protocol_agent_config)

virtual protocol_if vif;

uvm_active_passive_enum is_active = UVM_ACTIVE;

int unsigned timeout_cycles = 100;

function new(string name = "protocol_agent_config");
super.new(name);
endfunction

endclass

The configuration object now represents both policy and the interface handle required to operate the agent.

This is particularly useful when several instances of the same agent use different interfaces.

Step 6: Validate configuration before using it

A configuration object should not merely store fields. It can also provide validation logic.

function bit is_valid();


if (vif == null)
return 0;

if (timeout_cycles == 0)
return 0;

return 1;

endfunction

The agent can validate the object after retrieving it:

if (!uvm_config_db#(protocol_agent_config)::get(
  this,
  "",
  "cfg",
  cfg
)) begin


`uvm_fatal("CFG", "Missing protocol_agent_config")
end

if (!cfg.is_valid()) begin
`uvm_fatal("CFG", "Invalid protocol_agent_config")
end

This gives a clean distinction:

Configuration missing
    vs.


Configuration present but invalid

Step 7: Keep validation close to the configuration meaning

Some fields have relationships that cannot be validated by checking each field independently.

For example:

max_outstanding = 16


timeout_cycles   = 1000

may be legal for one protocol mode but inappropriate for another.

A configuration object can validate these relationships:

function bit is_valid();


if (vif == null)
return 0;

if (timeout_cycles == 0)
return 0;

if (max_outstanding == 0)
return 0;

if (!supports_out_of_order && max_outstanding > 1)
return 0;

return 1;

endfunction

The exact rules depend on the protocol, but the architectural lesson is general: configuration validation belongs near the definition of configuration policy.

Step 8: Put the object into the configuration database

Once the configuration object is created and initialized, pass the object through uvm_config_db.

protocol_agent_config cfg;


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

cfg.vif = protocol_vif;
cfg.is_active = UVM_ACTIVE;
cfg.timeout_cycles = 100;
cfg.enable_error_injection = 0;

uvm_config_db#(protocol_agent_config)::set(
this,
"env.agent",
"cfg",
cfg
);

The database now carries one typed configuration object rather than several unrelated settings.

Step 9: Retrieve the configuration inside the agent

class protocol_agent extends uvm_agent;


`uvm_component_utils(protocol_agent)

protocol_agent_config cfg;

function new(
string name = "protocol_agent",
uvm_component parent = null
);
super.new(name, parent);
endfunction

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


if (!uvm_config_db#(protocol_agent_config)::get(
      this,
      "",
      "cfg",
      cfg
    )) begin
  `uvm_fatal(
    "CFG",
    "Missing protocol_agent_config"
  )
end

if (!cfg.is_valid()) begin
  `uvm_fatal(
    "CFG",
    "Invalid protocol_agent_config"
  )
end


endfunction

endclass

After this point, the agent can use cfg as its configuration source rather than repeatedly querying the configuration database.

Good pattern: Retrieve the configuration object once, validate it, and retain the handle for the component's use.

Step 10: Use configuration to control active/passive behavior

Active/passive mode is a classic example of configuration affecting component construction.

function void build_phase(uvm_phase phase);


super.build_phase(phase);

if (!uvm_config_db#(protocol_agent_config)::get(
this,
"",
"cfg",
cfg
)) begin
`uvm_fatal("CFG", "Missing agent configuration")
end

if (!cfg.is_valid()) begin
`uvm_fatal("CFG", "Invalid agent configuration")
end

monitor = protocol_monitor::type_id::create(
"monitor",
this
);

if (cfg.is_active == UVM_ACTIVE) begin
sequencer = protocol_sequencer::type_id::create(
"sequencer",
this
);


driver = protocol_driver::type_id::create(
  "driver",
  this
);


end
endfunction

The same agent class can therefore operate actively or passively without modifying the agent source.

Step 11: Pass configuration to child components

Sometimes the agent owns settings that its driver and monitor need. A useful pattern is to distribute the same configuration object to those children.

uvm_config_db#(protocol_agent_config)::set(


this,
"driver",
"cfg",
cfg
);

uvm_config_db#(protocol_agent_config)::set(
this,
"monitor",
"cfg",
cfg
);

The child component can retrieve the same object relative to itself:

if (!uvm_config_db#(protocol_agent_config)::get(
  this,
  "",
  "cfg",
  cfg
)) begin


`uvm_fatal("CFG", "Missing agent configuration")
end

This keeps driver and monitor behavior synchronized around the same configuration policy.

However, do not automatically pass every configuration field to every child. A monitor may not need a driver-only setting. Keeping the configuration object cohesive but avoiding irrelevant dependencies makes the environment easier to maintain.

Step 12: Decide whether configuration is mutable

Configuration is normally established during environment construction and then treated as stable.

For example:

build_phase:
retrieve configuration
validate configuration
construct components


run_phase:
use configuration

Avoid casually changing configuration fields halfway through simulation. If runtime behavior needs to change dynamically, use a mechanism designed for runtime communication or synchronization.

This avoids situations where the driver uses one interpretation of a setting while the monitor uses another.

Step 13: Configure multiple agent instances

Configuration objects become particularly valuable when several instances use different settings.

protocol_agent_config cfg_a;


protocol_agent_config cfg_b;

cfg_a = protocol_agent_config::type_id::create("cfg_a");
cfg_b = protocol_agent_config::type_id::create("cfg_b");

cfg_a.vif = vif_a;
cfg_a.is_active = UVM_ACTIVE;
cfg_a.timeout_cycles = 100;

cfg_b.vif = vif_b;
cfg_b.is_active = UVM_PASSIVE;
cfg_b.timeout_cycles = 500;

uvm_config_db#(protocol_agent_config)::set(
this,
"env.agent_a",
"cfg",
cfg_a
);

uvm_config_db#(protocol_agent_config)::set(
this,
"env.agent_b",
"cfg",
cfg_b
);

The reusable agent implementation remains identical. Only the configuration differs.

              same agent class
             /       \
            /         \
      cfg_a             cfg_b
       |                 |
   active             passive
   vif_a              vif_b
   100 cycles         500 cycles

Step 14: Keep environment-level and agent-level configuration distinct

As an environment grows, not every setting belongs to one agent.

For example:

Environment configuration


|
+-- Agent A configuration
|
+-- Agent B configuration
|
+-- Scoreboard policy
|
+-- Global timeout policy

An environment-level configuration object can group the settings that belong to the environment as a whole.

class protocol_env_config extends uvm_object;


`uvm_object_utils(protocol_env_config)

protocol_agent_config agent_a_cfg;
protocol_agent_config agent_b_cfg;

bit enable_global_checks = 1;

function new(string name = "protocol_env_config");
super.new(name);
endfunction

endclass

This becomes useful when the test needs to construct a coherent configuration for a complete reusable environment rather than configuring each component independently.

The detailed design of hierarchical configuration is a natural extension of this lesson and becomes increasingly important as multiple agents are integrated.

Step 15: Use configuration to express verification policy

A configuration object can describe verification policy without embedding that policy into implementation code.

For example:

bit enable_error_injection = 0;


bit enable_protocol_checks = 1;
int unsigned timeout_cycles = 100;

The same reusable agent can then be used for:

Normal regression:


protocol checks = enabled
error injection = disabled

Error-injection test:
protocol checks = enabled
error injection = enabled

Passive observation:
agent = passive
protocol checks = enabled

The test selects the policy; the agent implements the behavior.

Step 16: Make configuration observable

Configuration bugs are much easier to debug when the final configuration can be printed.

UVM objects support standard object printing mechanisms, and a configuration object can also implement custom diagnostics where useful.

`uvm_info(


"CFG",
$sformatf(
"Agent configuration: active=%0d timeout=%0d error_injection=%0d",
cfg.is_active,
cfg.timeout_cycles,
cfg.enable_error_injection
),
UVM_MEDIUM
)

Print configuration at a useful lifecycle point, typically after retrieval and validation.

This creates evidence that the component actually received the configuration you intended.

Step 17: Understand object ownership

A configuration object is a SystemVerilog class object, so the configuration database and components hold object handles rather than independent copies of the object.

This means that:

cfg_a -> agent_a


cfg_b -> agent_b

can safely represent independent configurations.

But if multiple agents intentionally or accidentally receive the same object handle, changes to that object's fields are visible through that shared handle.

Therefore, decide explicitly whether configuration should be:

  • shared as one immutable policy object;
  • separate per agent instance;
  • copied into another object before modification.

For most agent-specific settings, separate configuration objects are clearer.

Step 18: Avoid putting implementation state into configuration

A configuration object should describe policy and resources, not become a dumping ground for runtime state.

Avoid fields such as:

transactions_seen


current_request
outstanding_queue
last_response
error_count

Those are runtime state and belong in the appropriate component.

A useful distinction is:

Configuration:


"What behavior should this component use?"

Runtime state:
"What has happened so far during this simulation?"

Common mistakes

Debugging strategy

When an agent behaves incorrectly, inspect the configuration path before debugging the implementation.

Unexpected agent behavior
    |
    v


Was configuration retrieved?
|
v
Was the configuration object valid?
|
v
Was the correct object assigned to this instance?
|
v
Were the expected fields initialized?
|
v
Was the object modified unexpectedly?
|
v
Did the component consume the correct field?
|
v
Only then debug driver/monitor behavior

For example, if a driver is unexpectedly created in a passive agent, check cfg.is_active before inspecting the driver's implementation.

Practical design checklist

  1. Give the configuration object one clear responsibility.
  2. Use strongly typed fields.
  3. Provide safe defaults where appropriate.
  4. Leave mandatory resources such as virtual interfaces explicitly required.
  5. Validate related fields together.
  6. Retrieve the object before structural component decisions are made.
  7. Keep configuration stable during normal simulation.
  8. Use separate objects for independent agent instances unless sharing is intentional.
  9. Print important configuration during debug builds or at useful verbosity.
  10. Keep runtime state outside the configuration object.

Try it yourself

Design a configuration object for a reusable APB-style agent containing:

virtual interface


active/passive mode
timeout cycles
maximum wait states
error injection enable
protocol checking enable

Add an is_valid() function that rejects:

  • a missing virtual interface;
  • a zero timeout;
  • an invalid wait-state limit.

Then configure two agent instances with different virtual interfaces and active/passive settings.

Debugging exercise

An agent reports:

active=0


timeout=500

But the test expected:

active=1


timeout=100

Investigate the problem systematically:

  1. Print the actual UVM topology.
  2. Identify the configuration object assigned to the agent.
  3. Inspect where that object was initialized.
  4. Check whether another configuration object was used for the same instance.
  5. Check the exact configuration path.
  6. Check whether the object was modified after initialization.
  7. Confirm the agent retrieved the intended object.

Do not modify the driver until the configuration evidence is correct.

Challenge: Design a reusable environment configuration

Create:

protocol_env_config
|
+-- command_agent_config
|
+-- response_agent_config
|
+-- global timeout
|
+-- global checking enable

Configure the command agent as active and the response agent as passive. Give them different virtual interfaces and timeout policies.

Then add validation so the environment rejects:

  • missing agent configurations;
  • missing virtual interfaces;
  • zero timeout values;
  • incompatible protocol settings.

Advanced extension: Add a configuration field describing whether the response protocol permits out-of-order completion. Use that value to select an appropriate checker architecture, but keep the actual scoreboard algorithm outside the configuration object.

Knowledge check

  1. Why use a configuration object?
    To group related, typed settings and resources into a coherent object that can be passed through the UVM hierarchy.
  2. Why does a configuration object usually extend uvm_object?
    Configuration data does not need UVM component hierarchy, phases, or TLM ports.
  3. Should a virtual interface belong in an agent configuration object?
    Yes, when the interface is a resource required by that agent's driver or monitor.
  4. Should a transaction address belong in the configuration object?
    No. It is transaction data and normally belongs in a sequence item.
  5. Why validate configuration?
    A successfully retrieved object can still contain invalid or inconsistent settings.
  6. Why should independent agent instances usually have independent configuration objects?
    It prevents accidental coupling through a shared mutable object.
  7. Should runtime scoreboard state be stored in configuration?
    No. Configuration describes policy; runtime state belongs in the component responsible for that state.
  8. When should configuration normally be retrieved?
    Before the component makes structural or initialization decisions that depend on it.
  9. What is the role of uvm_config_db when using configuration objects?
    It provides the hierarchical delivery mechanism; the configuration object provides the structured representation of the settings.

Key takeaways

  • A configuration object gives a reusable UVM component one coherent place for related settings and resources.
  • Use configuration for policy and environment resources, not transaction streams or runtime state.
  • Virtual interfaces are commonly carried by agent configuration objects.
  • Defaults should be safe and intentional; mandatory resources should be validated explicitly.
  • Configuration validation can check relationships between fields, not just individual values.
  • Retrieve and validate configuration before making component-construction decisions.
  • Independent agent instances generally benefit from independent configuration objects.
  • Keep configuration stable during normal simulation unless a deliberate runtime-control architecture exists.
  • uvm_config_db distributes the configuration object; it does not define the meaning of the settings.
  • Configuration design should make the environment easier to reuse, debug, and extend—not merely reduce the number of set() calls.

What comes next?

Lesson 41 introduced the mechanics of uvm_config_db. This lesson turned those mechanics into a scalable configuration-object design.

Lesson 41


Configuration Database Patterns
|
v
Lesson 42
Configuration Object Design
|
v
Lesson 43
Configuration Scope and Precedence
|
v
Lessons 44–46
Factory Overrides and Debugging

Lesson 43: Configuration Scope and Precedence will address the part that becomes increasingly important as environments grow: when multiple configuration settings match the same component, which one does UVM use?

The learner will move from simply knowing how to create and retrieve configuration to being able to reason about hierarchical matching, wildcards, specificity, precedence, and configuration-debugging techniques in larger multi-agent environments.