Automatic Phase Objection in UVM: How and When to Use It
In short: call set_automatic_phase_objection(1) in a sequence, and UVM raises an objection just before the sequence starts and drops it just after it finishes. It only works when the test ties the sequence to a phase with set_starting_phase(phase). Never use it on a sequence that never returns, and never fork work that outlives body(), because the objection follows body(), not your threads.
Raising and dropping objections by hand is easy to get wrong.
Forget the raise and nothing runs. Forget the drop and nothing ends.
The automatic phase objection takes that bookkeeping off your hands for the everyday case: a sequence that starts, does its work and returns. This lesson runs it five ways on Synopsys VCS, including the three ways it quietly fails.
By the end of this lesson, you’ll be able to:
- Turn on the automatic phase objection and tie a sequence to a phase.
- Say exactly when UVM raises and drops the objection for you.
- Recognise its three failures: no starting phase, a forever loop and a forked tail.
- Choose between manual and automatic objections for a sequence.
The picture: a badge reader at the office door
Think of an office building with a security desk.
The old way, every visitor signs a book on the way in and signs out on the way out. Forget to sign in, and security thinks the building is empty and locks up with you inside. Forget to sign out, and security waits all night for you.
The new way is a badge reader on the door. It logs you in the moment you walk in and out the moment you walk out. You never touch the book.
But a badge reader has two blind spots. It has to be set up for the right building, and it only sees you. It has no idea what you left running inside.
| At the office | In UVM | What it means |
|---|---|---|
| Signing the visitor book by hand | Manual raise_objection() and drop_objection() | You do the bookkeeping |
| The badge reader | set_automatic_phase_objection(1) | UVM does it for you |
| Walking through the door | start() is called | Raise, just before pre_start() |
| Walking out | The sequence returns | Drop, just after post_start() |
| Which building the reader belongs to | set_starting_phase(phase) | The phase to object to |
| A reader that isn’t set up for this building | No starting phase | Nobody is logged in, so the building locks at once |
| Never walking out | A forever loop | Security waits all night |
| Leaving your assistant inside to finish | A fork ... join_none in body() | You’re logged out, the building locks, the assistant gets thrown out |
Each of the five runs below is one row of this table.
The starting phase
UVM can only object to a phase it knows about. The test tells the sequence which phase it belongs to with set_starting_phase():
task run_phase(uvm_phase phase);
auto_seq seq = auto_seq::type_id::create("seq");
seq.set_starting_phase(phase); // now UVM knows which phase to object to
seq.start(sqr); // no raise or drop here
endtask
If the starting phase is null, there’s nothing to object to, and the automatic objection does nothing. The older starting_phase variable is deprecated in UVM 1.2. Use set_starting_phase() and get_starting_phase().
This is setting up the badge reader for the right building. A reader with no building logs nobody in, and the run below shows that costs you the whole test, without a single warning.
Turning the automatic objection on
One call, usually in the sequence’s constructor, so every instance carries it:
class auto_seq extends uvm_sequence #(bus_item);
`uvm_object_utils(auto_seq)
function new(string name = "auto_seq");
super.new(name);
set_automatic_phase_objection(1);
endfunction
task body();
repeat (8) `uvm_do(req)
endtask
endclass
Here’s when the objection is up:
start()is called.- UVM raises the objection.
pre_start(),pre_body(),body(),post_body()andpost_start()run.- UVM drops the objection.
start()returns.
The drop is tied to the sequence returning. Anything still running after that is not covered.
Five runs, one bench
One sequence with a couple of knobs, a simple driver, and a test that starts the sequence five different ways with +MODE=. Every run has +UVM_OBJECTION_TRACE on, so you can see exactly when UVM raises and drops for you. The sequence prints a line in pre_start() and post_start(), and the test prints when the run phase ended and how many items were sent.
Real output, Synopsys VCS X-2025.06-SP1 with UVM 1.2, every run with +UVM_OBJECTION_TRACE:
| Run | Who raised | Raised | Dropped | Run phase ended | Items sent | What the log says |
|---|---|---|---|---|---|---|
manual | uvm_test_top | 0 ns | 155 ns | 155 ns | 8 | Clean |
auto | uvm_test_top.sqr.seq | 0 ns, before pre_start | 155 ns, after post_start | 155 ns | 8 | Clean |
no_phase | nobody | never | never | 0 ns | 0 | Nothing. No warning, no error |
forever_body | uvm_test_top.sqr.seq | 0 ns | never | 2000 ns | n/a | UVM_FATAL [PH_TIMEOUT] |
fork_tail | uvm_test_top.sqr.seq | 0 ns | 155 ns | 155 ns | 8 of 13 | UVM_ERROR [SEQFINERR] |
manual and auto ended at exactly the same time. Same 8 items, same 155 ns. The only difference is who holds the objection. In the automatic run, the trace names the sequence itself, uvm_test_top.sqr.seq, with the reason “automatic phase objection”:
UVM_INFO @ 0: run [OBJTN_TRC] Object uvm_test_top.sqr.seq raised 1 objection(s) (automatic phase objection): count=1 total=1
UVM_INFO @ 0: uvm_test_top.sqr@@seq [SEQ] pre_start
UVM_INFO @ 155: uvm_test_top.sqr@@seq [SEQ] post_start
UVM_INFO @ 155: run [OBJTN_TRC] Object uvm_test_top.sqr.seq dropped 1 objection(s) (automatic phase objection): count=0 total=0
The raise comes before pre_start, and the drop comes after post_start. That’s the timeline from the section above, confirmed in a real log.
no_phase failed in total silence. The automatic objection was on, but there was no starting phase to object to. The trace printed nothing, pre_start ran at 0 ns, and the run phase ended at once with 0 items sent. Zero warnings, zero errors. In a regression, that’s a pass.
forever_body never dropped. The raise came at 0 ns, post_start never printed, and the 2 us global timeout ended the run with a fatal.
fork_tail lost every forked item. body() sent its 8 items, forked off 5 more and returned. The objection dropped at 155 ns, the phase ended, and none of the 5 extra items was sent. This time UVM did complain:
UVM_ERROR @ 155: uvm_test_top.sqr [SEQFINERR] Parent sequence 'uvm_test_top.sqr.seq' should not finish before all items from itself and items from descendent sequences are processed. The item request from the sequence 'uvm_test_top.sqr.seq' is being removed.
If you see SEQFINERR, look for a fork ... join_none inside body().
Back at the office: manual and auto are the same visit, once with the book and once with the badge, and you leave at the same minute either way. no_phase is a reader that was never set up for this building, so security saw an empty building and locked it at once. forever_body is a visitor who never walks out. And fork_tail is the visitor who walks out and leaves an assistant inside to finish five more jobs. The reader logs the visitor out, security locks up, and the assistant is shown the door with the jobs undone. That’s SEQFINERR.
Manual or automatic?
| Manual raise and drop | Automatic phase objection | |
|---|---|---|
| Where you write it | In the test or in body() | One call in the sequence constructor |
| Needs a starting phase | No | Yes, set_starting_phase() |
| Safe with a forever loop | Yes, you decide when to drop | No, the objection never drops |
Covers work forked off in body() | Yes, if you drop after it ends | No, the drop happens when body() returns |
| Risk of a forgotten drop | Real | None |
| Best for | Endless traffic, condition-based ends | Simple sequences that run once |
The one rule you must not break
Never turn on the automatic objection for a sequence that doesn’t return.
A badge reader can only log you out when you walk out. If you never walk out, security waits all night.
UVM drops the objection only when the sequence finishes. A forever loop never finishes, so the phase can never end. For endless traffic, use the manual pattern and drop the objection when a real end condition is met, as shown in How to Terminate UVM Test? (UVM Objections).
If a test does hang this way, Why Does My UVM Test Never End walks through finding the stuck objection in minutes.
Common mistakes, with fixes
Turning it on but forgetting set_starting_phase(). The starting phase is null, nothing is raised, and the test ends at 0 ns with no warning at all.
- Fix A: call
seq.set_starting_phase(phase)in the test beforeseq.start(). - Fix B: in the sequence’s
pre_start(), warn ifget_starting_phase()is null, so this never fails silently.
Using it on a sequence with a forever loop. The objection is held forever.
- Fix: use the manual pattern for endless traffic.
Forking work that outlives body(). The objection drops when body() returns. In the run above, none of the 5 forked items was sent, and UVM reported SEQFINERR.
- Fix A: wait for the forked threads inside
body()before returning. - Fix B: if they really must run on, hold the phase open with a manual objection in the test.
Mixing manual and automatic on the same sequence. It still works if every raise has a drop, but the count goes to 2 and the trace gets harder to read.
- Fix: pick one style per sequence.
Using the deprecated starting_phase variable. It still works in UVM 1.2 but is gone in IEEE 1800.2.
- Fix: use
set_starting_phase()andget_starting_phase().
How AI helps (and where it doesn’t)
- Reviewing a sequence. Paste a sequence and ask whether it’s safe to give it an automatic objection. A good assistant will spot a forever loop or a fork that outlives
body(). - Reading a trace. Paste the
+UVM_OBJECTION_TRACEoutput and ask when the objection went up and down, and why the phase ended where it did.
Where to be careful: assistants often suggest the old starting_phase variable, because there’s so much old code online. Check that they use set_starting_phase(). And only a run tells you the sequence really ends.
Interview questions
These come up a lot in UVM interviews. Try answering each one before reading the answer.
- What does set_automatic_phase_objection(1) do? UVM raises an objection just before
pre_start()and drops it just afterpost_start(), so the sequence holds the phase open while it runs. - Why do you also need set_starting_phase()? UVM can only object to a phase it knows. Without it, nothing is raised, and in our run the test ended at 0 ns with no warning.
- Can you use it on a sequence with a forever loop? No. The drop only happens when the sequence returns, and a forever loop never returns. Our run hit the global timeout.
- What does SEQFINERR mean? A parent sequence finished while its items were still waiting. It’s the classic sign of a
fork ... join_noneinsidebody(). - starting_phase or set_starting_phase()?
set_starting_phase()andget_starting_phase(). Thestarting_phasevariable is deprecated in UVM 1.2.
Practice challenge
Take the full code below and try this:
- Fix
+MODE=fork_tailby addingwait fork;at the end ofbody(). All 13 items should now be sent. - Undo that, and fix it a second way: hold the phase in the test with a manual objection until the driver has sent 13.
- In
pre_start(), warn whenget_starting_phase()is null, then rerun+MODE=no_phase.
You’ll know step 3 works when the silent run now prints your warning at 0 ns.
Frequently asked questions
What does set_automatic_phase_objection do?
It makes UVM raise an objection to the starting phase just before the sequence runs, and drop it just after it finishes, so you don’t call raise_objection() and drop_objection() yourself.
Why do I also need set_starting_phase?
UVM can only object to a phase it knows about. Without a starting phase, the automatic objection does nothing and the test can end at 0 ns.
Can I use it with a forever loop?
No. The objection drops only when the sequence returns, and a forever loop never returns.
When exactly is the objection raised and dropped?
Raised just before pre_start(), dropped just after post_start(). It covers the whole sequence, but nothing that keeps running after it returns.
Is starting_phase the same as set_starting_phase?
Same idea, but the starting_phase variable is deprecated. Use set_starting_phase() and get_starting_phase().
Should I use manual or automatic objections?
Automatic for simple sequences that run once. Manual for endless traffic or a condition-based end, where you need to decide when the objection drops.
Full code
One file: the sequence, a driver and a test that starts the sequence five ways. On EDA Playground choose Synopsys VCS and UVM 1.2, set the top module to top, and run once per +MODE= option with +UVM_OBJECTION_TRACE.
// auto_objection_demo.sv : the automatic phase objection, five runs, one bench
// The Art of Verification | theartofverification.com
//
// Run options (one per run), each with +UVM_OBJECTION_TRACE:
// +MODE=manual the test raises and drops by hand (for comparison)
// +MODE=auto set_automatic_phase_objection(1) plus set_starting_phase
// +MODE=no_phase automatic objection on, but set_starting_phase is missing
// +MODE=forever_body automatic objection on a sequence that never returns
// +MODE=fork_tail body() forks off 5 more items and returns before they are sent
//
// Run on Synopsys VCS X-2025.06-SP1 with UVM 1.2 (EDA Playground), 23 Nov 2026.
`timescale 1ns/1ns
`include "uvm_macros.svh"
import uvm_pkg::*;
string MODE = "auto";
interface bus_if (input logic clk);
logic valid;
logic [7:0] data;
endinterface
class bus_item extends uvm_sequence_item;
rand bit [7:0] data;
`uvm_object_utils(bus_item)
function new(string name = "bus_item");
super.new(name);
endfunction
endclass
// One sequence, with knobs for each run
class auto_seq extends uvm_sequence #(bus_item);
`uvm_object_utils(auto_seq)
int num_items = 8;
bit forever_body = 0;
bit fork_tail = 0;
function new(string name = "auto_seq");
super.new(name);
set_automatic_phase_objection(1); // UVM raises before pre_start, drops after post_start
endfunction
task pre_start();
`uvm_info("SEQ", "pre_start", UVM_NONE)
endtask
task body();
if (forever_body) begin
forever `uvm_do(req) // never returns, so the objection never drops
end else begin
repeat (num_items) `uvm_do(req)
if (fork_tail)
fork
repeat (5) `uvm_do(req) // still running after body() returns
join_none
end
endtask
task post_start();
`uvm_info("SEQ", "post_start", UVM_NONE)
endtask
endclass
class bus_driver extends uvm_driver #(bus_item);
`uvm_component_utils(bus_driver)
virtual bus_if vif;
int sent;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
task run_phase(uvm_phase phase);
vif.valid <= 1'b0;
forever begin
seq_item_port.get_next_item(req);
@(posedge vif.clk);
vif.valid <= 1'b1;
vif.data <= req.data;
@(posedge vif.clk);
vif.valid <= 1'b0;
sent++;
seq_item_port.item_done();
end
endtask
endclass
class auto_test extends uvm_test;
`uvm_component_utils(auto_test)
uvm_sequencer #(bus_item) sqr;
bus_driver drv;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
virtual bus_if vif;
if (!uvm_config_db#(virtual bus_if)::get(this, "", "vif", vif))
`uvm_fatal("NOVIF", "bus_if not set")
sqr = uvm_sequencer#(bus_item)::type_id::create("sqr", this);
drv = bus_driver::type_id::create("drv", this);
drv.vif = vif;
endfunction
function void connect_phase(uvm_phase phase);
drv.seq_item_port.connect(sqr.seq_item_export);
endfunction
task run_phase(uvm_phase phase);
auto_seq seq = auto_seq::type_id::create("seq");
case (MODE)
"manual": begin
seq.set_automatic_phase_objection(0);
phase.raise_objection(this, "manual");
seq.start(sqr);
phase.drop_objection(this, "manual");
end
"auto": begin
seq.set_starting_phase(phase);
seq.start(sqr);
end
"no_phase": begin
seq.start(sqr); // set_starting_phase is missing
end
"forever_body": begin
seq.forever_body = 1;
seq.set_starting_phase(phase);
seq.start(sqr);
end
"fork_tail": begin
seq.fork_tail = 1;
seq.set_starting_phase(phase);
seq.start(sqr);
end
default: `uvm_fatal("MODE", {"unknown +MODE=", MODE})
endcase
endtask
function void report_phase(uvm_phase phase);
`uvm_info("END", $sformatf("MODE=%s run phase ended at %0t: items sent=%0d",
MODE, $time, drv.sent), UVM_NONE)
endfunction
endclass
module top;
logic clk = 1'b0;
bus_if b (clk);
initial begin
void'($value$plusargs("MODE=%s", MODE));
`uvm_info("TOP", {"Running with MODE=", MODE}, UVM_NONE)
fork
forever #5 clk = ~clk;
join_none
if (MODE == "forever_body") uvm_top.set_timeout(2us, 0); // ends the hang
uvm_config_db#(virtual bus_if)::set(null, "uvm_test_top", "vif", b);
run_test("auto_test");
end
endmodule
References
- Accellera UVM downloads and class reference
- IEEE 1800.2 standard for UVM (this lesson runs on UVM 1.2)
Read next
- How to Terminate UVM Test? (UVM Objections) (lesson 18)
- UVM Verbosity and Reporting (lesson 20)
- UVM sequencer and driver communication
- Why Does My UVM Test Never End?
Part of the learning path UVM methodology
