ovm_object.svh

Go to the documentation of this file.
00001 // $Id: ovm__object_8svh-source.html,v 1.1 2008/10/07 21:54:38 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 
00023 /*******************************************************************************
00024 
00025   FILE        : ovm_object.svh
00026 
00027   The base class for all urm classes. 
00028 
00029   The ovm_void class is added as an empty root class so that users can
00030   derive from that class and create datastructures which take both
00031   ovm_object types as well as user defined types.
00032 
00033  *******************************************************************************/
00034 
00035 `ifndef OVM_OBJECT_SVH
00036 `define OVM_OBJECT_SVH
00037 
00038 `include "base/ovm_misc.svh"
00039 `include "base/ovm_object_globals.svh"
00040 
00041 typedef class ovm_copy_map;
00042 typedef class ovm_printer;
00043 typedef class ovm_comparer;
00044 typedef class ovm_packer;
00045 typedef class ovm_recorder;
00046 typedef class ovm_report_object;
00047 
00048 //------------------------------------------------------------------------------
00049 //
00050 // CLASS: ovm_status_container
00051 //
00052 // Class to contain status information for automation methods.
00053 //
00054 //------------------------------------------------------------------------------
00055 
00056 typedef class ovm_object;
00057 
00058 // This container class needs to be defined ahead of the ovm_object class
00059 // which uses it to work around a but in ius 6.11 regarding class in packages.
00060 // This class is just for internal usage. It is a class instead of a struct
00061 // becauses structs currently cannot hold class object handles.
00062 class ovm_status_container;
00063   //Since there is a cost to saving the field string, only do so if needed.
00064   static bit          save_last_field = 0;
00065   static string       last_field     = "";
00066 
00067   static bit          warning    = 0;
00068   static bit          status     = 0;
00069   static ovm_bitstream_t  bitstream  = 0;
00070   static int          intv       = 0;
00071   static int          element    = 0;
00072   static string       stringv    = "";
00073   static string       scratch1   = "";
00074   static string       scratch2   = "";
00075   static string       key        = "";
00076   static ovm_object   object     = null;
00077   static bit          array_warning_done = 0;
00078   static ovm_scope_stack scope       = new;  //For get-set operations
00079 
00080   extern static function string get_full_scope_arg ();
00081 endclass
00082 
00083 //------------------------------------------------------------------------------
00084 //
00085 // CLASS: ovm_object
00086 //
00087 // Base class for OVM elements.
00088 //
00089 //------------------------------------------------------------------------------
00090 
00091 virtual class ovm_object extends ovm_void;
00092   //Constructor
00093   extern function new (string name="");
00094 
00095   //Static bits used for controlling global seeding behaviors
00096   static  bit use_ovm_seeding  = 1;  //use the URM random stability feature
00097 
00098   //Functions which should not be overridden
00099   extern  function void          print         (ovm_printer printer=null);
00100   extern  function string        sprint        (ovm_printer printer=null); 
00101   extern  function void          reseed        ();
00102 
00103   //Virtual method which can be overridden.
00104   extern virtual function void   do_print      (ovm_printer printer);
00105   extern virtual function string do_sprint     (ovm_printer printer); 
00106   extern virtual function void   do_record     (ovm_recorder recorder);
00107   extern virtual function void   do_copy       (ovm_object  rhs);
00108   extern virtual function bit    do_compare    (ovm_object  rhs,
00109                                                 ovm_comparer comparer);
00110   extern virtual function void   do_pack       (ovm_packer   packer);
00111   extern virtual function void   do_unpack     (ovm_packer   packer);
00112 
00113   extern virtual function void   set_name      (string      name);
00114 
00115   extern virtual function string get_name      ();
00116   extern virtual function string get_full_name ();
00117 
00118   //Required overrides
00119   virtual  function ovm_object  create        (string      name=""); return null; endfunction
00120   virtual  function string      get_type_name (); return "ovm_object"; endfunction 
00121   extern virtual function ovm_object  clone   ();
00122 
00123   //Data oriented methods
00124   extern  function void         copy          (ovm_object       rhs);
00125   extern  function bit          compare       (ovm_object       rhs,
00126                                                ovm_comparer     comparer=null);
00127   extern  function void         record        (ovm_recorder     recorder=null);
00128 
00129   extern  function int          pack          (ref   bit        bitstream[],
00130                                                input ovm_packer packer=null);
00131   extern  function int          unpack        (ref   bit        bitstream[],
00132                                                input ovm_packer packer=null);
00133   extern  function int          pack_bytes    (ref   byte unsigned bytestream[],
00134                                                input ovm_packer packer=null);
00135   extern  function int          unpack_bytes  (ref   byte unsigned bytestream[],
00136                                                input ovm_packer packer=null);
00137   extern  function int          pack_ints     (ref   int unsigned intstream[],
00138                                                input ovm_packer packer=null);
00139   extern  function int          unpack_ints   (ref   int unsigned intstream[],
00140                                                input ovm_packer packer=null);
00141 
00142   extern local function void m_pack(inout ovm_packer packer);
00143   extern local function void m_unpack_pre(inout ovm_packer packer);
00144   extern local function void m_unpack_post(ovm_packer packer);
00145 
00146   //The print_matches bit causes an informative message to be printed
00147   //when a field is set using one of the set methods.
00148   static  bit print_matches = 0;
00149 
00150   extern static  function void  print_field_match 
00151                                               (string  fnc,
00152                                                string      match);
00153 
00154   extern virtual function void  set_int_local 
00155                                               (string      field_name,
00156                                                ovm_bitstream_t value,
00157                                                bit         recurse=1);
00158   extern virtual function void  set_object_local
00159                                               (string      field_name,
00160                                                ovm_object  value,
00161                                                bit         clone=1,
00162                                                bit         recurse=1);
00163   extern virtual function void  set_string_local
00164                                               (string      field_name,
00165                                                string      value,
00166                                                bit         recurse=1);
00167 
00168 
00169   // internal methods & properties; users must not use directly
00170   extern virtual function void     m_field_automation
00171                                          (ovm_object  tmp_data__,  
00172                                           int         what__, 
00173                                           string      str__);
00174   extern protected function int m_do_data
00175                                          (      string      arg,
00176                                           inout ovm_bitstream_t lhs,
00177                                           input ovm_bitstream_t rhs,
00178                                                 int         what,
00179                                                 int         bits,
00180                                                 int         flag);
00181   extern protected function int m_do_data_object
00182                                          (      string      arg,
00183                                           inout ovm_object  lhs,
00184                                           input ovm_object  rhs,
00185                                                 int         what,
00186                                                 int         flag);
00187   extern protected function int m_do_data_string
00188                                          (      string      arg,
00189                                           inout string      lhs,
00190                                           input string      rhs,
00191                                                 int         what,
00192                                                 int         flag);
00193   extern protected function void m_record_field_object 
00194                                          (string       arg,
00195                                           ovm_object   value,
00196                                           ovm_recorder recorder=null,
00197                                           int          flag=OVM_DEFAULT);
00198   extern protected function int m_do_set        
00199                                          (string       match,
00200                                           string       arg,
00201                                           inout ovm_bitstream_t  lhs, 
00202                                           input int          what,
00203                                                 int          flag);
00204   extern protected function int m_do_set_string 
00205                                          (string       match,
00206                                           string       arg,
00207                                           inout  string       lhs, 
00208                                           input  int          what,
00209                                                  int          flag);
00210   extern protected function int m_do_set_object 
00211                                          (string       match,
00212                                           string       arg,
00213                                           inout  ovm_object   lhsobj, 
00214                                           input  int          what,
00215                                                  int          flag);
00216   extern protected function string   m_get_function_type  (int what);
00217   static protected int     m_inst_count = 0;
00218 
00219   extern protected virtual function ovm_report_object m_get_report_object();
00220 
00221   // internal properties (user should not access directly)
00222   // needs to be protected since set_name()/get_name() are virtual
00223   local string m_leaf_name;
00224 
00225   // Some urm class need access to this container, so provide a
00226   // backdoor access.
00227   static protected ovm_status_container m_sc = new;
00228   static function ovm_status_container m_get_status(); return m_sc; endfunction
00229 
00230   // The following members are used for verifying the integrity of the 
00231   // ovm_field macros.
00232   static protected int m_field_array[string];
00233   extern protected function void m_do_field_check(string field);
00234 endclass
00235 
00236 
00237 //------------------------------------------------------------------------------
00238 //
00239 // CLASS: ovm_copy_map
00240 //
00241 //------------------------------------------------------------------------------
00242 
00243 // Used to map rhs to lhs so when a cycle is found in the rhs, the correct
00244 // lhs object can be bound to it.
00245 class ovm_copy_map;
00246   local ovm_object m_map[ovm_object];
00247   function void set(ovm_object key, ovm_object obj);
00248     m_map[key] = obj;
00249   endfunction
00250   function ovm_object get(ovm_object key);
00251     if (m_map.exists(key))
00252        return m_map[key];
00253     return null;
00254   endfunction
00255   function void clear();
00256     m_map.delete();
00257   endfunction 
00258   function void delete(ovm_object v);
00259     m_map.delete(v);
00260   endfunction 
00261 endclass
00262 
00263 //------------------------------------------------------------------------------
00264 //
00265 // CLASSES: Policy classes
00266 //
00267 // Policy classes for ovm_object basic functions: copy, compare,
00268 // pack/unpack, and record.
00269 //
00270 //------------------------------------------------------------------------------
00271 
00272 
00273 // ovm_comparer
00274 // ---------------
00275 
00276 class ovm_comparer;
00277 
00278   //Comparison message settings
00279   int unsigned   show_max      = 1;    // Maximum miscompares to print
00280   int unsigned   verbosity     = 500;  // Verbosity setting for miscompare
00281   ovm_severity   sev           = OVM_INFO; // Severity setting for miscompare
00282   string         miscompares   = "";   // Last set of miscompares
00283 
00284   //Comparison settings
00285   bit physical     = 1; // compare physical fields 
00286   bit abstract     = 1; // compare abstract fields
00287   bit check_type   = 1; // verify that object types match
00288 
00289   ovm_recursion_policy_enum policy = OVM_DEFAULT_POLICY;
00290 
00291   //Result of comparison
00292   int unsigned result          = 0; // Count of miscompares, will be <= show_max
00293 
00294   //Methods used checking for printing information
00295   extern virtual function bit  compare_field  (string      name, 
00296                                                ovm_bitstream_t lhs, 
00297                                                ovm_bitstream_t rhs, 
00298                                                int         size,
00299                                                ovm_radix_enum  radix=OVM_NORADIX); 
00300   //For efficency, have a version for smaller fields. Automatically called
00301   //by compare_field if size is <= 64.
00302   extern virtual function bit  compare_field_int  (string      name, 
00303                                                logic[63:0] lhs, 
00304                                                logic[63:0] rhs, 
00305                                                int         size,
00306                                                ovm_radix_enum  radix=OVM_NORADIX); 
00307   extern virtual function bit  compare_object (string      name,
00308                                                ovm_object    lhs,
00309                                                ovm_object    rhs);
00310   extern virtual function bit  compare_string (string      name,
00311                                                string      lhs,
00312                                                string      rhs);
00313 
00314   extern  function void print_rollup    (ovm_object rhs, ovm_object lhs);
00315 
00316   extern  function void print_msg       (string     msg);
00317   extern  function void print_msg_object(ovm_object   lhs, ovm_object   rhs);
00318 
00319   //Internally used properties
00320   int depth                    = 0;   //current depth of objects, internal use 
00321   ovm_copy_map compare_map     = new; //mapping of rhs to lhs objects
00322   ovm_scope_stack scope        = new;
00323 endclass
00324 
00325 
00326 // ovm_recorder
00327 // --------------
00328 
00329 class ovm_recorder;
00330   int        recording_depth = 0; 
00331   integer    tr_handle     = 0;   //transaction handle to record to
00332   ovm_radix_enum default_radix = OVM_HEX; //radix to use if no radix is set
00333   bit        physical      = 1;   //record physical fields
00334   bit        abstract      = 1;   //record abstract fields
00335 
00336   bit        identifier    = 1;   //record object identifiers
00337   ovm_recursion_policy_enum policy = OVM_DEFAULT_POLICY;
00338   ovm_scope_stack scope   = new;
00339 
00340   extern virtual function void record_field   (string      name, 
00341                                                ovm_bitstream_t value, 
00342                                                int         size, 
00343                                                ovm_radix_enum  radix=OVM_NORADIX);
00344   extern virtual function void record_object  (string      name,
00345                                                ovm_object    value);
00346   extern virtual function void record_string  (string      name,
00347                                                string      value);
00348   extern virtual function void record_time    (string      name,
00349                                                time        value); 
00350   extern virtual function void record_generic (string      name, 
00351                                                string      value);
00352 endclass
00353 
00354 // defaults
00355 // --------
00356 
00357 ovm_packer       ovm_default_packer     = new();
00358 ovm_comparer     ovm_default_comparer   = new();
00359 ovm_recorder     ovm_default_recorder   = new();
00360 
00361 // ovm options 
00362 // -----------
00363 
00364 class ovm_options_container;
00365   ovm_comparer    comparer;
00366   ovm_packer      packer;
00367   ovm_recorder    recorder;
00368   ovm_printer     printer;
00369   bit             clone = 1;
00370   extern function new();
00371 endclass
00372 
00373 `endif //OVM_OBJECT_SVH
00374 

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