Environment Architecture
Assemble agents, scoreboards, reference models, and coverage into a reusable verification environment.
Learning objectives
- Explain the purpose and responsibility of a
uvm_env. - Identify which verification components belong inside an environment.
- Build an environment containing one or more agents and checking components.
- Connect monitor analysis ports to scoreboards, reference models, and coverage components.
- Separate reusable environment architecture from test-specific scenarios.
- Trace stimulus and observations through a complete UVM environment.
Step 1: What problem does an environment solve?
By now, you have built individual pieces of a UVM testbench: sequence items, sequences, sequencers, drivers, monitors, subscribers, scoreboards, and reference models. The environment is where these pieces are assembled into a coherent verification system.
A UVM environment usually extends uvm_env and acts as the architectural
container for reusable verification components.
class bus_env extends uvm_env;
`uvm_component_utils(bus_env)
// Agents
bus_agent agent;
// Checking
bus_scoreboard scoreboard;
// Coverage
bus_coverage coverage;
function new(string name = "bus_env",
uvm_component parent = null);
super.new(name, parent);
endfunction
endclass
The environment does not normally generate individual transactions itself. Instead, it assembles the components that know how to generate, observe, predict, check, and measure behavior.
Step 2: See the complete environment
A simple environment can be visualized as:
TEST
|
| starts sequences
v
+-----------------------+
| bus_env |
| |
| +---------------+ |
| | bus_agent | |
| | | |
| | sequencer | |
| | driver | |
| | monitor ------+----+----+
| +---------------+ | |
| | |
| scoreboard <---------+ |
| | |
| coverage <-----------+ |
+-----------------------+ |
| |
v v
DUT observed transactions
The exact architecture depends on the DUT, but the important idea is that the environment composes reusable verification components.
Step 3: Decide what belongs inside the environment
A useful rule is to place components inside the environment when they represent reusable structure or verification infrastructure.
| Component | Typical location | Responsibility |
|---|---|---|
| Agent | Environment | Protocol stimulus and observation |
| Sequencer | Inside active agent | Manages sequence items |
| Driver | Inside active agent | Drives protocol signals |
| Monitor | Inside agent | Observes and publishes transactions |
| Scoreboard | Environment | Determines whether behavior is correct |
| Reference model | Environment | Predicts expected behavior |
| Coverage | Environment | Measures what scenarios were observed |
| Sequence | Test / sequence library | Defines stimulus scenarios |
Step 4: Build the environment hierarchy
The environment creates its child components during build_phase().
Factory creation keeps the architecture compatible with UVM's factory mechanism.
class bus_env extends uvm_env;
`uvm_component_utils(bus_env)
bus_agent agent;
bus_scoreboard scoreboard;
bus_coverage coverage;
function new(string name = "bus_env",
uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
agent = bus_agent::type_id::create(
"agent", this);
scoreboard = bus_scoreboard::type_id::create(
"scoreboard", this);
coverage = bus_coverage::type_id::create(
"coverage", this);
endfunction
endclass
After build, the hierarchy conceptually looks like:
uvm_test_top
└── env
├── agent
│ ├── sequencer
│ ├── driver
│ └── monitor
├── scoreboard
└── coverage
The environment owns these components, so it is responsible for constructing and connecting them.
Step 5: Connect the environment
Creating components gives you a hierarchy, but it does not automatically create communication paths between them.
The environment's connect_phase() is where analysis connections are
normally established.
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
One monitor can publish the same observed transaction to multiple consumers.
Monitor
|
analysis_port
/ \
/ \
v v
Scoreboard Coverage
| |
correctness measurement
This is one of the major advantages of transaction-level communication: the monitor does not need to know who will consume its observations.
Step 6: Understand the environment's responsibility
The environment is primarily responsible for composition. It decides which reusable components exist and how their communication paths are wired.
For example:
- The agent owns the driver/sequencer relationship.
- The monitor owns observation and transaction reconstruction.
- The environment connects observations to checking and coverage.
- The scoreboard determines correctness.
- The reference model predicts expected behavior.
- The test chooses which scenario to run.
This division prevents one component from becoming responsible for the entire verification system.
Step 7: Add a reference model
For a realistic environment, a scoreboard often needs expected behavior generated by a reference model rather than a fixed expected value.
INPUT
|
v
+---------+
| Monitor |
+----+----+
|
v
+-------------+
| Reference |
| Model |
+------+------+
|
expected
|
v
+-------------+
| Scoreboard |
+------+------+
^
|
actual
|
|
+----+----+
| Monitor |
+---------+
^
|
DUT
The environment can therefore become the place where the prediction and checking pipeline is assembled.
The exact connections depend on the DUT. A simple data path might connect an input monitor to the reference model and an output monitor to the scoreboard.
input_agent.monitor
|
+----------> reference_model
| |
| | expected
| v
| scoreboard
| ^
| |
output_agent.monitor -----+ Step 8: Use multiple agents
Real DUTs frequently have more than one interface. The environment can instantiate multiple agents, each responsible for one protocol.
class system_env extends uvm_env;
`uvm_component_utils(system_env)
bus_agent input_agent;
bus_agent output_agent;
system_scoreboard scoreboard;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
input_agent = bus_agent::type_id::create(
"input_agent", this);
output_agent = bus_agent::type_id::create(
"output_agent", this);
scoreboard = system_scoreboard::type_id::create(
"scoreboard", this);
endfunction
endclass
The two agents can even have different roles:
input_agent -> UVM_ACTIVE
output_agent -> UVM_PASSIVE
This gives the environment a flexible architecture:
system_env
+----------------+
| |
| input_agent |
| drive + obs |
| |
| output_agent |
| observe only |
| |
| scoreboard |
| coverage |
+----------------+
Step 9: Keep tests out of the environment
A common architectural mistake is putting a particular test scenario directly into the environment.
A better separation is:
Environment:
"What verification components exist?"
Test:
"Which configuration and scenario should I run?"
Sequence:
"What stimulus should I generate?"
Agent:
"How do I interact with the protocol?"
Scoreboard:
"Is the behavior correct?"
For example, the environment should not contain:
repeat (100) begin
// Generate random traffic
end
That is stimulus policy and belongs in sequences/tests. The environment should provide the infrastructure through which those sequences operate.
Step 10: A complete small environment
Here is the core architecture assembled into one example:
class bus_env extends uvm_env;
`uvm_component_utils(bus_env)
bus_agent agent;
bus_scoreboard scoreboard;
bus_coverage coverage;
function new(string name = "bus_env",
uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
agent = bus_agent::type_id::create(
"agent", this);
scoreboard = bus_scoreboard::type_id::create(
"scoreboard", this);
coverage = bus_coverage::type_id::create(
"coverage", this);
endfunction
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
endclass
This environment does not know how the driver toggles valid,
ready, addr, or data. That belongs to the
agent and driver.
It also does not know which particular sequence should run. That belongs to the test and sequence layers.
Its job is to assemble the verification infrastructure and establish the communication paths between its children.
Step 11: Configuration flows into the environment
The environment may also receive configuration that determines how its agents operate. This is especially useful when the same environment is reused in multiple tests.
bus_agent_cfg cfg;
cfg = bus_agent_cfg::type_id::create("cfg");
cfg.vif = bus_vif;
cfg.is_active = UVM_ACTIVE;
uvm_config_db#(bus_agent_cfg)::set(
this,
"agent",
"cfg",
cfg
);
The environment can therefore remain structurally identical while configuration changes its behavior.
Same environment
|
+---- active agent
|
+---- passive agent
|
+---- different interface
|
+---- different test configuration
Reuse becomes much easier when structure and configuration are separated.
Step 12: Debug the environment from the outside in
When a complete environment does not behave correctly, debug the architecture in layers rather than changing every component at once.
- Hierarchy: Did the environment create the expected children?
- Configuration: Did each agent receive the correct configuration?
- Agent mode: Are the required agents active or passive?
- Internal agent connections: Is each active sequencer connected to its driver?
- Environment connections: Are monitor analysis ports connected?
- Stimulus: Did the sequence reach the driver?
- Observation: Did the monitor publish the expected transactions?
- Checking: Did the scoreboard receive them?
- Coverage: Did the coverage component receive observations?
Configuration
|
v
Environment hierarchy
|
v
Agent connections
|
v
Stimulus
|
v
DUT
|
v
Monitor observations
|
+-----------> Scoreboard
|
+-----------> Coverage
|
+-----------> Reference model
Step 13: Environment architecture versus hierarchy
A component hierarchy tells you what exists. The environment architecture also tells you why those components exist and how they cooperate.
Hierarchy:
uvm_test_top
└── env
├── agent
│ ├── sequencer
│ ├── driver
│ └── monitor
├── scoreboard
└── coverage
Architecture:
Stimulus
|
v
Agent
|
v
DUT
|
v
Monitor
/
v v
SB Coverage
Good UVM architecture makes both views easy to understand.
Try it yourself
Build a bus_env for a simple DUT with one bus interface.
- Create one
bus_agent. - Create a scoreboard.
- Create a coverage subscriber.
- Construct all three in
build_phase(). - Connect the monitor analysis port to both consumers in
connect_phase(). - Configure the agent as active.
- Run a directed sequence containing at least five transactions.
- Verify that the scoreboard receives observations.
- Verify that the coverage component receives the same observations.
- Print the topology and explain the purpose of every component.
Key takeaways
- A
uvm_envcomposes reusable verification components into a coherent testbench. - Agents provide protocol-specific stimulus and observation infrastructure.
- Scoreboards, reference models, and coverage components typically live at the environment level.
- Build creates the environment hierarchy; connect establishes communication between components.
- Monitor analysis ports allow one observation stream to feed multiple consumers.
- Multiple agents allow an environment to model multiple DUT interfaces.
- The environment provides infrastructure; tests and sequences choose the scenarios.
- A reusable environment should not be tightly coupled to one particular test.
Core mental model
Think of the environment as the verification system's wiring and composition layer.
TEST
|
chooses scenario
|
v
+-------------+
| ENV |
| |
| AGENTS |
| | |
| v |
| DUT |
| | |
| MONITORS |
| / \ |
| v v |
| SB COVER |
+-------------+
The most important separation is:
- Sequence: What stimulus should happen?
- Agent: How does that stimulus interact with a protocol?
- Environment: How do the verification components work together?
- Scoreboard: Is the observed behavior correct?
- Coverage: What behavior have we exercised?
- Test: Which configuration and scenario should be executed?
Agents encapsulate protocols. Environments compose verification.
What comes next?
In the next lesson, you will move one level upward and learn Test Architecture: how a UVM test configures the environment, selects sequences, controls the simulation scenario, and becomes the entry point for reusable verification.