ovm_printer.svh

Go to the documentation of this file.
00001 // $Id: ovm__printer_8svh-source.html,v 1.1 2008/10/07 21:54:09 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 // This file provides the declarations for the following printing classes
00025 //   ovm_printer_knobs       : controls for controlling print output
00026 //   ovm_printer             : default printer object, contains a knob object 
00027 //                              and user print methods and override methods.
00028 //   ovm_table_printer_knobs : knobs specific to table format, derived from
00029 //                             ovm_printer_knobs.
00030 //   ovm_table_printer       : printer for tabular format
00031 //   ovm_tree_printer_knobs  : knobs specific to tree format
00032 //   ovm_tree_printer        : printer for tree format
00033 //   ovm_line_printer        : printer for line format
00034 //
00035 //------------------------------------------------------------------------------
00036 `ifndef OVM_PRINTER_SVH
00037 `define OVM_PRINTER_SVH
00038 
00039 // Forward declarations of printer classes
00040 typedef class ovm_printer;
00041 typedef class ovm_tree_printer;
00042 typedef class ovm_table_printer;
00043 typedef class ovm_line_printer;
00044 
00045 `include "base/ovm_object.svh"
00046 `include "base/ovm_misc.svh"
00047 
00048 parameter OVM_STDOUT = 1;  // Writes to standard out and nc logfile
00049 
00050 //------------------------------------------------------------------------------
00051 //
00052 // CLASS: ovm_printer_knobs
00053 //
00054 // Provides standard printer formatting controls.
00055 //------------------------------------------------------------------------------
00056 
00057 class ovm_printer_knobs;
00058   int       column         = 0;      // current column position. This is not a
00059                                      // user level variable.
00060   int       max_width      = 999;    // maximum with of a field. Any field that
00061                                      // requires more characters will be 
00062                                      // truncated.
00063   string    truncation     = "+";    // character to indicate a field has been
00064                                      // truncated.
00065 
00066   bit       header         = 1;      // print the header
00067   bit       footer         = 1;      // print the footer
00068   int       global_indent  = 0;      // indentation for any printed line
00069   bit       full_name      = 1;      // the full name when printing id info
00070   bit       identifier     = 1;      // print index identifier information
00071   int       depth          = -1;     // printing depth, -1 is full
00072   bit       reference      = 1;      // print the reference of an object
00073   bit       type_name      = 1;      // print object type (for typed objects)
00074   bit       size           = 1;      // print the size of an object
00075   ovm_radix_enum default_radix = OVM_HEX;    // for data with no radix set
00076   int       begin_elements = 5;      // max front indexs of the array to print
00077                                      // (-1 for no max)
00078   int       end_elements   = 5;      // max back indexs of the array to print
00079   bit       show_radix     = 1;      // prepend value with radix
00080   string    prefix         = "";     // appended to start of each line
00081 
00082   bit       print_fields   = 1;      // Used by the tcl printing
00083 
00084   //where to print
00085   int       mcd            = OVM_STDOUT; // file descriptor(s) to write to
00086   bit       sprint         = 0;      // if set, write to string instead of mcd
00087 
00088   //Radix output control
00089   string    bin_radix      = "'b";
00090   string    oct_radix      = "'o";
00091   string    dec_radix      = "'d";
00092   string    unsigned_radix = "'d";
00093   string    hex_radix      = "'h";
00094 
00095   extern function string get_radix_str(ovm_radix_enum radix);
00096 endclass
00097 
00098 
00099 //------------------------------------------------------------------------------
00100 //
00101 // CLASS: ovm_printer
00102 //
00103 // Provides a generic printer. No formatting is done, the information is 
00104 // just printed in a raw form.
00105 //------------------------------------------------------------------------------
00106 
00107 class ovm_printer;
00108   protected bit m_array_stack[$];
00109   ovm_scope_stack    m_scope  = new;  //for internal use
00110   string             m_string = "";   //for internal use
00111 
00112   ovm_printer_knobs  knobs = new;
00113 
00114   // Primary derived class overrides. Use these methods to create a new 
00115   // printer type. Functions needed for array printing are not protected
00116   // since array printing must be done in macros.
00117   extern virtual  function void print_header       ();
00118   extern virtual  function void print_footer       ();
00119   extern virtual protected function void print_id           (string      id, 
00120                                          byte        scope_separator=".");
00121   extern virtual protected function void print_type_name    (string      name, bit is_object=0);
00122   extern virtual protected function void print_size         (int         size=-1);
00123   extern virtual protected function void print_newline      (bit         do_global_indent=1);
00124   extern virtual protected function void print_value        (ovm_bitstream_t value, 
00125                                          int         size, 
00126                                          ovm_radix_enum  radix=OVM_NORADIX);
00127   extern virtual protected function void print_value_object (ovm_object  value);
00128   extern virtual protected function void print_value_string (string      value);
00129 
00130   extern virtual  function void print_value_array  (string      value="", 
00131                                          int         size=0);
00132   extern virtual  function void print_array_header ( string      name,
00133                                          int         size,     
00134                                          string      arraytype="array",
00135                                          byte        scope_separator=".");
00136   extern virtual  function void print_array_range  (int         min,      
00137                                          int         max);
00138   extern virtual  function void print_array_footer (int         size=0);
00139 
00140   // Utility methods, may be overridden.
00141   extern virtual protected function void indent             (int         depth, 
00142                                          string      indent_str="  ");
00143 
00144   // Primary user level functions. These functions are called from 
00145   // ovm_object::print() methods, or are called directly on any data to
00146   // get formatted printing.
00147   extern virtual function void print_field         ( string      name, 
00148                                          ovm_bitstream_t value, 
00149                                          int         size, 
00150                                          ovm_radix_enum  radix=OVM_NORADIX,
00151                                          byte        scope_separator=".",
00152                                          string      type_name="");
00153   extern virtual function void print_object_header ( string      name,
00154                                          ovm_object  value, 
00155                                          byte        scope_separator=".");
00156   extern virtual function void print_object        (string      name,
00157                                          ovm_object  value, 
00158                                          byte        scope_separator=".");
00159   extern virtual function void print_string        (string      name,
00160                                          string      value, 
00161                                          byte        scope_separator=".");
00162   extern virtual function void print_time          ( string      name,
00163                                          time        value, 
00164                                          byte        scope_separator=".");
00165   extern virtual function void print_generic       (string      name, 
00166                                          string      type_name, 
00167                                          int         size, 
00168                                          string      value,
00169                                          byte        scope_separator=".");
00170 
00171   // Utility methods
00172   extern  function bit    istop             ();
00173   extern  function int    index             (string name);
00174   extern  function string index_string      (int index, 
00175                                          string      name="");
00176   extern protected function void   write_stream      (string str);
00177 endclass
00178 
00179 
00180 //------------------------------------------------------------------------------
00181 //
00182 // CLASS: ovm_hier_printer_knobs
00183 //
00184 // Knobs for hierarchical printing. These are knobs which are common to any
00185 // hierarchy printing control.
00186 //------------------------------------------------------------------------------
00187 class ovm_hier_printer_knobs extends ovm_printer_knobs;
00188   // Add an indentation string for indenting hierarchy instead of 
00189   // printing full names.
00190   string   indent_str    = "  ";    // string to use for indentation
00191   bit      show_root      = 0;      // show full name of the very first object
00192 
00193   extern function new(); 
00194 endclass
00195 
00196 
00197 //------------------------------------------------------------------------------
00198 //
00199 // CLASS: ovm_table_printer_knobs
00200 //
00201 // Table printing knobs. Specifies the length of the columns.
00202 //------------------------------------------------------------------------------
00203 
00204 class ovm_table_printer_knobs extends ovm_hier_printer_knobs;
00205   int            name_width  = 25;      // characters in the name column
00206   int            type_width  = 20;      // characters in the type column
00207   int            size_width  = 5;       // characters in the size column
00208   int            value_width = 20;      // characters in the value column
00209 endclass
00210 
00211 //------------------------------------------------------------------------------
00212 //
00213 // CLASS: ovm_table_printer
00214 //
00215 // Table printer prints output in a tabular format.
00216 //------------------------------------------------------------------------------
00217 
00218 class ovm_table_printer extends ovm_printer;
00219   extern  function new(); 
00220 
00221   // Adds column headers
00222   extern virtual function void print_header       ();
00223   extern virtual function void print_footer       ();
00224 
00225   // Puts information in column format
00226   extern virtual function void print_id           (string      id,
00227                                         byte        scope_separator=".");
00228   extern virtual function void print_size         (int         size=-1);
00229   extern virtual function void print_type_name    (string      name, bit is_object=0);
00230   extern virtual function void print_value        (ovm_bitstream_t value, 
00231                                         int         size, 
00232                                         ovm_radix_enum  radix=OVM_NORADIX);
00233   extern virtual function void print_value_object (ovm_object  value);
00234   extern virtual function void print_value_string (string      value);
00235   extern virtual function void print_value_array  (string      value="", 
00236                                         int         size=0);
00237 
00238   //override the knobs variable to allow direct access
00239   ovm_table_printer_knobs knobs = new;
00240 endclass
00241 
00242 
00243 //------------------------------------------------------------------------------
00244 //
00245 // CLASS: ovm_tree_printer_knobs
00246 //
00247 // Tree printing knobs. Specifies the hierarchy separator.
00248 //------------------------------------------------------------------------------
00249 
00250 class ovm_tree_printer_knobs extends ovm_hier_printer_knobs;
00251   string            separator     = "{}";    // the separator for composites
00252 endclass
00253 
00254 
00255 //------------------------------------------------------------------------------
00256 //
00257 // CLASS: ovm_tree_printer
00258 //
00259 // Tree printer prints output in a tree format.
00260 //------------------------------------------------------------------------------
00261 
00262 class ovm_tree_printer extends ovm_printer;
00263   // Information to print at the opening/closing of a scope
00264   extern virtual function void print_scope_open   ();
00265   extern virtual function void print_scope_close  ();
00266 
00267   // Puts information in tree format
00268   extern virtual function void print_id           (string id,
00269                                         byte   scope_separator=".");
00270   extern virtual function void print_type_name    (string name, bit is_object=0);
00271   extern virtual function void print_object_header(string      name,
00272                                         ovm_object  value, 
00273                                         byte        scope_separator=".");
00274   extern virtual function void print_object       (string      name,
00275                                         ovm_object  value, 
00276                                         byte        scope_separator=".");
00277   extern virtual function void print_string       ( string      name,
00278                                         string      value, 
00279                                         byte        scope_separator=".");
00280   extern virtual function void print_value_object (ovm_object value);
00281   extern virtual function void print_value_array  (string      value="", 
00282                                         int         size=0);
00283   extern virtual function void print_array_footer (int         size=0);
00284 
00285   extern function new(); 
00286 
00287   //override the knobs variable to allow direct access
00288   ovm_tree_printer_knobs knobs = new;
00289 endclass
00290 
00291 
00292 //------------------------------------------------------------------------------
00293 //
00294 // CLASS: ovm_line_printer
00295 //
00296 // Tree printer prints output in a line format.
00297 //------------------------------------------------------------------------------
00298 
00299 class ovm_line_printer extends ovm_tree_printer;
00300   extern virtual function void print_newline      (bit do_global_indent=1);
00301   extern  function new(); 
00302 endclass
00303 
00304 
00305 // Package global printer objects
00306 ovm_table_printer ovm_default_table_printer = new();
00307 ovm_tree_printer  ovm_default_tree_printer  = new();
00308 ovm_line_printer  ovm_default_line_printer  = new();
00309 
00310 ovm_printer       ovm_default_printer = ovm_default_table_printer;
00311 
00312 
00313 `endif

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