ovm_printer

The ovm_printer class provides an interface for printing ovm_objects in various formats.  Subtypes of ovm_printer implement different print formats, or policies.

A user-defined printer format can be created, or one of the following four built-in printers can be used:

Printers have knobs that you use to control what and how information is printed.  These knobs are contained in separate knob classes:

For convenience, global instances of each printer type are available for direct reference in your testbenches.

The ovm_default_printer is used by ovm_object::print and ovm_object::sprint when the optional ovm_printer argument to these methods is not provided.

Summary
ovm_printer
The ovm_printer class provides an interface for printing ovm_objects in various formats.
Class Declaration
class ovm_printer
knobsThe knob object provides access to the variety of knobs associated with a specific printer instance.
Methods for printer usage
print_fieldPrints an integral field.
print_object_headerPrints the header of an object.
print_objectPrints an object.
print_stringPrints a string field.
print_timePrints a time value.
Methods for printer subtyping
print_headerPrints header information.
print_footerPrints footer information.
print_idPrints a field’s name, or id, which is the full instance name.
print_type_namePrints a field’s type name.
print_sizePrints a field’s size.
print_newlinePrints a newline character.
print_valuePrints an integral field’s value.
print_value_objectPrints a unique handle identifier for the given object.
print_value_stringPrints a string field’s value.
print_value_arrayPrints an array’s value.
print_array_headerPrints the header of an array.
print_array_rangePrints a range using ellipses for values.
print_array_footerPrints the header of a footer.

knobs

ovm_printer_knobs knobs = new

The knob object provides access to the variety of knobs associated with a specific printer instance.

Each derived printer class overwrites the knobs variable with the a derived knob class that extends ovm_printer_knobs.  The derived knobs class adds more knobs to the base knobs.

print_field

virtual function void print_field (string name,  
ovm_bitstream_t value,  
int size,  
ovm_radix_enum radix = OVM_NORADIX,
byte scope_separator = ".",
string type_name = "")

Prints an integral field.

