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 thetopmodule in Tasting), which in turn calls therun_testtask of theuvm_rootclass. - The
uvm_rootcalls them_run_phasestask of theuvm_phaseclass. - 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
exec_funccalls thebuild_phasefunction of each component. - If the phase is a task phase,
exec_taskis called for each component. - For example, the
exec_taskcalls themain_phasetask of each component. - The
uvm_phasechecks if any objections are raised by the components. Thephase_doneis theuvm_objectionobject that theuvm_phasekeeps track of the number of objections with. When we calledphase.raise_objection()from inside therun_phaseof thejelly_bean_testclass (see the line 27 of thejelly_bean_testclass in Tasting),phase_done.raise_objection()is called in theuvm_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.