Vertical Reuse of a Block Environment
A block team's UVM environment has agents, monitors, a register model and a scoreboard. At chip level most of it comes along, but its drivers must stay behind, because the chip now drives the block. Learn what moves up, what goes passive, what is replaced, and how a virtual sequencer ties the chip's agents together.
You Will Be Able To
- Sort the parts of a block environment into reused, reused passive, left behind and replaced.
- Switch an agent to passive through its configuration, and say what it then builds.
- Feed a scoreboard from a monitor so that it works at both levels.
- Explain what a virtual sequencer holds and why a chip test needs one.
- Lesson
- V3.6
- Time
- 26 min
- Runs on
- Your browser
- Check
- 5 questions
Picture a UART0 environment that passed every block test. Lifted into the chip, its scoreboard reports every byte on the pad as unexpected. Nothing is wrong with the chip. The scoreboard always learned what to expect from its own driver, and at chip level that driver never runs.
- Sequence
- Manager
- Peripheral
- Test
- Result
- Bus
- Control / FSM
- Data
- Control
- Block level
The agent is active: sequences go through the driver into UART0, and the monitor watches.
- Chip level
The fabric drives UART0. The agent is passive: no driver, no sequencer, the same monitor.
- What carries the checking
The scoreboard takes what the monitor saw. A virtual sequencer coordinates the chip's own agents.
Read the diagram as text
- Block sequences: write TXDATA, DIV
- Driver: block level only
- UART0: the block
- Monitor: both levels
- Scoreboard: expects from the monitor
- Chip fabric: chip level: drives UART0
- Virtual sequencer: chip level: one handle per agent
- Driver → UART0: block level
- Block sequences → Driver: items
- Chip fabric → UART0: chip level
- UART0 → Monitor: read only
- Monitor → Scoreboard: transactions
- Virtual sequencer → Chip fabric: chip tests
The pattern of the UVM Cookbook's testbench architecture, drawn for UART0 of ap_soc.
Before You Start
Read Passive Checkers: Bind and Listen first. The UVM track teaches the machinery: Active and Passive Agents and Vertical Reuse.
| Question | |
|---|---|
| 1 | Why can a block's driver not come along into the chip? |
| 2 | What does a passive agent build, and how is it told to be passive? |
| 3 | Where must a reused scoreboard get its expected values? |
| 4 | What does a virtual sequencer hold? |
| 5 | What did the chip's own UVM environment do in one run, and what did it cost to build? |
The Idea: The Chip Takes the Wheel
At block level the environment is the block's whole world: its driver writes the block's registers, and its monitor watches them. At chip level the chip's fabric writes those registers, under firmware or a bus manager. A second driver on the same port would fight the fabric, so the driver must stay behind.
Everything that only watches comes along: monitors, coverage, register models, scoreboards. That is most of the value of the block team's work. It is why environments switch between active and passive with one setting.
New Words
| Word | Meaning |
|---|---|
| Vertical reuse | Using a block's verification environment again inside a larger one: a subsystem or the chip. |
| Agent | A UVM component that bundles a driver, a sequencer and a monitor for one interface. |
| is_active | An agent's setting: UVM_ACTIVE builds a driver and a sequencer, UVM_PASSIVE builds only the monitor. |
| Configuration database | uvm_config_db: where a parent sets values that its children read when they are built. |
| Scoreboard | A component that compares what should have happened with what did. |
| Virtual sequencer | A sequencer that holds handles to other sequencers, so one sequence can drive several agents in step. |
The Smallest Example: Sort the UART0 Environment
Before the chip's own environment, sort a block environment for UART0 by one question. Does the part drive the block's port?
| Part | Drives the port? | At chip level |
|---|---|---|
| APB driver and sequencer | yes | left behind: the fabric drives UART0 |
| APB monitor | no | comes along |
| UART pad agent | drives the pad, not the port | comes along: the pads are still the outside world |
| Register model of UART0 | no | comes along, mapped at UART0's base in the chip's model |
| Scoreboard fed by the APB driver | no, but leans on the driver | replaced: feed it from the monitor |
| Block sequences | through the driver | left behind, or rewritten as chip sequences |
The Rules
Rule 1: Make every agent switchable.
Build the driver and the sequencer only when is_active is UVM_ACTIVE; build the monitor always.
Rule 2: Set the mode from above.
The chip environment sets is_active for the reused agent through the configuration database before it is built.
Rule 3: Check from monitors, never from drivers.
A scoreboard fed by a monitor works at both levels; one fed by a driver goes deaf at chip level.
Rule 4: Coordinate with a virtual sequencer.
Keep one handle for each agent that still drives. Then a chip test can start traffic on the bus and the pads in step.
Rule 5: Keep the build small enough to run.
A chip-sized UVM build costs minutes; reuse at the level a test needs.
Sources for These Rules
Agents, is_active and the configuration database: IEEE 1800.2-2020 13.4 (uvm_agent) and F.2 (uvm_active_passive_enum); checked in uvm-core 2020.3.1, src/comps/uvm_agent.svh.
Vertical reuse, passive agents and virtual sequencers: UVM Cookbook, Testbench Architecture and Sequences chapters (UVM-CB).
The chip's environment: tools/soc/ap_soc/bench/soc_tb/soc_uvm/ and README.md; its build time: plan §3.10, stage E7.
The Lab: The Chip's Own UVM Environment
soc_tb has a third front end, in soc_uvm/. It has a bus agent on the core's seat and pad agents for UART, GPIO, JTAG and the flash. It also has a generated register model, a UART scoreboard and a virtual sequencer. Be clear about what it is. It was written for the chip, not lifted from a block bench. So it shows the receiving end of reuse: the parts a reused agent plugs into.
bus = soc_bus_agent::type_id::create("bus", this);
bus.api = api;
uart = pad("uart"); gpio = pad("gpio"); jtag = pad("jtag"); spi = pad("spi");
regs = soc_reg_block::type_id::create("regs");
regs.build(); virtual function void build_phase(uvm_phase phase);
monitor = soc_bus_monitor::type_id::create("monitor", this);
monitor.api = api;
if (get_is_active() == UVM_ACTIVE) begin
sequencer = uvm_sequencer #(soc_bus_item)::type_id::create("sequencer", this);
driver = soc_bus_driver::type_id::create("driver", this);
driver.api = api;
end
endfunctionRule 1 at work in the bus agent. On the seat it is active, so all three parts exist. With the processor in the seat the same agent would have to be passive, and only its monitor would be built. One detail is a warning, not a model. The flash's pad agent listens only, but it decides that by its kind, not by is_active. A reusable agent should not take that shortcut.
class soc_vsequencer extends uvm_sequencer;
uvm_sequencer #(soc_bus_item) bus;
uvm_sequencer #(soc_pad_item) uart, gpio, jtag;
soc_reg_block regs;
soc_api api;Rule 4 at work: a chip test starts one virtual sequence on soc_vsequencer. From there it reaches the bus agent, the UART, GPIO and JTAG agents, and the register model. The build ran once on the site's UVM engine, Verilator 5.052 with uvm-core 2020.3.1, at -O0.
That build is slow. On the development laptop, a WSL machine shared with other jobs, five builds took 49 to 134 s. Three were in the bench's own gate, and two in this module's recordings, under load.
soc_pads_test:
verdict=pass
reason=pass
status=0000900d
cycles=1717
uart_bytes=2
spi_frames=1
jtag_scans=7
bus_transfers=57
checker_errors=0
UVM_ERROR=0 UVM_FATAL=0The test sent a byte each way on the UART pads (uart_bytes = 2) and read the flash (spi_frames = 1). It ran JTAG scans (jtag_scans = 7), all through UVM agents. It ended the way firmware does, with the pass word, under the bench's own end-of-test rules.
soc_pads_test +uart_div=3:
verdict=fail
reason=checker
uart_bytes=3
checker_errors=1The board's UART model now reads the chip's frames at the wrong bit time and counts a frame error. The bench's checker count ends the run as a fail. The scoreboard is not needed to see this: the passive parts of the bench and of the environment agree.
Why It Is Built This Way
Why not write the chip environment from scratch? Because the block team's monitors, register model and coverage already encode months of knowledge about the block. Reusing them passively costs a configuration setting; rewriting them costs the same months again, with new bugs.
Why keep the UVM practice problem small? The live server ran the chip bench about 3.5 times slower than the laptop when it was measured. Scaled by that factor, the chip environment would take an estimated 3 to 8 minutes there. One check may take 240 s. So the practice problem reuses a block environment inside a small fixture that plays the chip around it. Its page says what the fixture leaves out.
Traps
The trap of the hook is the scoreboard that listens to its driver. At block level it is a convenient shortcut: the driver knows what it sent. At chip level no driver runs, the expected queue stays empty, and every real byte looks unexpected. Worse, at block level it can hide a bus bug, because it trusts the driver's word instead of the bus.
The second trap is a build_phase that forgets its parent. uvm_agent reads is_active from the configuration database in its own build_phase. An agent whose build_phase never calls super.build_phase keeps the default, UVM_ACTIVE, and builds a driver the chip never asked for.
At Scale
This section looks ahead. ap_soc's environment has one bus agent and four pad agents.
Subsystem first
Block environments are usually reused twice: into a subsystem environment, then into the chip. Each level sets its children passive.
Register models in layers
The chip's register model contains each block's model as a sub-block at its base address, generated from one register database.
Emulation and silicon
Passive monitors and scoreboards can follow the design onto an emulator; drivers are replaced by transactors or by firmware.
Try It
Run it: one agent module, instantiated twice. Active, it drives three transfers; passive, it drives nothing and the "fabric" does.
In both places the monitor sees three transfers. That is why checking hangs off the monitor.
Make the chip-level agent active as well. What happens on its bus, and why would a real chip test now be wrong?
block level: driver on, monitor saw 3 chip level: driver off, monitor saw 3Check Yourself
Common Mistakes
Wrong Feed a scoreboard from the driver's announcement of what it sent.
At chip level the driver is gone, so the scoreboard expects nothing.
Fix Feed it from a monitor of the bus, which works at both levels.
Wrong Override build_phase without calling super.build_phase in an agent.
is_active is then never read, and the agent stays active.
Fix Call super.build_phase first, then test get_is_active().
Wrong Rebuild the whole chip environment for a small reuse question.
A chip-sized UVM build takes minutes; most of it is irrelevant to the question.
Fix Reuse the block environment inside the smallest fixture that plays its surroundings.
Remember
- Monitors, coverage, register models and scoreboards come along into the chip; drivers stay behind.
- is_active, set through the configuration database, decides what an agent builds.
- Scoreboards must take their expectations from monitors, never from drivers.
- A virtual sequencer holds a handle for each agent that drives; soc_vsequencer holds four, plus the register model and the bench's doors.