uvm_info信息定制

北城余情 提交于 2019-12-06 19:23:55

1,uvm自带的打印信息国语繁重,不利于debug

`uvm_info("TESTCASE",$sformatf("my_case0 new"),UVM_DEBUG);

UVM_INFO /home/zl/Desktop/uvm_study/template/sim/tests/my_case0.sv(29) @ 0: uvm_test_top [TEST_CASE] my_case0 new

修改目标:

UVM_INFO @ 102.2ns uvm_test_top [TEST_CASE] my_case0 new

取消打印文件路径,修改打印时间格式


源代码分析:

uvm_message_defines.svh

// MACRO: `uvm_info
//
//| `uvm_info(ID,MSG,VERBOSITY)
//
// Calls uvm_report_info if ~VERBOSITY~ is lower than the configured verbosity of
// the associated reporter. ~ID~ is given as the message tag and ~MSG~ is given as
// the message text. The file and line are also sent to the uvm_report_info 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); \
   end


uvm_report_catcher.svh

   protected function void uvm_report_info(string id, string message, int verbosity, string fname = "", int line = 0 );
     string m;
     uvm_action a;
     UVM_FILE f;
     uvm_report_handler rh;
     rh    = this.m_client.get_report_handler();
     a    = rh.get_action(UVM_INFO,id);
     f     = rh.get_file_handle(UVM_INFO,id);
     
     m     = this.m_server.compose_message(UVM_INFO,this.m_name, id, message, fname, line);
     this.m_server.process_report(UVM_INFO, this.m_name, id, message, a, f, fname, line,
                                  m, verbosity, this.m_client);
   endfunction // uvm_report_info


uvm_report_server.svh

  virtual function void process_report(
      uvm_severity severity,
      string name,
      string id,
      string message,
      uvm_action action,
      UVM_FILE file,
      string filename,
      int line,
      string composed_message,
      int verbosity_level,
      uvm_report_object client
      );


    uvm_cmdline_processor clp;
    string stack_args[$];
    string split_vals[$];
    static int debug, info, warn, error, fatal;
    static bit first = 1;
    
    if(first) begin
       clp = uvm_cmdline_processor::get_inst();


       void'(clp.get_arg_matches("+UVM_STACKTRACE", stack_args));
       //Take into account if option is specified multiple times.
       foreach(stack_args[i]) begin
          string temp;
          temp = stack_args[i].substr(16, stack_args[i].len()-1);
          // In case no additinal argument is specified
          if(temp == "") begin
             error = 1; fatal = 1;
          end
          uvm_split_string(temp, ",", split_vals);
          //For all the comma sepearted options
          foreach(split_vals[i]) begin
             case(split_vals[i])
               "default" : begin error = 1; fatal = 1; end
               "debug"   : begin debug = 1; end
               "info"    : begin info  = 1; end
               "warn"    : begin warn  = 1; end
               "error"   : begin error = 1; end
               "fatal"   : begin fatal = 1; end
               "all"     : begin debug = 1; info = 1; warn = 1; error = 1; fatal = 1; end
               default   : $display("UVM_WARNING::INVLCMDARGS::Invalid argument specified for command line, +UVM_STACKTRACE=%0s", split_vals[i]);
             endcase
          end
       end
       first = 0;
    end


    // update counts
    incr_severity_count(severity);
    incr_id_count(id);


    if(action & UVM_DISPLAY) begin
       case (severity)
          UVM_DEBUG  : if(debug) $stack;
          UVM_INFO   : if(info)  $stack;
          UVM_WARNING: if(warn)  $stack;
          UVM_ERROR  : if(error) $stack;
          UVM_FATAL  : if(fatal) $stack;
       endcase
       $display("%s",composed_message);
    end


    // if log is set we need to send to the file but not resend to the
    // display. So, we need to mask off stdout for an mcd or we need
    // to ignore the stdout file handle for a file handle.
    if(action & UVM_LOG)
      if( (file == 0) || (file != 32'h8000_0001) ) //ignore stdout handle
      begin
        UVM_FILE tmp_file = file;
        if( (file&32'h8000_0000) == 0) //is an mcd so mask off stdout
        begin
           tmp_file = file & 32'hffff_fffe;
        end
        f_display(tmp_file,composed_message);
      end    


    if(action & UVM_EXIT) client.die();


    if(action & UVM_COUNT) begin
      if(get_max_quit_count() != 0) begin
          incr_quit_count();
        if(is_quit_count_reached()) begin
          client.die();
        end
      end  
    end


    if (action & UVM_STOP) $stop;


  endfunction







标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!