Interview Essential: "How does UVM end simulation without calling
$finish?"
The Answer:
UVM uses the run_test() task. When all time-consuming phases complete (all
objections dropped), UVM automatically executes all post-run phases (extract, check,
report, final) and then run_test() calls $finish internally.
The Complete Flow:
run_test() is called from your testbench top module
- UVM creates the test component and runs all phases
uvm_root tracks objection counts across all phases
- When run_phase objections hit zero, run_phase ends
- Post-simulation phases execute (extract → check → report → final)
run_test() calls $finish and simulation ends
module tb_top;
// DUT and interface instantiation
my_if m_if();
my_dut dut(.clk(m_if.clk), .data(m_if.data));
initial begin
// Pass interface to UVM
uvm_config_db#(virtual my_if)::set(null, "*", "vif", m_if);
// Start UVM - this handles $finish internally
run_test("my_test");
// Code after run_test() never executes
end
endmodule
Pro Tip: Forcing Early Termination
If you need to end simulation early (e.g., on fatal error), you
can call:
uvm_top.stop_request() - Graceful shutdown after completing current
transactions
global_stop_request() - Legacy method, still works