Search code examples
verilogsystem-veriloguvmquestasim

Why can the argument of `uvm_info not be convert2string()?


I defined a class called repeat_seq, which extends from base_seq, which extends from uvm_sequence. Some slicing code has shown the following:

class repeat_seq extends hermes_base_seq;
...
hermes_router_seq_config cfg;
...
task pre_body();
 super.pre_body();
 if(!uvm_config_db #(hermes_router_seq_config)::get(get_sequencer(),"","config",cfg))
   `uvm_fatal(get_type_name(), "config config_db lookup failed")
endtask
task body;
...
`uvm_info("repeat_seq",cfg.convert2string(),UVM_HIGH)
...
endtask: body

In class hermes_router_seq_config, the convert2string function has shown the following:

virtual function string convert2string();
  string s = super.convert2string();
  s = { s, $psprintf( "\n port       : %0d", port) };
  s = { s, $psprintf( "\n p_size     : %0d", p_size) };
  s = { s, $psprintf( "\n header     : %H" , header) };
  s = { s, $psprintf( "\n valid_addr : %p" , hermes_pkg::valid_addrs(port)) };
  s = { s, $psprintf( "\n npackets   : %0d", npackets) };
  return s;
endfunction: convert2string

However, in the transcript file, the corresponding message is:

UVM_INFO /home/ICer/nocc/noc-router/tb/seqs/src/repeat_seq.sv(39) @ 130000: uvm_test_top.env.agent_master_2.sequencer@@seq [repeat_seq]

I find that an `uvm_info doesn't print as expected in monitor, which also takes convert2string() as an argument.


Solution

  • The argument of `uvm_info can be convert2string().

    In the transcript file, look at the lines immediately following the UVM_INFO line. You didn't show us the code for super.convert2string, but after that, the 1st character you assign to the string is a newline (\n):

    s = { s, $psprintf( "\n port       : %0d", port) };
    

    This means that the port string will be on a different line from the UVM_INFO string. Your code shows 5 newline characters, which means your output will be on 5 different lines in the transcript file.

    Your output could look like:

    UVM_INFO /home/ICer/nocc/noc-router/tb/seqs/src/repeat_seq.sv(39) @ 130000: uvm_test_top.env.agent_master_2.sequencer@@seq [repeat_seq]
     port    : 5
     p_size  : 2
     header  : A
     ...