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:52 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 
00081   bit       print_fields   = 1;      // Used by the tcl printing
00082 
00083   //where to print
00084   int       mcd            = OVM_STDOUT; // file descriptor(s) to write to
00085   bit       sprint         = 0;      // if set, write to string instead of mcd
00086 
00087   //Radix output control
00088   string    bin_radix      = "'b";
00089   string    oct_radix      = "'o";
00090   string    dec_radix      = "'d";
00091   string    unsigned_radix = "'d";
00092   string    hex_radix      = "'h";
00093 
00094   extern function string get_radix_str(ovm_radix_enum radix);
00095 endclass
00096 
00097 
00098 //------------------------------------------------------------------------------
00099 //
00100 // CLASS: ovm_printer
00101 //
00102 // Provides a generic printer. No formatting is done, the information is 
00103 // just printed in a raw form.
00104 //------------------------------------------------------------------------------
00105 
00106 class ovm_printer;
00107   protected bit m_array_stack[$];
00108   ovm_scope_stack    m_scope  = new;  //for internal use
00109   string             m_string = "";   //for internal use
00110 
00111   ovm_printer_knobs  knobs = new;
00112 
00113   // Primary derived class overrides. Use these methods to create a new 
00114   // printer type. Functions needed for array printing are not protected
00115   // since array printing must be done in macros.
00116   extern virtual  function void print_header       ();
00117   extern virtual  function void print_footer       ();
00118   extern virtual protected function void print_id           (string      id, 
00119                                          byte        scope_separator=".");
00120   extern virtual protected function void print_type_name    (string      name, bit is_object=0);
00121   extern virtual protected function void print_size         (int         size=-1);
00122   extern virtual protected function void print_newline      (bit         do_global_indent=1);
00123   extern virtual protected function void print_value        (ovm_bitstream_t value, 
00124                                          int         size, 
00125                                          ovm_radix_enum  radix=OVM_NORADIX);
00126   extern virtual protected function void print_value_object (ovm_object  value);
00127   extern virtual protected function void print_value_string (string      value);
00128 
00129   extern virtual  function void print_value_array  (string      value="", 
00130                                          int         size=0);
00131   extern virtual  function void print_array_header ( string      name,
00132                                          int         size,     
00133                                          string      arraytype="array",
00134                                          byte        scope_separator=".");
00135   extern virtual  function void print_array_range  (int         min,      
00136                                          int         max);
00137   extern virtual  function void print_array_footer (int         size=0);
00138 
00139   // Utility methods, may be overridden.
00140   extern virtual protected function void indent             (int         depth, 
00141                                          string      indent_str="  ");
00142 
00143   // Primary user level functions. These functions are called from 
00144   // ovm_object::print() methods, or are called directly on any data to
00145   // get formatted printing.
00146   extern virtual function void print_field         ( string      name, 
00147                                          ovm_bitstream_t value, 
00148                                          int         size, 
00149                                          ovm_radix_enum  radix=OVM_NORADIX,
00150                                          byte        scope_separator=".",
00151                                          string      type_name="");
00152   extern virtual function void print_object_header ( string      name,
00153                                          ovm_object  value, 
00154                                          byte        scope_separator=".");
00155   extern virtual function void print_object        (string      name,
00156                                          ovm_object  value, 
00157                                          byte        scope_separator=".");
00158   extern virtual function void print_string        (string      name,
00159                                          string      value, 
00160                                          byte        scope_separator=".");
00161   extern virtual function void print_time          ( string      name,
00162                                          time        value, 
00163                                          byte        scope_separator=".");
00164   extern virtual function void print_generic       (string      name, 
00165                                          string      type_name, 
00166                                          int         size, 
00167                                          string      value,
00168                                          byte        scope_separator=".");
00169 
00170   // Utility methods
00171   extern  function bit    istop             ();
00172   extern  function int    index             (string name);
00173   extern  function string index_string      (int index, 
00174                                          string      name="");
00175   extern protected function void   write_stream      (string str);
00176 endclass
00177 
00178 
00179 //------------------------------------------------------------------------------
00180 //
00181 // CLASS: ovm_hier_printer_knobs
00182 //
00183 // Knobs for hierarchical printing. These are knobs which are common to any
00184 // hierarchy printing control.
00185 //------------------------------------------------------------------------------
00186 class ovm_hier_printer_knobs extends ovm_printer_knobs;
00187   // Add an indentation string for indenting hierarchy instead of 
00188   // printing full names.
00189   string   indent_str    = "  ";    // string to use for indentation
00190   bit      show_root      = 0;      // show full name of the very first object
00191 
00192   extern function new(); 
00193 endclass
00194 
00195 
00196 //------------------------------------------------------------------------------
00197 //
00198 // CLASS: ovm_table_printer_knobs
00199 //
00200 // Table printing knobs. Specifies the length of the columns.
00201 //------------------------------------------------------------------------------
00202 
00203 class ovm_table_printer_knobs extends ovm_hier_printer_knobs;
00204   int            name_width  = 25;      // characters in the name column
00205   int            type_width  = 20;      // characters in the type column
00206   int            size_width  = 5;       // characters in the size column
00207   int            value_width = 20;      // characters in the value column
00208 endclass
00209 
00210 //------------------------------------------------------------------------------
00211 //
00212 // CLASS: ovm_table_printer
00213 //
00214 // Table printer prints output in a tabular format.
00215 //------------------------------------------------------------------------------
00216 
00217 class ovm_table_printer extends ovm_printer;
00218   extern  function new(); 
00219 
00220   // Adds column headers
00221   extern virtual function void print_header       ();
00222   extern virtual function void print_footer       ();
00223 
00224   // Puts information in column format
00225   extern virtual function void print_id           (string      id,
00226                                         byte        scope_separator=".");
00227   extern virtual function void print_size         (int         size=-1);
00228   extern virtual function void print_type_name    (string      name, bit is_object=0);
00229   extern virtual function void print_value        (ovm_bitstream_t value, 
00230                                         int         size, 
00231                                         ovm_radix_enum  radix=OVM_NORADIX);
00232   extern virtual function void print_value_object (ovm_object  value);
00233   extern virtual function void print_value_string (string      value);
00234   extern virtual function void print_value_array  (string      value="", 
00235                                         int         size=0);
00236 
00237   //override the knobs variable to allow direct access
00238   ovm_table_printer_knobs knobs = new;
00239 endclass
00240 
00241 
00242 //------------------------------------------------------------------------------
00243 //
00244 // CLASS: ovm_tree_printer_knobs
00245 //
00246 // Tree printing knobs. Specifies the hierarchy separator.
00247 //------------------------------------------------------------------------------
00248 
00249 class ovm_tree_printer_knobs extends ovm_hier_printer_knobs;
00250   string            separator     = "{}";    // the separator for composites
00251 endclass
00252 
00253 
00254 //------------------------------------------------------------------------------
00255 //
00256 // CLASS: ovm_tree_printer
00257 //
00258 // Tree printer prints output in a tree format.
00259 //------------------------------------------------------------------------------
00260 
00261 class ovm_tree_printer extends ovm_printer;
00262   // Information to print at the opening/closing of a scope
00263   extern virtual function void print_scope_open   ();
00264   extern virtual function void print_scope_close  ();
00265 
00266   // Puts information in tree format
00267   extern virtual function void print_id           (string id,
00268                                         byte   scope_separator=".");
00269   extern virtual function void print_type_name    (string name, bit is_object=0);
00270   extern virtual function void print_object_header(string      name,
00271                                         ovm_object  value, 
00272                                         byte        scope_separator=".");
00273   extern virtual function void print_object       (string      name,
00274                                         ovm_object  value, 
00275                                         byte        scope_separator=".");
00276   extern virtual function void print_string       ( string      name,
00277                                         string      value, 
00278                                         byte        scope_separator=".");
00279   extern virtual function void print_value_object (ovm_object value);
00280   extern virtual function void print_value_array  (string      value="", 
00281                                         int         size=0);
00282   extern virtual function void print_array_footer (int         size=0);
00283 
00284   extern function new(); 
00285 
00286   //override the knobs variable to allow direct access
00287   ovm_tree_printer_knobs knobs = new;
00288 endclass
00289 
00290 
00291 //------------------------------------------------------------------------------
00292 //
00293 // CLASS: ovm_line_printer
00294 //
00295 // Tree printer prints output in a line format.
00296 //------------------------------------------------------------------------------
00297 
00298 class ovm_line_printer extends ovm_tree_printer;
00299   extern virtual function void print_newline      (bit do_global_indent=1);
00300   extern  function new(); 
00301 endclass
00302 
00303 
00304 // Package global printer objects
00305 ovm_table_printer ovm_default_table_printer = new();
00306 ovm_tree_printer  ovm_default_tree_printer  = new();
00307 ovm_line_printer  ovm_default_line_printer  = new();
00308 
00309 ovm_printer       ovm_default_printer = ovm_default_table_printer;
00310 
00311 
00312 `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:20:12 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV