Need Help in Casting in `uvm_info

Hi,

my requirement is as below:


class my_sequence extends uvm_sequence ;
    //factory registration
   // function new ()
   
    task body () ;
     cntr_read (counter1) 
    endtask
       
 task cntr_read ( reg counter1 )
    
      counter1.read(//arguments );
      `uvm_info (get_full_name(), $sformatf( "counter %0s value is %0d", counter1, value),OVM_LOW )
  endtask

endclass

In the above code, although counter1 is of reg type, I need to display the counter name as “counter1”. Here it displays either H or decimal value if I use %0h or %0d in place of %0s.
I tried to do $cast, it gave runtime Dynamic Cast Failure.

Any help? I am stuck.

Best Regards,
Mahesh

In reply to MaheshBabu:

counter1 is a uvm_object with several data fields. Using the object name for displaying the name will not work. But the uvm_reg provides you with a convinient function to display the name: get_name().

In reply to chr_sue:

In reply to MaheshBabu:
counter1 is a uvm_object with several data fields. Using the object name for displaying the name will not work. But the uvm_reg provides you with a convinient function to display the name: get_name().

Thanks for the reply Mr.chr_sue !

But if I use get_name in place of get_full_name , I ended up in compilation error which says- “%0s” is not a valid type to use.

Regards,
Mahesh

In reply to MaheshBabu:

I did not say you should replace get_full_name() by get_name.

You should do
`uvm_info (get_type_name(), $sformatf( “%0s value is %0d”, counter1.get_name, value),UVM_LOW )