nameThe name of the field.
valueThe value of the field.
sizeThe number of bits of the field (maximum is 4096).
radixThe radix to use for printingthe printer knob for radix is used if no radix is specified.
scope_separatoris used to find the leaf name since many printers only print the leaf name of a field.  Typical values for the separator are . (dot) or [ (open bracket).

print_object_header

virtual function void print_object_header (string name,  
ovm_object value,  
byte scope_separator = ".")

Prints the header of an object.

This function is called when an object is printed by reference.  For this function, the object will not be recursed.

print_object

virtual function void print_object (string name,  
ovm_object value,  
byte scope_separator = ".")

Prints an object.  Whether the object is recursed depends on a variety of knobs, such as the depth knob; if the current depth is at or below the depth setting, then the object is not recursed.

By default, the children of ovm_components are printed.  To turn this behavior off, you must set the ovm_component::print_enabled bit to 0 for the specific children you do not want automatically printed.

print_string

virtual function void print_string (string name,  
string value,  
byte scope_separator = ".")

Prints a string field.

print_time

virtual function void print_time (string name,  
time value,  
byte scope_separator = ".")

Prints a time value. name is the name of the field, and value is the value to print.

The print is subject to the $timeformat system task for formatting time values.

print_header

virtual function void print_header ()

Prints header information.  It is called when the current depth is 0, before any fields have been printed.

print_footer

virtual function void print_footer ()

Prints footer information.  It is called when the current depth is 0, after all fields have been printed.

print_id

virtual protected function void print_id (string id,  
byte scope_separator = ".")

Prints a field’s name, or id, which is the full instance name.

The intent of the separator is to mark where the leaf name starts if the printer if configured to print only the leaf name of the identifier.

print_type_name

virtual protected function void print_type_name (string name,  
bit is_object = )

Prints a field’s type name.

The is_object bit indicates that the item being printed is an object derived from ovm_object.

print_size

virtual protected function void print_size (int size = -1)

Prints a field’s size.  A size of -1 indicates that no size is available, in which case the printer inserts the appropriate white space if the format requires it.

print_newline

virtual protected function void print_newline (bit do_global_indent = 1)

Prints a newline character.  It is up to the printer to determine how or whether to display new lines.  The do_global_indent bit indicates whether the call to print_newline() should honor the indent knob.

print_value

virtual protected function void print_value (ovm_bitstream_t value,  
int size,  
ovm_radix_enum radix = OVM_NORADIX)

Prints an integral field’s value.

The value vector is up to 4096 bits, and the size input indicates the number of bits to actually print.

The radix input is the radix that should be used for printing the value.

print_value_object

virtual protected function void print_value_object (ovm_object value)

Prints a unique handle identifier for the given object.

print_value_string

virtual protected function void print_value_string (string value)

Prints a string field’s value.

print_value_array

virtual function void print_value_array (string value = "",
int size = 0)

Prints an array’s value.

This only prints the header value of the array, which means that it implements the printer-specific print_array_header().

value is the value to be printed for the array.  It is generally the string representation of size, but it may be any string.  size is the number of elements in the array.

print_array_header

virtual function void print_array_header(string name,  
int size,  
string arraytype = "array",
byte scope_separator = ".")

Prints the header of an array.  This function is called before each individual element is printed.  print_array_footer is called to mark the completion of array printing.

print_array_range

virtual function void print_array_range (int min,
int max)

Prints a range using ellipses for values.  This method is used when honoring the array knobs for partial printing of large arrays, ovm_printer_knobs::begin_elements and ovm_printer_knobs::end_elements.

This function should be called after begin_elements have been printed and after end_elements have been printed.

print_array_footer

virtual function void print_array_footer (int size = )

Prints the header of a footer.  This function marks the end of an array print.  Generally, there is no output associated with the array footer, but this method lets the printer know that the array printing is complete.

ovm_table_printer

The table printer prints output in a tabular format.

The following shows sample output from the table printer.

---------------------------------------------------
Name        Type            Size        Value
---------------------------------------------------
c1          container       -           @1013
d1          mydata          -           @1022
v1          integral        32          'hcb8f1c97
e1          enum            32          THREE
str         string          2           hi
value       integral        12          'h2d
---------------------------------------------------
Summary
ovm_table_printer
The table printer prints output in a tabular format.
Class Hierarchy
ovm_table_printer
Class Declaration
class ovm_table_printer extends ovm_printer
Variables
newCreates a new instance of ovm_table_printer.
knobsAn instance of ovm_table_printer_knobs, which govern the content and format of the printed table.

new

function new()

Creates a new instance of ovm_table_printer.

knobs

ovm_table_printer_knobs knobs = new

An instance of ovm_table_printer_knobs, which govern the content and format of the printed table.

ovm_tree_printer

By overriding various methods of the ovm_printer super class, the tree printer prints output in a tree format.

The following shows sample output from the tree printer.

c1: (container@1013) {
  d1: (mydata@1022) {
       v1: 'hcb8f1c97
       e1: THREE
       str: hi
  }
  value: 'h2d
}
Summary
ovm_tree_printer
By overriding various methods of the ovm_printer super class, the tree printer prints output in a tree format.
Class Hierarchy
ovm_tree_printer
Class Declaration
class ovm_tree_printer extends ovm_printer
Variables
newCreates a new instance of ovm_tree_printer.
knobsAn instance of ovm_tree_printer_knobs, which govern the content and format of the printed tree.

new

function new()

Creates a new instance of ovm_tree_printer.

knobs

ovm_tree_printer_knobs knobs = new

An instance of ovm_tree_printer_knobs, which govern the content and format of the printed tree.

ovm_line_printer

The line printer prints output in a line format.

The following shows sample output from the line printer.

c1: (container@1013) { d1: (mydata@1022) { v1: 'hcb8f1c97 e1: THREE str: hi } value: 'h2d }
Summary
ovm_line_printer
The line printer prints output in a line format.
Class Hierarchy
ovm_line_printer
Class Declaration
class ovm_line_printer extends ovm_tree_printer
Variables
newCreates a new instance of ovm_line_printer.
Methods
print_newlineOverrides ovm_printer::print_newline to not print a newline, effectively making everything appear on a single line.

new

function new()

Creates a new instance of ovm_line_printer.

print_newline

virtual function void print_newline (bit do_global_indent = 1)

Overrides ovm_printer::print_newline to not print a newline, effectively making everything appear on a single line.

ovm_printer_knobs

The ovm_printer_knobs class defines the printer settings available to all printer subtypes.  Printer subtypes may subtype this class to provide additional knobs for their specific format.  For example, the ovm_table_printer uses the ovm_table_printer_knobs, which defines knobs for setting table column widths.

Summary
ovm_printer_knobs
The ovm_printer_knobs class defines the printer settings available to all printer subtypes.
Class Declaration
class ovm_printer_knobs
Variables
max_widthThe maximum with of a field.
truncationSpecifies the character to use to indicate a field was truncated.
headerIndicates whether the <print_header> function should be called when printing an object.
footerIndicates whether the <print_footer> function should be called when printing an object.
global_indentSpecifies the number of spaces of indentation to add whenever a newline is printed.
full_nameIndicates whether <print_id> should print the full name of an identifier or just the leaf name.
identifierIndicates whether <print_id> should print the identifier.
depthIndicates how deep to recurse when printing objects.
referenceControls whether to print a unique reference ID for object handles.
type_nameControls whether to print a field’s type name.
sizeControls whether to print a field’s size.
begin_elementsDefines the number of elements at the head of a list to print.
end_elementsThis defines the number of elements at the end of a list that should be printed.
show_radixIndicates whether the radix string (‘h, and so on) should be prepended to an integral value when one is printed.
prefixSpecifies the string prepended to each output line
mcdThis is a file descriptor, or multi-channel descriptor, that specifies where the print output should be directed.
default_radixThis knob sets the default radix to use for integral values when no radix enum is explicitly supplied to the print_field() method.
dec_radixThis string should be prepended to the value of an integral type when a radix of OVM_DEC is used for the radix of the integral object.
bin_radixThis string should be prepended to the value of an integral type when a radix of OVM_BIN is used for the radix of the integral object.
oct_radixThis string should be prepended to the value of an integral type when a radix of OVM_OCT is used for the radix of the integral object.
unsigned_radixThis is the string which should be prepended to the value of an integral type when a radix of OVM_UNSIGNED is used for the radix of the integral object.
hex_radixThis string should be prepended to the value of an integral type when a radix of OVM_HEX is used for the radix of the integral object.
Methods
get_radix_strConverts the radix from an enumerated to a printable radix according to the radix printing knobs (bin_radix, and so on).

max_width

int max_width = 999

The maximum with of a field.  Any field that requires more characters will be truncated.

truncation

string truncation = "+"

Specifies the character to use to indicate a field was truncated.

header

bit header = 1

Indicates whether the <print_header> function should be called when printing an object.

footer

bit footer = 1

Indicates whether the <print_footer> function should be called when printing an object.

global_indent

int global_indent = 0

Specifies the number of spaces of indentation to add whenever a newline is printed.

full_name

bit full_name = 1

Indicates whether <print_id> should print the full name of an identifier or just the leaf name.  The line, table, and tree printers ignore this bit and always print only the leaf name.

identifier

bit identifier = 1

Indicates whether <print_id> should print the identifier.  This is useful in cases where you just want the values of an object, but no identifiers.

depth

int depth = -1

Indicates how deep to recurse when printing objects.  A depth of -1 means to print everything.

reference

bit reference = 1

Controls whether to print a unique reference ID for object handles.  The behavior of this knob is simulator-dependent.

type_name

bit type_name = 1

Controls whether to print a field’s type name.

size

bit size = 1

Controls whether to print a field’s size.

begin_elements

int begin_elements = 5

Defines the number of elements at the head of a list to print.  Use -1 for no max.

end_elements

int end_elements = 5

This defines the number of elements at the end of a list that should be printed.

show_radix

bit show_radix = 1

Indicates whether the radix string (‘h, and so on) should be prepended to an integral value when one is printed.

prefix

string prefix = ""

Specifies the string prepended to each output line

mcd

int mcd = OVM_STDOUT

This is a file descriptor, or multi-channel descriptor, that specifies where the print output should be directed.

By default, the output goes to the standard output of the simulator.

default_radix

ovm_radix_enum default_radix = OVM_HEX

This knob sets the default radix to use for integral values when no radix enum is explicitly supplied to the print_field() method.

dec_radix

string dec_radix = "'d"

This string should be prepended to the value of an integral type when a radix of OVM_DEC is used for the radix of the integral object.

When a negative number is printed, the radix is not printed since only signed decimal values can print as negative.

bin_radix

string bin_radix = "'b"

This string should be prepended to the value of an integral type when a radix of OVM_BIN is used for the radix of the integral object.

oct_radix

string oct_radix = "'o"

This string should be prepended to the value of an integral type when a radix of OVM_OCT is used for the radix of the integral object.

unsigned_radix

string unsigned_radix = "'d"

This is the string which should be prepended to the value of an integral type when a radix of OVM_UNSIGNED is used for the radix of the integral object.

hex_radix

string hex_radix = "'h"

This string should be prepended to the value of an integral type when a radix of OVM_HEX is used for the radix of the integral object.

get_radix_str

function string get_radix_str (ovm_radix_enum radix)

Converts the radix from an enumerated to a printable radix according to the radix printing knobs (bin_radix, and so on).

ovm_hier_printer_knobs

The ovm_hier_printer_knobs is a simple container class that extends <ovm_printer::ovm_printer_knobs> with settings for printing information hierarchically.

Summary
ovm_hier_printer_knobs
The ovm_hier_printer_knobs is a simple container class that extends <ovm_printer::ovm_printer_knobs> with settings for printing information hierarchically.
Class Hierarchy
ovm_hier_printer_knobs
Class Declaration
class ovm_hier_printer_knobs extends ovm_printer_knobs
Variables
indent_strThis knob specifies the string to use for level indentation.
show_rootThis setting indicates whether or not the initial object that is printed (when current depth is 0) prints the full path name.

indent_str

string indent_str = " "

This knob specifies the string to use for level indentation.  The default level indentation is two spaces.

show_root

bit show_root = 0

This setting indicates whether or not the initial object that is printed (when current depth is 0) prints the full path name.  By default, the first object is treated like all other objects and only the leaf name is printed.

ovm_table_printer_knobs

The ovm_table_printer_knobs is a simple container class that extends <ovm_printer::ovm_hier_printer_knobs> with settings specific to printing in table format.

Summary
ovm_table_printer_knobs
The ovm_table_printer_knobs is a simple container class that extends <ovm_printer::ovm_hier_printer_knobs> with settings specific to printing in table format.
Class Hierarchy
ovm_table_printer_knobs
Class Declaration
class ovm_table_printer_knobs extends ovm_hier_printer_knobs
Variables
name_widthSets the width of the name column.
type_widthSets the width of the type column.
size_widthSets the width of the size column.
value_widthSets the width of the value column.

name_width

int name_width = 25

Sets the width of the name column.  If set to 0, the column is not printed.

type_width

int type_width = 20

Sets the width of the type column.  If set to 0, the column is not printed.

size_width

int size_width = 5

Sets the width of the size column.  If set to 0, the column is not printed.

value_width

int value_width = 20

Sets the width of the value column.  If set to 0, the column is not printed.

ovm_tree_printer_knobs

The ovm_tree_printer_knobs is a simple container class that extends <ovm_printer::ovm_hier_printer_knobs> with settings specific to printing in tree format.

Summary
ovm_tree_printer_knobs
The ovm_tree_printer_knobs is a simple container class that extends <ovm_printer::ovm_hier_printer_knobs> with settings specific to printing in tree format.
Class Hierarchy
ovm_tree_printer_knobs
Class Declaration
class ovm_tree_printer_knobs extends ovm_hier_printer_knobs
Variables
separatorDetermines the opening and closing separators used for nested objects.

separator

string separator = "{}"

Determines the opening and closing separators used for nested objects.

class ovm_printer
The ovm_printer class provides an interface for printing ovm_objects in various formats.
virtual class ovm_object extends ovm_void
The ovm_object class is the base class for all OVM data and hierarchical classes.
ovm_printer_knobs knobs = new
The knob object provides access to the variety of knobs associated with a specific printer instance.
virtual function void print_field (string name,  
ovm_bitstream_t value,  
int size,  
ovm_radix_enum radix = OVM_NORADIX,
byte scope_separator = ".",
string type_name = "")
Prints an integral field.
virtual function void print_object_header (string name,  
ovm_object value,  
byte scope_separator = ".")
Prints the header of an object.
virtual function void print_object (string name,  
ovm_object value,  
byte scope_separator = ".")
Prints an object.
virtual function void print_string (string name,  
string value,  
byte scope_separator = ".")
Prints a string field.
virtual function void print_time (string name,  
time value,  
byte scope_separator = ".")
Prints a time value.
virtual function void print_header ()
Prints header information.
virtual function void print_footer ()
Prints footer information.
virtual protected function void print_id (string id,  
byte scope_separator = ".")
Prints a field’s name, or id, which is the full instance name.
virtual protected function void print_type_name (string name,  
bit is_object = )
Prints a field’s type name.
virtual protected function void print_size (int size = -1)
Prints a field’s size.
virtual protected function void print_newline (bit do_global_indent = 1)
Prints a newline character.
virtual protected function void print_value (ovm_bitstream_t value,  
int size,  
ovm_radix_enum radix = OVM_NORADIX)
Prints an integral field’s value.
virtual protected function void print_value_object (ovm_object value)
Prints a unique handle identifier for the given object.
virtual protected function void print_value_string (string value)
Prints a string field’s value.
virtual function void print_value_array (string value = "",
int size = 0)
Prints an array’s value.
virtual function void print_array_header(string name,  
int size,  
string arraytype = "array",
byte scope_separator = ".")
Prints the header of an array.
virtual function void print_array_range (int min,
int max)
Prints a range using ellipses for values.
virtual function void print_array_footer (int size = )
Prints the header of a footer.
class ovm_table_printer extends ovm_printer
The table printer prints output in a tabular format.
class ovm_tree_printer extends ovm_printer
By overriding various methods of the ovm_printer super class, the tree printer prints output in a tree format.
class ovm_line_printer extends ovm_tree_printer
The line printer prints output in a line format.
class ovm_printer_knobs
The ovm_printer_knobs class defines the printer settings available to all printer subtypes.
class ovm_hier_printer_knobs extends ovm_printer_knobs
The ovm_hier_printer_knobs is a simple container class that extends ovm_printer::ovm_printer_knobs with settings for printing information hierarchically.
class ovm_table_printer_knobs extends ovm_hier_printer_knobs
The ovm_table_printer_knobs is a simple container class that extends ovm_printer::ovm_hier_printer_knobs with settings specific to printing in table format.
class ovm_tree_printer_knobs extends ovm_hier_printer_knobs
The ovm_tree_printer_knobs is a simple container class that extends ovm_printer::ovm_hier_printer_knobs with settings specific to printing in tree format.
ovm_tree_printer ovm_default_tree_printer = new()
The tree printer is a global object that can be used with ovm_object::do_print to get multi-line tree style printing.
ovm_line_printer ovm_default_line_printer = new()
The line printer is a global object that can be used with ovm_object::do_print to get single-line style printing.
ovm_table_printer ovm_default_table_printer = new()
The table printer is a global object that can be used with ovm_object::do_print to get tabular style printing.
ovm_printer ovm_default_printer = ovm_default_table_printer
The default printer is a global object that is used by ovm_object::print or ovm_object::sprint when no specific printer is set.
function void print (ovm_printer printer = null)
The print method deep-prints this object’s properties in a format and manner governed by the given printer argument; if the printer argument is not provided, the global ovm_default_printer is used.
function string sprint (ovm_printer printer = null)
The sprint method works just like the print method, except the output is returned in a string rather than displayed.
virtual class ovm_component extends ovm_report_object
The ovm_component class is the root base class for OVM components.
bit print_enabled = 1
This bit determines if this component should automatically be printed as a child of its parent object.
int begin_elements = 5
Defines the number of elements at the head of a list to print.
int end_elements = 5
This defines the number of elements at the end of a list that should be printed.
function new()
Creates a new instance of ovm_table_printer.
ovm_table_printer_knobs knobs = new
An instance of ovm_table_printer_knobs, which govern the content and format of the printed table.
function new()
Creates a new instance of ovm_tree_printer.
ovm_tree_printer_knobs knobs = new
An instance of ovm_tree_printer_knobs, which govern the content and format of the printed tree.
function new()
Creates a new instance of ovm_line_printer.
virtual function void print_newline (bit do_global_indent = 1)
Overrides ovm_printer::print_newline to not print a newline, effectively making everything appear on a single line.
int max_width = 999
The maximum with of a field.
string truncation = "+"
Specifies the character to use to indicate a field was truncated.
bit header = 1
Indicates whether the print_header function should be called when printing an object.
bit footer = 1
Indicates whether the print_footer function should be called when printing an object.
int global_indent = 0
Specifies the number of spaces of indentation to add whenever a newline is printed.
bit full_name = 1
Indicates whether print_id should print the full name of an identifier or just the leaf name.
bit identifier = 1
Indicates whether print_id should print the identifier.
int depth = -1
Indicates how deep to recurse when printing objects.
bit reference = 1
Controls whether to print a unique reference ID for object handles.
bit type_name = 1
Controls whether to print a field’s type name.
bit size = 1
Controls whether to print a field’s size.
bit show_radix = 1
Indicates whether the radix string (‘h, and so on) should be prepended to an integral value when one is printed.
string prefix = ""
Specifies the string prepended to each output line
int mcd = OVM_STDOUT
This is a file descriptor, or multi-channel descriptor, that specifies where the print output should be directed.
ovm_radix_enum default_radix = OVM_HEX
This knob sets the default radix to use for integral values when no radix enum is explicitly supplied to the print_field() method.
string dec_radix = "'d"
This string should be prepended to the value of an integral type when a radix of OVM_DEC is used for the radix of the integral object.
Selects decimal (%d) format
string bin_radix = "'b"
This string should be prepended to the value of an integral type when a radix of OVM_BIN is used for the radix of the integral object.
Selects binary (%b) format
string oct_radix = "'o"
This string should be prepended to the value of an integral type when a radix of OVM_OCT is used for the radix of the integral object.
Selects octal (%o) format
string unsigned_radix = "'d"
This is the string which should be prepended to the value of an integral type when a radix of OVM_UNSIGNED is used for the radix of the integral object.
Selects unsigned decimal (%u) format
string hex_radix = "'h"
This string should be prepended to the value of an integral type when a radix of OVM_HEX is used for the radix of the integral object.
Selects hexidecimal (%h) format
function string get_radix_str (ovm_radix_enum radix)
Converts the radix from an enumerated to a printable radix according to the radix printing knobs (bin_radix, and so on).
string indent_str = " "
This knob specifies the string to use for level indentation.
bit show_root = 0
This setting indicates whether or not the initial object that is printed (when current depth is 0) prints the full path name.
int name_width = 25
Sets the width of the name column.
int type_width = 20
Sets the width of the type column.
int size_width = 5
Sets the width of the size column.
int value_width = 20
Sets the width of the value column.
string separator = "{}"
Determines the opening and closing separators used for nested objects.