(8)UVM 学会消息管理才会让你在验证中游刃有余
(8)UVM 学会消息管理才会让你在验证中游刃有余
UVM 消息管理
文章目录UVM 消息管理一、前言二、消息方法三、消息宏四、消息机制五、回调函数关注作者
一、前言
在一个好的验证系统应该具有消息管理特性,它们是:
通过一种标准化的方式打印信息过滤(重要级别)信息打印通道 这些特性在UVM中均有支持,UVM提供了一系列丰富的类和方法来生成和过滤消息:消
(8)UVM 学会消息管理才会让你在验证中游刃有余
UVM 消息管理
- UVM 消息管理
- 一、前言
- 二、消息方法
- 三、消息宏
- 四、消息机制
- 五、回调函数
- 关注作者
一、前言
在一个好的验证系统应该具有消息管理特性,它们是:
- 通过一种标准化的方式打印信息
- 过滤(重要级别)信息
- 打印通道
这些特性在UVM中均有支持,UVM提供了一系列丰富的类和方法来生成和过滤消息: - 消息方法
- 消息处理
- 消息机制
二、消息方法
- 在UVM环境中或者环,只要有引入uvm_pkg,均可以通过下面的方法来按照消息的严重级别和冗余度来打印消息。
function void uvm_report_info(string id,string message,int verbosity=UVM_MEDIUM,string filename =,int line=0);
function void uvm_report_warning(string id,string message,int verbosity=UVM_MEDIUM,string filename =,int line=0);
function void uvm_report_error(string id,string message,int verbosity=UVM_LOW,string filename =,int line=0);
function void uvm_report_fatal(string id,string message,int verbosity=UVM_OE,string filename =,int line=0);
- 四个消息函数有若干共同的消息,它们是严重级别(severity)、冗余度(verbosity)、消息ID、消息、文件名和行号:
- 严重级别:从函数名本身也可以得出,这四个严重级别分别是UVM_IFO、UVM_WARIG、UVM_ERROR、UVM_FATAL。不同的严重级别在打印的消息中也会有不同的指示来区别,同时仿真器对不同严重级别消息的处理方式也不一样。例如对于UVM_FATAL的消息,默认情况下仿真会停止。
- 消息ID:该ID可以是任意的字符串,用来标记信息。这个标记会同消息本身打印出来,同时不同的标记也可以用来进行消息处理。
- 消息:即消息文本的主题。
- 冗余度:冗余度与消息处理中的过滤直接相关。冗余度的设置如果低于过滤的开关,那么该消息会打印出来,否则不会被打印出来。但是无论消息是否会被打印出来,这都与对消息采取的其它措施没有关系,例如仿真停止。
- 文件名和行号:这些消息用来提供消息发生时所在的文件和行号。用户可以使用默认值,而UVM后台会自动填补它们原本的文件名和行号,同时也在打印时将文件名和行号输出。
- 与每一条消息对应的是如何处理这些消息。通常情况下,消息处理的方式是同消息的严重级别对应的。如果用户有额外的需求,也可以修改对各个严重级别的消息处理方式。
而不同的严重级别消息,用户可以使用默认的消息处理方式
冗余度 | 消息重要程度 |
---|---|
UVM_OE | 表示最重要的消息 |
UVM_LOW | 表示次重要的消息 |
UVM_MEDIUM | 中间的等级 |
UVM_HIGH | 不那么重要 |
UVM_FULL | 依次向下 |
UVM_DEBUG | 依次向下 |
三、消息宏
- 如果要做自定义的消息处理方式,用户可以通过uvm_report_object类提供的方法进行配置。
- uvm_report_object类是间于uvm_object类与uvm_component类之间的中间类,它的主要功能是完成消息打印和管理。
- UVM也提供了一些宏来对应上面的消息方法,用户也可以使用这些宏来处理消息。
package uvm_message_pkg;import uvm_pkg::*;`include uvm_macros.svhclass config_obj extends uvm_object;`uvm_object_utils(config_obj)function new(string name = config_obj);(name);`uvm_info(CREATE, $sformatf(config_obj type [%s] created, name), UVM_LOW)endfunctionendclassclass comp2 extends uvm_component;`uvm_component_utils(comp2)function new(string name = comp2, uvm_component parent = null);(name, parent);`uvm_info(CREATE, $sformatf(unit type [%s] created, name), UVM_LOW)endfunctionfunction void build_phase(uvm_phase phase);super.build_phase(phase);`uvm_info(BUILD, comp2 build phase entered, UVM_LOW)`uvm_info(BUILD, comp2 build phase exited, UVM_LOW)endfunctiontask run_phase(uvm_phase phase);super.run_phase(phase);`uvm_info(RU, comp2 run phase entered, UVM_LOW)`uvm_info(RU, comp2 run phase exited, UVM_LOW)endtaskendclassclass comp1 extends uvm_component;`uvm_component_utils(comp1)function new(string name = comp1, uvm_component parent = null);(name, parent);`uvm_info(CREATE, $sformatf(unit type [%s] created, name), UVM_LOW)endfunctionfunction void build_phase(uvm_phase phase);super.build_phase(phase);`uvm_info(BUILD, comp1 build phase entered, UVM_LOW)`uvm_info(BUILD, comp1 build phase exited, UVM_LOW)endfunctiontask run_phase(uvm_phase phase);super.run_phase(phase);`uvm_info(RU, comp1 run phase entered, UVM_LOW)`uvm_info(RU, comp1 run phase exited, UVM_LOW)endtaskendclassclass uvm_message_test extends uvm_test;config_obj cfg;comp1 c1;comp2 c2;`uvm_component_utils(uvm_message_test)function new(string name = uvm_message_test, uvm_component parent = null);(name, parent);endfunctionfunction void build_phase(uvm_phase phase);super.build_phase(phase);`uvm_info(BUILD, uvm_message_test build phase entered, UVM_LOW)cfg = config_obj::type_id::create(cfg);c1 = comp1::type_id::create(c1, this);c2 = comp2::type_id::create(c2, this);// set_report_id_verbosity_hier(BUILD, UVM_OE);// set_report_id_verbosity_hier(CREATE, UVM_OE);// set_report_id_verbosity_hier(RU, UVM_OE);// uvm_root::get().set_report_id_verbosity_hier(CREATE, UVM_OE);// uvm_root::get().set_report_id_verbosity_hier(BUILD, UVM_OE);// uvm_root::get().set_report_id_verbosity_hier(RU, UVM_OE);`uvm_info(BUILD, uvm_message_test build phase exited, UVM_LOW)endfunctionfunction void end_of_elaboration_phase(uvm_phase phase);//set_report_id_verbosity_hier(BUILD, UVM_OE);//set_report_id_verbosity_hier(CREATE, UVM_OE);//set_report_id_verbosity_hier(RU, UVM_OE);endfunctiontask run_phase(uvm_phase phase);super.run_phase(phase);`uvm_info(RU, uvm_message_test run phase entered, UVM_LOW)phase.raise_objection(this);phase.drop_objection(this);`uvm_info(RU, uvm_message_test run phase exited, UVM_LOW)endtaskendclass
endpackagemodule uvm_message_ref;import uvm_pkg::*;`include uvm_macros.svhimport uvm_message_pkg::*;initial beginuvm_root::get().set_report_id_verbosity_hier(TOPTB, UVM_OE);uvm_root::get().set_report_verbosity_level_hier(UVM_OE);`uvm_info(TOPTB, RU TEST entered, UVM_LOW)run_test(); // empty test name`uvm_info(TOPTB, RU TEST exited, UVM_LOW)endendmodule
其中,set_report_id_verbosity_hier(“ID”, UVM_OE);对某一消息ID的冗余度进行过滤,
set_report_verbosity_level_hier(UVM_OE);对所有类型ID消息的冗余度进行过滤。
四、消息机制
- 消息处理是由uvm_report_handler类来完成的,而每一个uvm_report_object类中都有一个uvm_report_handler实例。
- 上面的uvm_report_object消息处理方法或者uvm_component消息处理方法,都是针对于这些uvm_report_handler做出的配置。
- 除了上面的常见使用方法,用户还可以做出更高级的消息控制。例如,当UVM_ERROR出现之后,仿真默认停止,这是由于设置了UVM_ERROR的处理方法是UVM_COUT数量达到上限(默认为1),即停止仿真。可以通过
set_max_quit_count
来修改UVM_COUT值。
五、回调函数
- 消息用户在处理信息时还希望做出额外的处理,这时回调函数就显得很有必要了,uvm_report_object类提供了下面的回调函数满足用户更多的需求:
function bit report_hook(string id,string message,int verbosity,string filename,int line);
function bit report_info_hook(string id,string message,int verbosity,string filename,int line);
function bit report_warning_hook(string id,string message,int verbosity,string filename,int line);
function bit report_error_hook(string id,string message,int verbosity,string filename,int line);
function bit report_fatal_hook(string id,string message,int verbosity,string filename,int line);
- report_hook()函数通过结合消息管理时的UVM_CALL_HOOK参数,结合用户自定义的回调函数,就可以实现更丰富的配置。
- 这样用户在调用回调函数时,首先会调用report_hook()函数,接下来才按照severity级别来选择更细致的回调函数report_SEVERITY_hook()。
- 默认情况下,report_hook()函数返回值为1,进而再转入severity hook函数。
- 如果report_hook()函数由用户自定义且返回0的话,那么后续report_SEVERITY_hook()函数不会执行。
- 除了每一个uvm_report_object中都内置一个uvm_report_handler实例之外,所有的uvm_report_handler实例也都依赖于uvm_pkg中uvm_report_server的唯一实例,但是该实例并没有作为全局变量,直接暴露给用户,需要用户自行调用uvm_report_server::get_server()方法来获取。
- uvm_report_server是一个全局的消息处理设备,用来处理从所有uvm_report_handler中产生的消息。这个唯一的report server之所有没有暴露在uvm_pkg中供用户使用,一个原因在于对消息的处理方式。
-
关注作者
- 自述
作者是一位中科大数字设计专业的研究生,水平有限,如有错误,请大家指正,想要与大家一同进步。 - 经历
曾获得国家奖学金,“高教社杯”数学建模国家二等奖等 - 陆续更新:
1.与UVM验证相关的system verilog后续内容;
2.与verilog数字设计相关的一些基础模块设计,例如FIFO,UART,I2C等的书写。
.保研与竞赛经历等
欢迎大家关注“数字IC小白的日常修炼”,期待与大家一同仗剑遨游数字IC世界。
#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格
上传时间: 2024-02-10 07:40:16
推荐阅读
留言与评论(共有 14 条评论) |
本站网友 ip地址更改器 | 6分钟前 发表 |
get_server()方法来获取 | |
本站网友 邢台酒店 | 14分钟前 发表 |
comp2 build phase exited | |
本站网友 最终进化少年 | 6分钟前 发表 |
UVM_OE);endfunctiontask run_phase(uvm_phase phase);super.run_phase(phase);`uvm_info(RU | |
本站网友 东区二手房 | 25分钟前 发表 |
UVM_OE);// set_report_id_verbosity_hier(CREATE | |
本站网友 路星河 | 11分钟前 发表 |
string message | |
本站网友 南通二手房信息 | 18分钟前 发表 |
消息机制五 | |
本站网友 伯恩 | 10分钟前 发表 |
string message | |
本站网友 口腔医学杂志 | 7分钟前 发表 |
int verbosity=UVM_MEDIUM | |
本站网友 西安婚纱照 | 24分钟前 发表 |
本站网友 山东原副省长黄胜 | 23分钟前 发表 |
UVM_OE);uvm_root | |
本站网友 四海一家自助餐团购 | 24分钟前 发表 |
UVM_LOW)endendmodule 其中,set_report_id_verbosity_hier(“ID” | |
本站网友 深圳市二手房 | 24分钟前 发表 |
本站网友 metlife大都会 | 25分钟前 发表 |