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
ovm_phase | ||
The ovm_phase class is used for defining phases for ovm_component and its subclasses. | ||
Class Declaration | ||
| ||
Methods | ||
new | Creates a phase object. | |
get_name | Returns the name of the phase object as supplied in the constructor. | |
is_task | Returns 1 if the phase is time consuming and 0 if not. | |
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 | Derived classes should override this method to return the phase type name. | |
wait_start | Waits until the phase has beed started. | |
wait_done | Waits until the phase has been completed. | |
is_in_progress | Returns 1 if the phase is currently in progress (active), 0 otherwise. | |
is_done | Returns 1 if the phase has completed, 0 otherwise. | |
reset | Resets phase state such that is_done and is_in_progress both return 0. | |
call_task | Calls the task-based phase of the component given by parent, which must be derived from ovm_component. | |
call_func | Calls the function-based phase of the component given by parent. |
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.
function string get_name ()
Returns the name of the phase object as supplied in the constructor.
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.
function bit is_in_progress ()
Returns 1 if the phase is currently in progress (active), 0 otherwise.
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.
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.
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.
build | Depending on configuration and factory settings, create and configure additional component hierarchies. |
connect | Connect ports, exports, and implementations (imps). |
end_of_elaboration | Perform final configuration, topology, connection, and other integrity checks. |
start_of_simulation | Do pre-run activities such as printing banners, pre-loading memories, etc. |
run | Most verification is done in this time-consuming phase. May fork other processes. Phase ends when global_stop_request is called explicitly. |
extract | Collect information from the run in preparation for checking. |
check | Check simulation results against expected outcome. |
report | Report 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.
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
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.
Usage | Phases 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_decl | These alternative macros have a single phase name argument. |
`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 (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
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)
The ovm_phase class is used for defining phases for ovm_component and its subclasses.
virtual class ovm_phase
Creates a phase object.
function new ( string name, bit is_top_down, bit is_task )
Returns the name of the phase object as supplied in the constructor.
function string get_name ()
Returns 1 if the phase is time consuming and 0 if not.
function bit is_task ()
Returns 1 if the phase executes top-down (executes the parent¿s phase callback before executing the children¿s callback) and 0 otherwise.
function bit is_top_down ()
Derived classes should override this method to return the phase type name.
virtual function string get_type_name()
Waits until the phase has beed started.
task wait_start ()
Waits until the phase has been completed.
task wait_done ()
Returns 1 if the phase is currently in progress (active), 0 otherwise.
function bit is_in_progress ()
Returns 1 if the phase has completed, 0 otherwise.
function bit is_done ()
Resets phase state such that is_done and is_in_progress both return 0.
function void reset ()
Calls the task-based phase of the component given by parent, which must be derived from ovm_component.
virtual task call_task ( ovm_component parent )
Calls the function-based phase of the component given by parent.
virtual function void call_func ( ovm_component parent )