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