ovm_phases.sv

Go to the documentation of this file.
00001 // $Id: ovm__phases_8sv-source.html,v 1.1 2008/10/07 21:54:53 alex.marin Exp $
00002 //------------------------------------------------------------------------------
00003 //   Copyright 2007-2008 Mentor Graphics Corporation
00004 //   Copyright 2007-2008 Cadence Design Systems, Inc.
00005 //   All Rights Reserved Worldwide
00006 //
00007 //   Licensed under the Apache License, Version 2.0 (the
00008 //   "License"); you may not use this file except in
00009 //   compliance with the License.  You may obtain a copy of
00010 //   the License at
00011 //
00012 //       http://www.apache.org/licenses/LICENSE-2.0
00013 //
00014 //   Unless required by applicable law or agreed to in
00015 //   writing, software distributed under the License is
00016 //   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00017 //   CONDITIONS OF ANY KIND, either express or implied.  See
00018 //   the License for the specific language governing
00019 //   permissions and limitations under the License.
00020 //------------------------------------------------------------------------------
00021 
00022 `ifndef OVM_PHASES_SVH
00023 `define OVM_PHASES_SVH
00024 
00025 typedef class ovm_component;
00026 typedef class ovm_threaded_component;
00027 
00028 //------------------------------------------------------------------------------
00029 //
00030 // Class: ovm_phase
00031 //
00032 //------------------------------------------------------------------------------
00033 // This class is a base class for a phase callback. All predefined OVM phases
00034 // and any user-defined phases alike use ovm_phase. To define a new phase:
00035 //
00036 // (1)  derive a subclass of ovm_phase that implements (overrides) either the
00037 //      call_task  or call_func method, depending on whether the new phase is
00038 //      to be time-consuming or not.  When calling super.new, your subclass must
00039 //      provide the name of phase (typically the name of the callback method),
00040 //      whether the method is to be called top-down or bottom-up, and whether
00041 //      the method is task or a function. For example, given a component type,
00042 //      my_comp, you can define a my_task phase for that component as follows:
00043 //
00044 //        class my_comp extends ovm_component;
00045 //          ...
00046 //          virtual my_task();  return; endtask // make virtual
00047 //          ...
00048 //        endclass
00049 //
00050 //        class my_task_phase extends ovm_phase;
00051 //          function new();
00052 //            super.new("my_task",1,1);
00053 //          endfunction
00054 //          task call_task(ovm_component parent);
00055 //             my_comp_type my_comp;
00056 //             if ($cast(my_comp,parent))
00057 //               my_comp.my_task_phase()
00058 //          endtask
00059 //        endclass
00060 //      
00061 //      Tip: The above can be defined via a convenient macro invocation:
00062 //           `ovm_phase_task_decl(my_task,1) //1=top-down
00063 //
00064 // (2)  Create a global (or package-scope) instance of your phase object:
00065 //
00066 //        my_task_phase my_task_ph = new();
00067 //
00068 // (3)  Register the phase with the OVM's phase controller, ovm_top. For
00069 //      example, to register the my_task_phase as a phase for all my_comp-
00070 //      based components:
00071 //        
00072 //        ovm_top.insert_phase(my_task_phase, run_ph);
00073 //
00074 //      It should be global in nature so that it is universally available 
00075 //      to any process for getting or waiting on phase state.
00076 //
00077 // That's it! The ovm_top phase controller will now call my_comp-based components'
00078 // my_task phase callbacks in top-down order after completion of the run phase.
00079 //
00080 //
00081 // Type information methods:
00082 //
00083 //   The methods get_name, is_task, and is_top_down provide information about
00084 //   the phase's type.
00085 // 
00086 // Event & status methods:
00087 //
00088 //   The ovm_phase class defines an event interface that allows processes to
00089 //   wait until the phase begins or ends and to determine whether the phase is
00090 //   currently active (is_in_progress) or has completed (is_done). The reset
00091 //   method clears the phase state.
00092 //
00093 //------------------------------------------------------------------------------
00094 
00095 
00096 virtual class ovm_phase;
00097 
00098   local  string  m_name;
00099   local  bit     m_is_top_down;
00100   local  bit     m_is_task;
00101 
00102   local  event   m_start_event;
00103   local  bit     m_is_started=0;
00104   local  event   m_done_event;
00105   local  bit     m_is_done=0;
00106 
00107   function new (string name, bit is_top_down, bit is_task);
00108     m_name = name;
00109     m_is_top_down = is_top_down;
00110     m_is_task     = is_task;
00111   endfunction
00112 
00113   //
00114   // Info interface
00115   //
00116   function string get_name       (); return m_name;        endfunction
00117   function bit    is_task        (); return m_is_task;     endfunction
00118   function bit    is_top_down    (); return m_is_top_down; endfunction
00119 
00120   virtual function string get_type_name();
00121     return "ovm_phase";
00122   endfunction
00123 
00124   //
00125   // Event & Status interface
00126   //
00127   task            wait_start     (); @m_start_event;       endtask
00128   task            wait_done      (); @m_done_event;        endtask
00129 
00130   function bit    is_in_progress (); return m_is_started;  endfunction
00131   function bit    is_done        (); return m_is_done;     endfunction
00132 
00133   function void   reset          (); m_is_done=0;
00134                                      m_is_started=0;       endfunction
00135 
00136   //
00137   // Virtual methods call_task/call_func: subclasses must define only one
00138   //
00139   virtual task call_task (ovm_threaded_component parent);
00140      return;
00141   endtask
00142 
00143   virtual function void call_func (ovm_component parent);
00144     return;
00145   endfunction
00146 
00147   // psuedo-private methods; do not call directly
00148 
00149   function void m_set_in_progress();
00150     m_is_started=1;
00151     ->m_start_event;
00152   endfunction
00153 
00154   function void m_set_done();
00155     m_is_done=1;
00156     m_is_started=0;
00157     ->m_done_event;
00158   endfunction
00159 
00160 endclass
00161 
00162 
00163 `endif // OVM_PHASES_SVH

Intelligent Design Verification
Intelligent Design Verification
Project: OVM, Revision: 1.1.0
Copyright (c) 2008 Intelligent Design Verification.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included here:
http://www.intelligentdv.com/licenses/fdl.txt
doxygen
Doxygen Version: 1.4.6
Mon Sep 29 14:20:12 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV