当前位置: 首页 > news >正文

谈谈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__

`uvm_file和`uvm_line分别用于显示文件和行,这样在打印信息时方便debug。当然,也可以在command line上定义UVM_REPORT_DISABLE_FILE_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_infovirtual 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信息。

http://www.lryc.cn/news/30850.html

相关文章:

  • 矩阵理论1 集合上的等价关系(equivalence relations on a set S)
  • 【网络监控】Zabbix详细安装部署(最全)
  • 阿里云轻量服务器--Docker--Nacos安装(使用外部Mysql数据存储)
  • unity开发知识点小结01
  • 软件系统[软件工程]
  • 电力系统稳定性的定义与分类
  • 基于java的俱乐部会员管理系统
  • 线程池执行父子任务,导致线程死锁
  • Ubuntu系统新硬盘挂载
  • 【亲测】Centos7系统非管理(root)权限编译NCNN
  • 四种常见的异步请求方式
  • Linux操作系统学习(进程间通信)
  • 单目标追踪——【相关滤波】C-COT原理与ECO基于C-COT的改进
  • C++中栈是如何实现,以及常用的栈函数都有哪些
  • 我就不信你还不懂HashSet/HashMap的底层原理
  • Qt中调用gtest进行单元测试及生成覆盖率报告
  • ChatGPT vs Bard 背后的技术对比分析和未来发展趋势
  • 搜索引擎的设计与实现
  • 动态规划之买卖股票问题
  • MySQL学习笔记之子查询
  • HCIP-5OSPF域内域间外部路由学习笔记
  • 【编程实践】简单是好软件的关键:Simplicity is key to good software
  • Python|贪心|数组|二分查找|贪心|数学|树|二叉搜索树|在排序数组中查找元素的第一个和最后一个位置|计数质数 |将有序数组转换为二叉搜索树
  • 操作系统——15.FCFS、SJF、HRRN调度算法
  • 如何防止用户打开浏览器开发者工具?
  • C语言-基础了解-12-C数组
  • RocksDB 架构
  • MVVM和MVC的区别
  • c++11 标准模板(STL)(std::unordered_map)(三)
  • OpenGL环境配置