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 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_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
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 the
topmodule in Tasting), which in turn calls the
run_testtask of the
m_run_phasestask of the
- For each phase, the
execute_phasetask is called.
- If the phase is a top-down or bottom-up phase,
exec_funcis called for each component.
- For example, the
build_phasefunction of each component.
- If the phase is a task phase,
exec_taskis called for each component.
- For example, the
main_phasetask of each component.
uvm_phasechecks if any objections are raised by the components. The
uvm_objectionobject that the
uvm_phasekeeps track of the number of objections with. When we called
phase.raise_objection()from inside the
jelly_bean_testclass (see the line 27 of the
jelly_bean_testclass in Tasting),
phase_done.raise_objection()is called in the
uvm_phaseunder the hood.
- If no objection is raised, all the processes started by the
exec_taskare 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.