ovm_object.svh

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

Intelligent Design Verification
Intelligent Design Verification
Project: OVM, Revision: 2.0.1
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.5.5
Wed Jan 7 19:27:18 2009
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV