RTL Studio Open IDE

4.4 · UVM CLASS

Factory override: swap in error-injection sequence

Override the factory to replace a normal sequence with an error-injection sequence without editing base code.

Watch on YouTube

What you practice

Factory override: swap in error-injection sequence (4.4). Override the factory to replace a normal sequence with an error-injection sequence without editing base code. It is in Factory override — Part 4 · Advanced UVM of the UVM Masterclass. Factory, config objects, virtual sequences, and pipelined drivers for large SoC verification.

The UVM bench compiles in that same browser SystemVerilog simulator. You edit the test in the IDE, run Verilator, and read the log beside the waveform.

What you will learn

You will learn how to use the UVM factory to replace a standard sequence with an error-injection sequence at runtime using set_type_override, without modifying the base testbench or environment.

Learning objectives

  • Understand the purpose and use of set_type_override in the UVM factory.
  • Locate and edit the test’s build_phase to register the override.
  • Run simulation and verify that the error-injection sequence executes instead of the base sequence.
  • Confirm correct behavior via INFO: log lines in the Log panel.

Theory

The UVM factory enables dynamic type substitution at runtime. This is essential for verification reuse: the same environment can run different sequences (e.g., normal vs. error) without duplicating code.

MethodPurpose
set_type_override(base_type, derived_type)Replaces base_type with derived_type globally for all subsequent create() calls
override_type::get_type()Returns the type ID of the derived sequence
build_phaseWhere set_type_override must be called before run_test

Override registration must happen *before* the test’s run_phase begins — typically in the test’s build_phase. The factory uses type IDs to resolve which class to instantiate when sequence::type_id::create("name") is called.

Practice

  1. Open this chapter in RtlStudio.

Files appear in Explore under student/rtl/ and student/tb/.

  1. Open student/tb/tb_top.sv in the editor.
  2. In the initial block, locate the fifo_error_test instantiation and run_test call.
  3. Add the factory override line in the build_phase of fifo_error_test:

This must be placed *before* run_test(...) is called.

  1. Run Simulation and check the Log panel for INFO: lines.
  2. If VCD is enabled, open the Waveform tab to inspect signal behavior aligned with the log checkpoints.

Summary

You practiced injecting a custom error sequence into a UVM test by registering a factory override in the test’s build_phase. This technique decouples test behavior from environment code, enabling reuse and targeted fault injection. In real verification flows, this allows engineers to swap sequences for stress, corner-case, or error scenarios without duplicating the entire testbench.

Run it in the Verilog IDE

  1. Open the UVM workspace in the IDE. The DUT and the testbench compile together in the browser.
  2. Run the SystemVerilog simulation with Verilator and read the phase and scoreboard lines in the log.
  3. When the check is on pins rather than a print, open the VCD next to that log.
  4. Edit the sequence, driver, or scoreboard in the IDE and rerun. You stay in the same simulator.

The lesson is done when the simulation matches Factory override: swap in error-injection sequence. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.