Dskpimc? · 2023年03月09日 · 北京市

谈谈UVM中的uvm_info打印

uvm_info宏的定义如下:

`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\_info由两部分组成:uvm\_report\_enabled(VERBOSITY,UVM\_INFO,ID)和uvm\_report\_info (ID, MSG, VERBOSITY, \`uvm\_file, \`uvm\_line)。当uvm\_report\_enabled(xxx)函数返回为1时,才会执行uvm\_report\_info(xxx)。

参数和变量分析:

1. 我们先看下uvm_info的三个参数。

ID是作为message的标记(tag)。
MSG就是真正要打印的message文本。
VERBOSITY用于传递uvm\_verbosity枚举类型的数字。当VERBOSITY低于相关reporter的配置verbosity时,uvm\_report_info(xxx)将会执行。也就是说VERBOSITY的数字越小,被打印的可能性越高。
对于uvm_verbosity枚举变量的定义如下:

// Enum: uvm_verbosity
// Defines standard verbosity levels for reports.
//  UVM_NONE   - Report is always printed. Verbosity level setting can not disable it.
//  UVM_LOW    - Report is issued if configured verbosity is set to UVM_LOW or above.
//  UVM_MEDIUM - Report is issued if configured verbosity is set to UVM_MEDIUM or above.
//  UVM_HIGH   - Report is issued if configured verbosity is set to UVM_HIGH or above.
//  UVM_FULL   - Report is issued if configured verbosity is set to UVM_FULL or above.
typedef enum
{
  UVM_NONE   = 0,
  UVM_LOW    = 100,
  UVM_MEDIUM = 200,
  UVM_HIGH   = 300,
  UVM_FULL   = 400,
  UVM_DEBUG  = 500
} uvm_verbosity;

2. uvm_report_enabled(xxx)函数上有个UVM_INFO的传参。它是uvm_severity_type枚举值,uvm_severity_type定义如下:

// Enum: uvm_severity
// Defines all possible values for report severity.
//   UVM_INFO    - Informative messsage.
//   UVM_WARNING - Indicates a potential problem.
//   UVM_ERROR   - Indicates a real problem. Simulation continues subject to the configured message action.
//   UVM_FATAL   - Indicates a problem from which simulation can not recover. Simulation exits via $finish after a #0 delay.
typedef bit [1:0] uvm_severity;
typedef enum uvm_severity
{
  UVM_INFO,
  UVM_WARNING,
  UVM_ERROR,
  UVM_FATAL
} uvm_severity_type;

3. uvm_report_info(xxx)函数上有\`uvm_file和\`uvm_line的传参,它们定义如下:

`define uvm_file `__FILE__
`define uvm_line `__LINE__

4. 在uvm_report_enabled(xxx)函数的中用到uvm_action枚举变量,它的定义为:

// Enum: uvm_action
// Defines all possible values for report actions. Each report is configured
// to execute one or more actions, determined by the bitwise OR of any or all
// of the following enumeration constants.
//   UVM_NO_ACTION - No action is taken
//   UVM_DISPLAY   - Sends the report to the standard output
//   UVM_LOG       - Sends the report to the file(s) for this (severity,id) pair
//   UVM_COUNT     - Counts the number of reports with the COUNT attribute.
//                   When this value reaches max_quit_count, the simulation terminates
//   UVM_EXIT      - Terminates the simulation immediately.
//   UVM_CALL_HOOK - Callback the report hook methods 
//   UVM_STOP      - Causes ~$stop~ to be executed, putting the simulation into
//                   interactive mode.
typedef int uvm_action;
typedef enum
{
  UVM_NO_ACTION = 'b000000,
  UVM_DISPLAY   = 'b000001,
  UVM_LOG       = 'b000010,
  UVM_COUNT     = 'b000100,
  UVM_EXIT      = 'b001000,
  UVM_CALL_HOOK = 'b010000,
  UVM_STOP      = 'b100000
} uvm_action_type;

uvm_report_enabled(VERBOSITY,UVM_INFO,ID)

uvm_report_enabled函数的定义如下:

  // Function: uvm_report_enabled
  // Returns 1 if the configured verbosity for this severity/id is greater than 
  // ~verbosity~ and the action associated with the given ~severity~ and ~id~
  // is not UVM_NO_ACTION, else returns 0.
  // See also <get_report_verbosity_level> and <get_report_action>, and the
  // global version of <uvm_report_enabled>.
 
  function int uvm_report_enabled(int verbosity, 
                          uvm_severity severity=UVM_INFO, string id="");
    if (get_report_verbosity_level(severity, id) < verbosity ||
        get_report_action(severity,id) == uvm_action'(UVM_NO_ACTION)) 
      return 0;
    else 
      return 1;
  endfunction

在uvm_report_enabled(xxx)中,会分析传过来的severity和id的配置verbosity要大于传过来的verbosity,(get_report_verbosity_level(severity, id) < verbosity)。另外也会看传过来的severity和id的配置不是UVM_NO_ACTION,(get_report_action(severity,id) == uvm_action'(UVM_NO_ACTION))。只有上述两者都满足的情况下,才会返回1,也就是允许打印message。

uvm_report_info(ID, MSG, VERBOSITY, uvm_file, uvm_line)

uvm\_report\_info函数的定义如下:

  // Function: uvm_report_info
  virtual function void uvm_report_info( string id,
                                         string message,
                                         int verbosity = UVM_MEDIUM,
                                         string filename = "",
                                         int line = 0);
    m_rh.report(UVM_INFO, get_full_name(), id, message, verbosity,
                filename, line, this);
  endfunction

m_rh是uvm_report_handler class类型的。在1个基于uvm_report_object继承过来的class在new的时候,会自动创建出m_rh。uvm_report_info(xxx)函数调用当前m_rh的report(xxx)函数来打印message。但在m_rh.report(xxx)内部其实是调用uvm_report_server class来打印消息的。uvm_report_server是一个Singleton的class,专门处理report信息。

文章来源:谷公子

推荐阅读

更多IC设计技术干货请关注IC设计技术专栏。
迎添加极术小姐姐微信(id:aijishu20)加入技术交流群,请备注研究方向。
推荐阅读
关注数
19642
内容数
1303
主要交流IC以及SoC设计流程相关的技术和知识
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息