Why run_phase is virtual in driver class?

In reply to VK_18:

In your example:

  • uvm_driver is base class, and you declared run_phase with virtual.
  • my_driver is derived from uvm_driver, you didn’t declare run_phase with virtual keyword, but according to LRM, the run_phase of my_driver is virtual implicitly.
  • update_driver is derived from my_driver, and the run_phase also virtual implicitly.

When you assign m_inst = up_inst, the polymorphism happened, you can see the message when you call m_inst.run_phase: “update_driver”, it means the run_phase of update_driver was executed.

Let remove the virtual keyword in uvm_driver class, you will see the message: “my_driver”.