How to print a queue of struct elements in Hex format

Hi,
I have a struct like:
typedef struct {bit[40:0] addr; bit[127:0] data[3:0]; bit[7:0] length; } axi_read_data_packet

and a queue of struct like:

read_data_packet rd[$];

And there is code which pushes/populates the queue and now I want to print the contents of the queue. So, I use the following:

for (int i = 0; i< rd.size, i++) begin
$display(“Value of Queue is %p_”,rd[i]);
end

Question is : The above print statement prints the contents of queue in Decimal format. This is very difficult for debug purpose. Can you please suggest an option for printing in Hex ?

Thanks
Ramya

$displayh(“Value of Queue is %p_”,rd[i]);

In reply to dave_59:

Hi Dave,
Thanks for your response.
I’m using a $psprintf(“Value of Queue is %p_”,rd[i]);

How can I use $psprintf and print the Queue items in Hex format?

I’m calling an internal `define which takes 3 inputs : log_id, text and verbosity for any print messages.
So, I’m using something like:

`print_message(log_id,$psprintf(“Value of Queue is %p_”,rd[i]),6);

(The print message is a `define which takes the three parameters stated above).
Can you please help with how can I pass the text string message inside psprintf to display value of queue items in Hex format?

Thanks

In reply to Ramyas:

The functionality of %p is very limited. You will have break up your struct into individual fields to format or break up the formatting by using an intermediate variable using

$swriteh(temp, “Value of Queue is %p_\n”,rd[i])
`print_message(log_id,temp,6);

In reply to dave_59:
Hi Dave,

Is there a way to print the struct in hexadecimal using uvm_info?

Thanks,
Navathej

In reply to Navathej bangari:

If you want to use %p, you’ll have to use the method above to create a string with $swriteh in a statement before `uvm_info,