ovm_event_pool.svh

Go to the documentation of this file.
00001 //
00002 //------------------------------------------------------------------------------
00003 //   Copyright 2007-2009 Mentor Graphics Corporation
00004 //   Copyright 2007-2009 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 
00023 //------------------------------------------------------------------------------
00024 //
00025 // CLASS: ovm_event_pool
00026 //
00027 // The ovm_event_pool is essentially an associative array of <ovm_event> objects
00028 // indexed by the string name of the event.
00029 //
00030 //------------------------------------------------------------------------------
00031 
00032 class ovm_event_pool extends ovm_object;
00033 
00034   static local ovm_event_pool  m_global_pool;
00035   local  ovm_event              pool[string];
00036 
00037 
00038   // Function: new
00039   //
00040   // Creates a new event pool with the given ~name~.
00041 
00042   function new (string name="");
00043     super.new(name);
00044   endfunction
00045 
00046 
00047   // Function: get_global_pool
00048   //
00049   // Returns the singleton global event pool. 
00050   //
00051   // This allows events to be shared between components throughout the
00052   // verification environment.
00053 
00054   static function ovm_event_pool get_global_pool ();
00055     if (m_global_pool==null) begin
00056       ovm_event_pool pool;
00057       pool = new("pool");
00058       m_global_pool = pool;
00059     end
00060     return m_global_pool;
00061   endfunction
00062 
00063 
00064   // Function: get
00065   //
00066   // Returns the event with the given ~name~.
00067   //
00068   // If no event exists by that name, a new event is created with that name
00069   // and returned.
00070 
00071   virtual function ovm_event get (string name);
00072     ovm_event e;
00073     if(this.pool.exists(name)) e = this.pool[name];
00074 
00075     if (e==null) begin
00076        e = new (name);
00077        this.pool[name] = e;
00078     end
00079     return e;
00080   endfunction
00081 
00082 
00083   // Function: num
00084   //
00085   // Returns the number of uniquely named events stored in the pool.
00086 
00087   virtual function int num ();
00088     return this.pool.num();
00089   endfunction
00090 
00091 
00092   // Function: delete
00093   //
00094   // Removes the event with the given ~name~ from the pool.
00095 
00096   virtual function void delete (string name);
00097     if (!this.exists(name)) begin
00098       ovm_report_warning("EVNTX", $psprintf("delete: %0s doesn't exist. Ignoring delete request",name));
00099       return;
00100     end
00101     this.pool.delete(name);
00102   endfunction
00103 
00104 
00105   // Function: exists
00106   //
00107   // Returns 1 if an event with the given ~name~ exists in the pool,
00108   // 0 otherwise.
00109 
00110   virtual function int exists (string name);
00111     return this.pool.exists(name);
00112   endfunction
00113 
00114 
00115   // Function: first
00116   //
00117   // Returns the name of the first event stored in the pool.
00118   //
00119   // If the pool is empty, then ~name~ is unchanged and 0 is returned.
00120   //
00121   // If the pool is not empty, then ~name~ is name of the first event
00122   // and 1 is returned.
00123 
00124   virtual function int first (ref string name);
00125     return this.pool.first(name);
00126   endfunction
00127 
00128 
00129   // Function: last
00130   //
00131   // Returns the name of the last event stored in the pool.
00132   //
00133   // If the pool is empty, then 0 is returned and ~name~ is unchanged. 
00134   //
00135   // If the pool is not empty, then ~name~ is set to the last name in
00136   // the pool and 1 is returned.
00137 
00138   virtual function int last (ref string name);
00139     return this.pool.last(name);
00140   endfunction
00141 
00142 
00143   // Function: next
00144   //
00145   // Returns the name of the next event in the pool.
00146   //
00147   // If the input ~name~ is the last name in the pool, then name is unchanged
00148   // and 0 is returned. 
00149   //
00150   // If a next name is found, then ~name~ is updated with that name and
00151   // 1 is returned.
00152 
00153   virtual function int next (ref string name);
00154     return this.pool.next(name);
00155   endfunction
00156 
00157 
00158   // Function: prev
00159   //
00160   // Returns the name of the previous event in the pool.
00161   //
00162   // If the input ~name~ is the first name in the pool, then ~name~ is left
00163   // unchanged and 0 is returned. 
00164   //
00165   // If a previous name is found, then ~name~ is updated with that name
00166   // and 1 is returned.
00167 
00168   virtual function int prev (ref string name);
00169     return this.pool.prev(name);
00170   endfunction
00171 
00172 
00173   const static string type_name = "ovm_event_pool";
00174 
00175   virtual function string get_type_name ();
00176     return type_name;
00177   endfunction
00178 
00179   virtual function ovm_object create (string name=""); 
00180     ovm_event_pool v;
00181     v=new(name);
00182     return v;
00183   endfunction
00184 
00185   virtual function void do_print (ovm_printer printer);
00186     printer.print_generic("pool", "aa_object_string", pool.num(), "-");
00187     printer.m_scope.down("pool", null);
00188     foreach(pool[e]) begin
00189       printer.print_object(e, pool[e], "[");
00190     end
00191     printer.m_scope.up(null);
00192   endfunction
00193 
00194   virtual function void do_copy (ovm_object rhs);
00195     ovm_event_pool ep;
00196     string key;
00197     super.do_copy(rhs);
00198 
00199     if (rhs == null) return;
00200     if (!$cast(ep, rhs))
00201       ovm_report_fatal ("CASTFL", "Failed to cast rhs to type ovm_event_pool in copy", OVM_NONE);
00202 
00203     pool.delete();
00204     if(ep.pool.first(key))
00205       do pool[key] = ep.pool[key];
00206       while(ep.pool.next(key));
00207   endfunction
00208 
00209 endclass
00210 
00211 

Intelligent Design Verification
Intelligent Design Verification
Project: OVM, Revision: 2.1.0
Copyright (c) 2008-2010 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.6.3
IDV SV Filter Version: 2.6.3
Sat Jun 19 11:51:28 2010
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV