0
class dpcfg extends uvm_object;
  rand int num_lanes;

  function new(string name="");
    super.new(name);
  endfunction

  function void do_print(uvm_printer printer);
    printer.print_string("dpcfg", "dpcfg");
    printer.print_field("num_lanes", num_lanes, $bits(num_lanes));
  endfunction

endclass

//Instantiating the above class
dpcfg cfg;
cfg = new("cfg");
cfg.print();

I am getting the print output as below

 ----------------------------------------------
 Name                Type      Size  Value     
 ----------------------------------------------
 cfg                 dpcfg     -     @2579     
   dpcfg             string    5     dpcfg     
   num_lanes         integral  32    'hA 
 ----------------------------------------------

where I need print output as below

 ----------------------------------------------
 Name                Type      Size  Value     
 ----------------------------------------------
 cfg                 dpcfg     -     @2579     
   dpcfg             string    5     dpcfg     
   num_lanes         integral  32    'd10 
 ----------------------------------------------
toolic
  • 57,801
  • 17
  • 75
  • 117
  • Duplicate of this: https://stackoverflow.com/questions/26229884/uvm-info-returning-a-hex-value The first answer seems to be the bkm. – Tal Jehuda Oct 13 '22 at 08:44

2 Answers2

0

How about:

printer.print_field("num_lanes", num_lanes, $bits(num_lanes), UVM_DEC);

The prototype for print_field is:

  // Function: print_field
  //
  // Prints an integral field (up to 4096 bits).
  //
  // name  - The name of the field. 
  // value - The value of the field.
  // size  - The number of bits of the field (maximum is 4096). 
  // radix - The radix to use for printing. The printer knob for radix is used
  //           if no radix is specified. 
  // scope_separator - is used to find the leaf name since many printers only
  //           print the leaf name of a field.  Typical values for the separator
  //           are . (dot) or [ (open bracket).

  extern virtual function void print_field (string          name, 
                                            uvm_bitstream_t value, 
                                            int    size, 
                                            uvm_radix_enum radix=UVM_NORADIX,
                                            byte   scope_separator=".",
                                            string type_name="");

How do I know this? From the HTML documentation that comes with UVM. It's really, really good and then, if in doubt, you can click through to the UVM code itself.

Matthew Taylor
  • 13,365
  • 3
  • 17
  • 44
0

adding UVM_DEC solved the issue

function void do_print(uvm_printer printer);
  printer.print_string("dpcfg", "dpcfg");
  printer.print_field("num_lanes", num_lanes, $bits(num_lanes), UVM_DEC);
endfunction