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_overridein the UVM factory. - Locate and edit the test’s
build_phaseto 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.
| Method | Purpose |
|---|---|
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_phase | Where 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
- Open this chapter in RtlStudio.
Files appear in Explore under student/rtl/ and student/tb/.
- Open
student/tb/tb_top.svin the editor. - In the
initialblock, locate thefifo_error_testinstantiation andrun_testcall. - Add the factory override line in the
build_phaseoffifo_error_test:
This must be placed *before* run_test(...) is called.
- Run Simulation and check the Log panel for
INFO:lines. - 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
- Open the UVM workspace in the IDE. The DUT and the testbench compile together in the browser.
- Run the SystemVerilog simulation with Verilator and read the phase and scoreboard lines in the log.
- When the check is on pins rather than a print, open the VCD next to that log.
- 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.