1
\$\begingroup\$

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?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.