UVM Tutorial for Candy Lovers – 22. Phasing
When we created the jelly_bean_driver
in Agent, we coded the build_phase
function and the run_phase
task, but who actually calls them? The answer is uvm_phase
class.
UVM Phases
UVM has nine common phase classes (shown in yellow) and twelve run-time phase classes (shown in pink). These phase classes are derived from the uvm_topdown_phase
, uvm_bottomup_phase
, or uvm_task_phase
classes, which in turn are derived from the uvm_phase
class. The uvm_phase
class has a virtual function called exec_func
and a virtual task called exec_task
. The phase classes derived from the uvm_topdown_phase
and the uvm_bottomup_phase
implement the exec_func
, while the phase classes derived from the uvm_task_phase
implement the exec_task
. As shown in the diagram, each phase class calls the corresponding phase function or task of the uvm_component
. For example, the exec_func
of the uvm_build_phase
class calls the build_phase
function of the uvm_component
, and the exec_task
of the uvm_run_phase
class calls the run_phase
task of the uvm_component
, etc.
Simplified Flow
The way UVM phases are implemented is rather complicated, but here is a simplified flow.
- We call
run_test
(if you don’t remember, see the line 17 of thetop
module in Tasting), which in turn calls therun_test
task of theuvm_root
class. - The
uvm_root
calls them_run_phases
task of theuvm_phase
class. - For each phase, the
execute_phase
task is called. - If the phase is a top-down or bottom-up phase,
exec_func
is called for each component. - For example, the
exec_func
calls thebuild_phase
function of each component. - If the phase is a task phase,
exec_task
is called for each component. - For example, the
exec_task
calls themain_phase
task of each component. - The
uvm_phase
checks if any objections are raised by the components. Thephase_done
is theuvm_objection
object that theuvm_phase
keeps track of the number of objections with. When we calledphase.raise_objection()
from inside therun_phase
of thejelly_bean_test
class (see the line 27 of thejelly_bean_test
class in Tasting),phase_done.raise_objection()
is called in theuvm_phase
under the hood. - If no objection is raised, all the processes started by the
exec_task
are killed. In other words, unless an objection is raised, the phase is immediately killed! - The steps 3 to 9 repeat until all phases are executed.
I hope this article helped in your understanding of the UVM phasing.