ovm_pair.svh

Go to the documentation of this file.
00001 // $Id: ovm__pair_8svh-source.html,v 1.1 2008/10/07 21:54:17 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_PAIR_SVH
00023 `define OVM_PAIR_SVH
00024 
00025 //
00026 // paramterized pair classes
00027 //
00028 
00029 class ovm_class_pair #( type T1 = int ,
00030          type T2 = T1 )
00031   
00032   extends ovm_transaction;
00033 
00034   typedef ovm_class_pair #( T1 , T2 ) this_type;
00035   
00036   const static string type_name = "ovm_class_pair #(T1,T2)";
00037 
00038   T1 first;
00039   T2 second;
00040 
00041   function new( input T1 f = null , input T2 s = null , string name="");
00042     super.new(name);
00043     if( f == null ) begin
00044       first = new;
00045     end
00046     else begin
00047       first = f;
00048     end
00049     if( s == null ) begin
00050       second = new;
00051     end
00052     else begin
00053       second = s;
00054     end
00055   endfunction  
00056   
00057   virtual function ovm_object create (string name=""); 
00058     this_type v;
00059     v=new(.name(name));
00060     return v;
00061   endfunction
00062 
00063   virtual function string get_type_name ();
00064     return type_name;
00065   endfunction
00066 
00067   virtual function string convert2string;
00068     string s;
00069 
00070     $sformat( s , "pair : %s , %s" ,
00071          first.convert2string() ,
00072          second.convert2string() );
00073     
00074     return s;    
00075   endfunction
00076 
00077   function bit comp( this_type t );
00078     return t.first.comp( first ) && t.second.comp( second );
00079   endfunction
00080 
00081   function void copy( input this_type t );
00082     first.copy( t.first );
00083     second.copy( t.second );
00084   endfunction
00085 
00086   virtual function ovm_object clone();
00087     this_type t;
00088     t = new;
00089     t.copy( this );
00090     return t;
00091   endfunction
00092   
00093 endclass
00094 
00095 class ovm_built_in_pair #( type T1 = int ,
00096             type T2 = T1 )
00097   
00098   extends ovm_transaction;
00099 
00100   typedef ovm_built_in_pair #( T1 , T2 ) this_type;
00101   
00102   const static string type_name = "ovm_built_in_pair #(T1,T2)";
00103 
00104   T1 first;
00105   T2 second;
00106   
00107   function new(input T1 f, input T2 s, string name="");
00108     super.new(name);
00109     first = f;
00110     second = s;
00111   endfunction  
00112   
00113   virtual function ovm_object create (string name=""); 
00114     this_type v;
00115     v=new(first,second,name);
00116     return v;
00117   endfunction
00118 
00119   virtual function string get_type_name ();
00120     return type_name;
00121   endfunction
00122 
00123   virtual function string convert2string;
00124     string s;
00125 `ifndef INCA
00126     $sformat( s , "built-in pair : %p , %p" ,
00127          first ,
00128          second );
00129 `else
00130     $sformat( s , "built-in pair : " ,
00131          first , " , ",
00132          second );
00133 `endif
00134 
00135     return s;
00136   endfunction
00137 
00138   function bit comp( this_type t );
00139     return t.first == first && t.second == second;
00140   endfunction
00141 
00142   function void copy( input this_type t );
00143     first = t.first;
00144     second = t.second;
00145   endfunction
00146   
00147   virtual function ovm_object clone();
00148     this_type t;
00149     t = new(first,second);
00150     return t;
00151   endfunction
00152 
00153 endclass
00154 
00155 `endif // OVM_PAIR_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:23:30 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV