ovm_phase

The ovm_phase class is used for defining phases for ovm_component and its subclasses.  For a list of predefined phases see ovm_component::Phasing Interface

Summary
ovm_phase
The ovm_phase class is used for defining phases for ovm_component and its subclasses.
Class Declaration
virtual class ovm_phase
Methods
newCreates a phase object.
get_nameReturns the name of the phase object as supplied in the constructor.
is_taskReturns 1 if the phase is time consuming and 0 if not.
is_top_downReturns 1 if the phase executes top-down (executes the parent¿s phase callback before executing the children¿s callback) and 0 otherwise.
get_type_nameDerived classes should override this method to return the phase type name.
wait_startWaits until the phase has beed started.
wait_doneWaits until the phase has been completed.
is_in_progressReturns 1 if the phase is currently in progress (active), 0 otherwise.
is_doneReturns 1 if the phase has completed, 0 otherwise.
resetResets phase state such that is_done and is_in_progress both return 0.
call_taskCalls the task-based phase of the component given by parent, which must be derived from ovm_component.
call_funcCalls the function-based phase of the component given by parent.

new

function new (string name,
bit is_top_down,
bit is_task)

Creates a phase object.

The name is the name of the phase.  When is_top_down is set, the parent is phased before its children. is_task indicates whether the phase callback is a task (1) or function (0).  Only tasks may consume simulation time and execute blocking statements.

get_name

function string get_name ()

Returns the name of the phase object as supplied in the constructor.

is_task

function bit is_task ()

Returns 1 if the phase is time consuming and 0 if not.

is_top_down

function bit is_top_down ()

Returns 1 if the phase executes top-down (executes the parent¿s phase callback before executing the children¿s callback) and 0 otherwise.

get_type_name

virtual function string get_type_name()

Derived classes should override this method to return the phase type name.

wait_start

task wait_start ()

Waits until the phase has beed started.

wait_done

task wait_done ()

Waits until the phase has been completed.

is_in_progress

function bit is_in_progress ()

Returns 1 if the phase is currently in progress (active), 0 otherwise.

is_done

function bit is_done ()

Returns 1 if the phase has completed, 0 otherwise.

reset

function void reset ()

Resets phase state such that is_done and is_in_progress both return 0.

call_task

virtual task call_task (ovm_component parent)

Calls the task-based phase of the component given by parent, which must be derived from ovm_component.  A task-based phase is defined by subtyping ovm_phase and overriding this method.  The override must $cast the base parent handle to the actual component type that defines the phase callback, and then call the phase callback.

call_func

virtual function void call_func (ovm_component parent)

Calls the function-based phase of the component given by parent.  A function-based phase is defined by subtyping ovm_phase and overriding this method.  The override must $cast the base parent handle to the actual component type that defines the phase callback, and then call that phase callback.

Usage

Phases are a synchronizing mechanism for the environment.  They are represented by callback methods.  A set of predefined phases and corresponding callbacks are provided in ovm_component.  Any class deriving from ovm_component may implement any or all of these callbacks, which are executed in a particular order.  Depending on the properties of any given phase, the corresponding callback is either a function or task, and it is executed in top-down or bottom-up order.

The OVM provides the following predefined phases for all ovm_components.

buildDepending on configuration and factory settings, create and configure additional component hierarchies.
connectConnect ports, exports, and implementations (imps).
end_of_elaborationPerform final configuration, topology, connection, and other integrity checks.
start_of_simulationDo pre-run activities such as printing banners, pre-loading memories, etc.
runMost verification is done in this time-consuming phase.  May fork other processes.  Phase ends when global_stop_request is called explicitly.
extractCollect information from the run in preparation for checking.
checkCheck simulation results against expected outcome.
reportReport simulation results.

A phase is defined by an instance of an ovm_phase subtype.  If a phase is to be shared among several component types, the instance must be accessible from a common scope, such as a package.

To have a user-defined phase get called back during simulation, the phase object must be registered with the top-level OVM phase controller, ovm_top.

Inheriting from the ovm_phase Class

When creating a user-defined phase, you must do the following.

1.  Define a new phase class, which must extend ovm_phase.  To enable use of the phase by any component, we recommend this class be parameterized.  The easiest way to define a new phase is to invoke a predefined macro.  For example:

`ovm_phase_func_topdown_decl( preload )

This convenient phase declaration macro is described below.

2.  Create a single instance of the phase in a convenient placein a package, or in the same scope as the component classes that will use the phase.

typedef class my_memory;
preload_phase #(my_memory) preload_ph = new;

3.  Register the phase object with ovm_top.

class my_memory extends ovm_component;
  function new(string name, ovm_component parent);
    super.new(name,parent);
    ovm_top.insert_phase(preload_ph, start_of_simulation_ph);
  endfunction
  virtual function void preload(); // our new phase
    ...
  endfunction
endclass

Phase Macros (Optional)

The following macros simplify the process of creating a user-defined phase.  They create a phase type that is parameterized to the component class that uses the phase.

Summary
UsagePhases are a synchronizing mechanism for the environment.
Macros
`ovm_phase_func_decl`ovm_phase_func_decl (PHASE_NAME, TOP_DOWN)
`ovm_phase_task_decl
`ovm_phase_func_topdown_decl
`ovm_phase_func_bottomup_decl
`ovm_phase_task_topdown_decl
`ovm_phase_task_bottomup_declThese alternative macros have a single phase name argument.

`ovm_phase_func_decl

`ovm_phase_func_decl (PHASE_NAME, TOP_DOWN)

The PHASE_NAME argument is used to define the name of the phase, the name of the component method that is called back during phase execution, and the prefix of the type-name of the phase class that gets generated.

The above macro creates the following class definition.

class PHASE_NAME``_phase #(type PARENT=int) extends ovm_phase;

  PARENT m_parent;

  function new();
     super.new(`"NAME`",TOP_DOWN,1);
  endfunction
  virtual function void call_func();
     m_parent.NAME(); // call the component¿s phase callback
  endtask
  virtual task execute(ovm_component parent);
     assert($cast(m_parent,parent));
     call_func();
  endtask
endclass

`ovm_phase_task_decl

`ovm_phase_task_decl (PHASE_NAME, TOP_DOWN)

The above macro creates the following class definition.

class PHASE_NAME``_phase #(type PARENT=int) extends ovm_phase;
  PARENT m_parent;
  function new();
   super.new(`"NAME`",TOP_DOWN,1);
  endfunction
  virtual task call_task();
       m_parent.NAME(); // call the component¿s phase callback
  endtask
  virtual task execute(ovm_component parent);
       assert($cast(m_parent,parent));
       call_task();
  endtask
endclass

`ovm_phase_task_bottomup_decl

These alternative macros have a single phase name argument.  The top-down or bottom-up selection is specified in the macro name, which makes them more self-documenting than those with a 0 or 1 2nd argument.

`define ovm_phase_func_topdown_decl  `ovm_phase_func_decl (PHASE_NAME,1)
`define ovm_phase_func_bottomup_decl `ovm_phase_func_decl (PHASE_NAME,0)
`define ovm_phase_task_topdown_decl  `ovm_phase_task_decl (PHASE_NAME,1)
`define ovm_phase_task_bottomup_decl `ovm_phase_task_decl (PHASE_NAME,0)
virtual class ovm_phase
The ovm_phase class is used for defining phases for ovm_component and its subclasses.
function new (string name,
bit is_top_down,
bit is_task)
Creates a phase object.
function string get_name ()
Returns the name of the phase object as supplied in the constructor.
function bit is_task ()
Returns 1 if the phase is time consuming and 0 if not.
function bit is_top_down ()
Returns 1 if the phase executes top-down (executes the parent¿s phase callback before executing the children¿s callback) and 0 otherwise.
virtual function string get_type_name()
Derived classes should override this method to return the phase type name.
task wait_start ()
Waits until the phase has beed started.
task wait_done ()
Waits until the phase has been completed.
function bit is_in_progress ()
Returns 1 if the phase is currently in progress (active), 0 otherwise.
function bit is_done ()
Returns 1 if the phase has completed, 0 otherwise.
function void reset ()
Resets phase state such that is_done and is_in_progress both return 0.
virtual task call_task (ovm_component parent)
Calls the task-based phase of the component given by parent, which must be derived from ovm_component.
virtual function void call_func (ovm_component parent)
Calls the function-based phase of the component given by parent.
Components execute their behavior in strictly ordered, pre-defined phases.