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_phaseuvm_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.

  1. We call run_test (if you don’t remember, see the line 17 of the top module in Tasting), which in turn calls the run_test task of the uvm_root class.
  2. The uvm_root calls the m_run_phases task of the uvm_phase class.
  3. For each phase, the execute_phase task is called.
  4. If the phase is a top-down or bottom-up phase, exec_func is called for each component.
  5. For example, the exec_func calls the build_phase function of each component.
  6. If the phase is a task phase, exec_task is called for each component.
  7. For example, the exec_task calls the main_phase task of each component.
  8. The uvm_phase checks if any objections are raised by the components. The phase_done is the uvm_objection object that the uvm_phase keeps track of the number of objections with. When we called phase.raise_objection() from inside the run_phase of the jelly_bean_test class (see the line 27 of the jelly_bean_test class in Tasting), phase_done.raise_objection() is called in the uvm_phase under the hood.
  9. 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!
  10. The steps 3 to 9 repeat until all phases are executed.

I hope this article helped in your understanding of the UVM phasing.

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页