uvm_info

1.what‘s a good report like:

2.bad display:

module tb;
  initial begin
    // Both are printed to the log
    $display("This is supposed to be a debug message");
    $display("This can be an informational message");
  end
endmodule

3.how uvm_info work:

typedef enum int {LOW, MEDIUM, HIGH} e_verbosity;
class Logger;  
  e_verbosity m_verbosity = LOW;
 
  virtual function void info(e_verbosity e_verb, string str);
 
    if (e_verb >= m_verbosity)
      $display (str);
  endfunction
endclass
 
 
module tb;
  initial begin
    Logger log = new;
    log.m_verbosity = HIGH;
    log.info(LOW,     "Priority low");
    log.info(MEDIUM,  "Priority medium");
    log.info(HIGH,     "Priority high");
  end
endmodule
`uvm_info(ID, MSG, VERBOSITY)
 
// The macro will expand into uvm_report_info() method call
`define uvm_info(ID, MSG, VERBOSITY) \
   begin \
     if (uvm_report_enabled(VERBOSITY,UVM_INFO,ID)) \
       uvm_report_info (ID, MSG, VERBOSITY, `uvm_file, `uvm_line, "", 1); \
   end

4.good code:

//use get_type_name() for id
`uvm_info(get_type_name(), $sformatf("Deassert reset _reset=%0b", _reset), UVM_LOW)

//in for loop
for (int i = 0; i < l_queue.size(); i++) begin
  for (int j = 0; j < l_queue[i].item.size(); j++) begin
    // Some other statements
    `uvm_info("iterate", $sformatf("Idx[i=%0d,j=%0d] Item=%s has value=0x%0h"), i, j, l_queue[i].item[j].m_name, l_queue[i].item[j].m_value), UVM_HIGH)
  end
end

//thread num in fork-join
fork
  begin
    `uvm_info(get_type_name(), $sformatf("[Thread0] Start cfg of regblock"), UVM_LOW)
    // Few other statements
    `uvm_info(get_type_name(), $sformatf("[Thread0] Set calc engine to active"), UVM_LOW)
  end
 
  begin
    `uvm_info(get_type_name(), $sformatf("[Thread1] Wait for event done"), UVM_LOW)
    // Some other code
    `uvm_info(get_type_name(), $sformatf("[Thread1] Event done, check registers"), UVM_LOW)
 
  end
 
  wait_for_evt_done("Thread3");
join

 5.some trick:

do not want line info and file info can +define+UVM_REPORT_DISABLE_FILE_LINE

`ifdef UVM_REPORT_DISABLE_FILE_LINE
  `define UVM_REPORT_DISABLE_FILE
  `define UVM_REPORT_DISABLE_LINE
`endif
 
`ifdef UVM_REPORT_DISABLE_LINE
  `define uvm_line 0
`else
  `define uvm_line `__LINE__
`endif
 
`ifdef UVM_REPORT_DISABLE_FILE
  `define uvm_file ""
`else
  `define uvm_file `__FILE__
`endif
 
`define uvm_info(ID, MSG, VERBOSITY) \
   begin \
     if (uvm_report_enabled(VERBOSITY,UVM_INFO,ID)) \
       uvm_report_info (ID, MSG, VERBOSITY, `uvm_file, `uvm_line, "", 1); \
   end

 

posted on 2019-12-05 20:00  hematologist  阅读(895)  评论(0编辑  收藏  举报

导航