| Customized Printing in OVM Introduction OVM provides three built-in print policies for controlling the output of a print operation. These are ovm_table_printer (default), ovm_line_printer and ovm_tree_printer. Usually one of these three policies will be sufficient for our needs, but occasionally we need more control over the print output.
OVM allows us to customize one of the built-in polices by changing pre-defined switches and options. Tutorial
Default printing in OVM
Given the data item packet defined as follows:-
class packet extends ovm_sequence_item;
Then we can create, randomize and print instances of packet as follows:-
packet p1;
Which gives us the following output (using the default ovm_table_printer policy).
Name Type Size Value Remember we have some basic control over the Value format for each property using flag options in the `ovm_field_int macro. For example, adding the OVM_BIN flag to the field macro for data_out will print the value in binary:
...
Name Type Size Value
But what if we need more control over this output. For example, we may want to omit the Size column. To customize the print, we need to create a new instance of one of the built-in OVM print policies, and then edit the policy options:
packet p1;
Here we create a new instance of the ovm_table_printer, named custom. We then set the size_width property of the knobs field of custom to zero. This stops the Size data printing. We pass our custom print policy as an argument to print, which gives us the following output:
Name Type Value
The full list of printer policy options can be found in the OVM Class Reference documentation (PDF or HTML) under ovm_printer_knobs.
Examples include:-
begin_elements, end_elements (default value 5) For an array or queue field of size greater than 10, OVM will only print the first and last 5 elements by default. We can print more array elements by increasing begin_elements and end_elements, or print the entire array by setting these to -1.
name_width (default value 25) Sets the width (in characters) of the name field. This only applies to the ovm_table_printer policy.
mcd (default value OVM_STDOUT) File descriptor or Multi-Channel Descriptor which specifies where the output should be directed. By default, this is to the simulator standard output.
Previous Tutorial | Next Tutorial |
