1

I create an object handle in UVM usually with new or create to allocate memory. Is there any possible way to print about created handle information? For example, I made the below example.

task body;
    i2c_packet pkt;
    pkt = i2c_packet::type_id::create("pkt");   
    ...

i2c_packet has bunch of variables. After pkt is created, can I print pkt (uvm_sequence_item's variables) information, and how do I know pkt is created as well or not?

toolic
  • 5,637
  • 5
  • 20
  • 33
Carter
  • 581
  • 2
  • 6
  • 23

1 Answers1

1

Since the uvm_sequence_item class is extended from the uvm_object class, it inherits the print method which is used to display the class variables.

task body;
    i2c_packet pkt;
    pkt = i2c_packet::type_id::create("pkt");
    pkt.print();

Use the uvm_object_utils and uvm_field_* macros in your uvm_sequence_item class to control what gets printed.

class i2c_packet extends uvm_sequence_item;
    ...
    `uvm_object_utils_begin(i2c_packet)
        `uvm_field_int(data, UVM_DEFAULT)
    `uvm_object_utils_end

For a code example, refer to UVM Object Print.

Refer also to the UVM class reference.

toolic
  • 5,637
  • 5
  • 20
  • 33