一、概述
一个好的验证系统应该具有消息管理特性,它们是:通过一种标准化的方式打印信息、过滤重要级别信息、打印通道。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_NONE, string filename="", int line=0);
三、消息处理
与每一条消息对应的是如何处理这些消息。通过情况下,消息处理的方式是同消息的严重级别对应的,也可以修改对各个严重级别的消息处理方式。
不同的严重级别消息,可以使用默认的消息处理方式
四、消息宏
如果要做自定义的消息处理方式,可以通过uvm_report_object
类提供的方法进行配置,uvm_report_object
类是间于uvm_object
类与uvm_component
类之间的中间类,它的主要功能是完成消息打印和管理。
UVM也提供了一些宏来对应上面的消息方法,也可以使用这些宏来处理消息
五、消息机制
消息处理是由uvm_report_handler
类来完成的,而每一个uvm_report_object
类中都有一个uvm_report_handler
实例。uvm_report_object消息处理方法或者uvm_component消息处理方法,都是针对于这些uvm_report_handler做出的配置。
六、回调函数
在处理信息时如果想要做出其他的处理,可以调用回调函数。
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)
回调函数示例
class test1 extends uvm_test;
integer f;
`uvm_component_utils(test1)
...
function void build_phase(uvm_phase, phase);
set_report_severity_action(UVM_ERROR, UVM_DISPLAY|UVM_CALL_HOOK); //设置不同严重级别的处理操作
set_report_severity_level(UVM_LOW); //设置过滤消息等级
endfunction
task run_phase(uvm_phase, phase);
uvm_report_info("RUN", "info1", UVM_MEDIUM);
uvm_report_info("RUN", "info2", UVM_LOW);
uvm_report_warning("RUN", "warning1", UVM_LOW);
uvm_report_error("RUN", "error1", UVM_LOW);
uvm_report_error("RUN", "error2", UVM_HIGH);
uvm_report_error("RUN", "error3", UVM_LOW);
endtask
function void report_phase(uvm_phase, phase);
$fclose(f);
endfunction
function bit report_hook(string id, string message, int verbosity, string filename, int line);
uvm_report_info("RPTHOOK", $sformatf("%s : %s", id, message), UVM_LOW);
return 1;
endfunction
function bit report_error_hook(string id, string message, int verbosity, string filename, int line);
uvm_report_info("ERRHOOK", $sformatf("%s : %s", id, message), UVM_LOW);
return 1;
endfunction
endclass
由此可见,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
中产生的消息,这个唯一的uvm_report_server
之所以没有直接暴露在uvm_pkg
中,一个原因在于对消息的处理方式。
---------------------
作者:煎丶包
来源:CSDN
原文:https://blog.csdn.net/qq_39794062/article/details/113924112
版权声明:本文为作者原创文章,转载请附上博文链接!
内容解析By:CSDN,CNBLOG博客文章一键转载插件