Esperan Logo
Esperan is internationally recognised as a high quality provider of training in VHDL, SystemVerilog, SystemC, PSL, SVA, OVM, TLM and for courses covering design, verification, and PCB methodologies.
Esperan Schedule Menu
Esperan Course Menu
Esperan Contact Menus
Esperan UK contact information Phone +44 1344 865436
Fax +44 1344 865347
Email:
info@esperan.com

Contacts for other regions
Free Tutorials

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;

   // Physical Data
   rand bit [7:0] data_out;
   rand bit [7:0] data_in;

   // OVM macros for built-in automation, including print
   `ovm_object_utils_begin(packet)
     `ovm_field_int(data_out, OVM_ALL_ON)
     `ovm_field_int(data_in, OVM_ALL_ON)
   `ovm_object_utils_end

   // standard OVM data constructor
   function new (string name = "packet");
     super.new(name);
   endfunction : new

endclass : packet

 

Then we can create, randomize and print instances of packet as follows:-

 

packet p1;

initial begin
  p1 = new("p1");
  assert(p1.randomize());
  p1.print();
  ...

 

Which gives us the following output (using the default ovm_table_printer policy).

 

Name          Type         Size       Value
----------------------------------------------
p1            packet       -          @467
  data_out    integral     8          'hb7
  data_in     integral     8          'h26
----------------------------------------------

 

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:

 

     ...
     `ovm_field_int(data_out, OVM_ALL_ON + OVM_BIN)
     ...

 

Name          Type         Size        Value
-------------------------------------------------
p1            packet       -           @467
  data_out    integral     8           'b10110111
  data_in     integral     8           'h26
-------------------------------------------------

 

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;

ovm_table_printer custom = new();

initial begin

  custom.knobs.size_width=0;

  p1 = new("p1");
  assert(p1.randomize());
  p1.print(custom);
  ...

 

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
----------------------------------
p1            packet       @467
   data_out   integral     'hb7
   data_in    integral     'h26
----------------------------------

 

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