00001 // $Id: ovm__phases_8sv-source.html,v 1.1 2008/10/07 21:54:25 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 00027 //------------------------------------------------------------------------------ 00028 // 00029 // Class: ovm_phase 00030 // 00031 //------------------------------------------------------------------------------ 00032 // This class is a base class for a phase callback. All predefined OVM phases 00033 // and any user-defined phases alike use ovm_phase. To define a new phase: 00034 // 00035 // (1) derive a subclass of ovm_phase that implements (overrides) either the 00036 // call_task or call_func method, depending on whether the new phase is 00037 // to be time-consuming or not. When calling super.new, your subclass must 00038 // provide the name of phase (typically the name of the callback method), 00039 // whether the method is to be called top-down or bottom-up, and whether 00040 // the method is task or a function. For example, given a component type, 00041 // my_comp, you can define a my_task phase for that component as follows: 00042 // 00043 // class my_comp extends ovm_component; 00044 // ... 00045 // virtual my_task(); return; endtask // make virtual 00046 // ... 00047 // endclass 00048 // 00049 // class my_task_phase extends ovm_phase; 00050 // function new(); 00051 // super.new("my_task",1,1); 00052 // endfunction 00053 // task call_task(ovm_component parent); 00054 // my_comp_type my_comp; 00055 // if ($cast(my_comp,parent)) 00056 // my_comp.my_task_phase() 00057 // endtask 00058 // endclass 00059 // 00060 // Tip: The above can be defined via a convenient macro invocation: 00061 // 00062 // `ovm_phase_task_topdown_decl(my_task) 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_ph, 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_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_is_started(bit val); 00150 m_is_started=val; 00151 endfunction 00152 00153 function void m_set_in_progress(); 00154 m_set_is_started(1); 00155 ->m_start_event; 00156 endfunction 00157 00158 function void m_set_done(); 00159 m_is_done=1; 00160 m_set_is_started(0); 00161 ->m_done_event; 00162 endfunction 00163 00164 endclass 00165 00166 00167 `endif // OVM_PHASES_SVH
![]() 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 Version: 1.4.6 Mon Sep 29 14:23:30 2008 |