Reporting 類提供了一組工具用於格式化報告輸出
report機制大概包括四個主要的類uvm_report_object,uvm_report_handler, uvm_report_server,uvm_report_catcher,UVM reporting主要的接口是uvm_report_object(這是一個接口類),這是uvm_components的父類。
uvm_report_object經過
內部的function調用
uvm_report_handler的function來執行大部分的工做。
uvm_report_handler存儲了對消息的顯示和處理的一些配置信息,他對消息的處理進行決策,並對消息進行一些格式化,過濾等。最終消息被將被uvm_report_handler送到uvm_report_server。而uvm_report_catcher實際上就是一個uvm_report_cb,他對特定的uvm_report_object發出的消息進行抓取。
下圖是reporting類的繼承關係:
1. 經過此接口,組件發起發生在仿真過程當中的各類message。 Users can configure what actions are taken and what file(s) are output for individual messages from a particular component or for all messages from all components in the environment
2.
uvm_report_object
大多數方法
委派給
uvm_report_handler一個內部實例, 在uvm_report_handler中存儲報告應該顯示配置,而後根據配置決定是否發佈消息,若是決定發佈消息,uvm_report_handler將這個工做委派給uvm_report_server。
3.
一個uvm的report由下列部分組成id string, severity, verbosity level, and the textual,filename and line number;若是消息的verbosity level超過了一個report被配置的最大verbosity level那麼這個消息將被過濾掉。若是消息經過了過濾,那麼之後的行爲都是肯定的,若是被配置爲輸出到一個文件,那麼該消息最後將被輸出的該文件中
4.
report的actions定義了對各個級別的消息採起的行動,該行動針對severity or id,或者(severity, id)對。可採起的行動包括顯示,推出,計數,UVM_DISPLAY | UVM_COUNT|UVM_EXIT,可使用 set_*_action替換這些action
5. default actions:
UVM_INFO - UVM_DISPLAY
UVM_WARNING - UVM_DISPLAY
UVM_ERROR - UVM_DISPLAY | UVM_COUNT
UVM_FATAL - UVM_DISPLAY | UVM_EXIT
6. 文件描述符,能夠設定默認的文件描述符,經過severity, id, (severity, id)設定文件描述符。這些文件描述符必須使用者本身負責進行開關維護
7. 默認的文件句柄是0,即標準輸出默認的文件句柄能夠經過set_*_file來改寫
8. uvm_report_object的第一個對象是uvm_report_handler m_rh該句柄在new函數中實例化,uvm_report_object的因此消息都委派給handler處理
Reporting Function:
6. virtual function void uvm_report_info( string id,
string message,
int verbosity = UVM_MEDIUM,
string filename = "",
int line = 0);
該函數直接調用m_rh.report函數,沒有過多內容。函數中的參數在1中也作了解釋
m_rh.report(UVM_INFO, get_full_name(), id, message, verbosity,
filename, line, this);
7. virtual function void uvm_report_warning( string id,
string message,
int verbosity = UVM_MEDIUM,
string filename = "",
int line = 0);
該函數直接調用m_rh.report函數,沒有過多內容。函數中的參數在1中也作了解釋
8. virtual function void uvm_report_error( string id,
string message,
int verbosity = UVM_LOW,
string filename = "",
int line = 0);
該函數直接調用m_rh.report函數,沒有過多內容。函數中的參數在1中也作了解釋
9. virtual function void uvm_report_fatal( string id,
string message,
int verbosity = UVM_NONE,
string filename = "",
int line = 0);
函數直接調用m_rh.report函數,沒有過多內容。函數中的參數在1中也作了解釋
NOTE
id a unique id for the report or report group that can be used for identification and therefore targeted filtering. You can configure an individual report’s actions and output file(s) using this id string.
message the message body, preformatted if necessary to a single string.
verbosity the verbosity of the message, indicating its relative importance. If this number is less than or equal to the effective verbosity level, see set_report_verbosity_level, then the report is issued, subject to the configured action and file descriptor settings. Verbosity is ignored for warnings, errors, and fatals. However, if a warning, error or fatal is demoted to an info message using the uvm_report_catcher, then the verbosity is taken into account.
filename/line (Optional) The location from which the report was issued. Use the predefined macros, `__FILE__ and `__LINE__. If specified, it is displayed in the output.
Callbacks Function:
virtual function bit report_info_hook(
string id, string message, int verbosity, string filename, int line);
virtual function bit report_error_hook(
string id, string message, int verbosity, string filename, int line);
virtual function bit report_warning_hook(
string id, string message, int verbosity, string filename, int line);
virtual function bit report_fatal_hook(
string id, string message, int verbosity, string filename, int line);
virtual function bit report_hook(
string id, string message, int verbosity, string filename, int line);//一個總的hook
1. These hook methods can be defined in derived classes to perform additional actions when reports are issued. They are called only if the UVM_CALL_HOOK bit is specified in the action associated with the report. The default implementations return 1, which allows the report to be processed. If an override returns 0, then the report is not processed.
virtual function void report_header(UVM_FILE file = 0);//打印 version and copyright information,若是file!=0就打印到對應文件。調用m_rh.report_header(file)
virtual function void report_summarize(UVM_FILE file = 0);//打印統計信息,調用m_rh.summarize(file);
virtual function void die();//該函數被report_server調用,若是知足退出條件或者須要採起退出的行動。若是是在component中,那麼將只把本仿真phase結束,若是不是component,那麼仿真將直接介紹,並嗲用12中的函數顯示總結信息
Configuration function:
16. function void set_report_id_action (string id, uvm_action action);
function void set_report_severity_action (uvm_severity severity,
uvm_action action);
function void set_report_severity_id_action (uvm_severity severity,
string id, uvm_action action);
//對給定的id, severity 或者(id, severity)對設置ACTIONS,在2中介紹,都是調用handler中對應的函數來實現
17. function void set_report_severity_override(uvm_severity cur_severity,
uvm_severity new_severity);//改寫14中的設定,調用handler對應函數實現
18. function void set_report_severity_id_override(uvm_severity cur_severity,
string id,
uvm_severity new_severity); //改寫(severity,id)對的severity值,調用handler內函數實現
19.function void set_report_default_file ( UVM_FILE file);//設置默認的輸出文件,調用handler相應函數實現
20.function void set_report_severity_file (uvm_severity severity, UVM_FILE file););//設置默認的severity級別的消息的輸出文件,調用handler相應函數實現
21.function void set_report_id_file (string id, UVM_FILE file);););//設置默認的ID級別的消息的輸出文件,調用handler相應函數實現
22. function void set_report_severity_id_file (uvm_severity severity, string id,
UVM_FILE file););););//設置默認的(ID,severity)級別的消息的輸出文件,調用handler相應函數實現
23. function int get_report_verbosity_level(uvm_severity severity=UVM_INFO, string id="");//返回(ID,severity)的verbosity值,調用handler對應的函數實現
24.function int get_report_action(uvm_severity severity, string id);//返回(ID,severity)的action值,調用handler對應的函數實現
25.function int get_report_file_handle(uvm_severity severity, string id);//返回(ID,severity)的report file值,調用handler對應的函數實現
26. function int uvm_report_enabled(int verbosity,
uvm_severity severity=UVM_INFO, string id="");//測試(ID,severity)對,若是他們對應的verbosity比report的verbosity低,或者對應的action=UVM_NO_ACTION那麼返回失敗,不然返回1
27. function void set_report_max_quit_count(int max_count);//若是UVM_COUNT actions達到max_count,將調用die;調用handler的函數實現
Setup Function:
28.function void set_report_handler(uvm_report_handler handler);//m_rh = handler;
29.function uvm_report_handler get_report_handler();// return m_rh;
30.function void reset_report_handler;// m_rh.initialize;讓m_rh達到初始狀態
31.function uvm_report_server get_report_server();//return m_rh.get_server();
32.function void dump_report_state();//m_rh.dump_state();對handler的內部狀態進行一個報告
33.function int uvm_get_max_verbosity();// return m_rh.m_max_verbosity_level;
34.protected virtual function uvm_report_object m_get_report_object();//return this;
uvm_report_handler:
uvm_report_handler是report_object的代理,許多對消息的配置信息和處理函數都在這個類裏邊實現。report—object和report_handler的關係是一 一對應的,固然也能夠多個report_object對應一個report_handler(set_report_handler).handler到server的關係是多對一
1. uvm_report_handler 保存verbosity,actions,以及file這些能夠影響報告處理方式的變量。
2. report handler並不能直接使用,
3. 這個類裏面的屬性:
int m_max_verbosity_level;//記錄report_object的允許verbosity,超過這個值的將被過濾掉
uvm_action severity_actions[uvm_severity];//每一個severity對應的action如顯示,丟掉,計數等
uvm_id_actions_array id_actions;//每一個id對應的action,是一個uvm_pool
1. 能夠精細化控制每一個ID的action
uvm_id_actions_array severity_id_actions[uvm_severity];//每一個(id,severity)對應一個action
uvm_id_verbosities_array id_verbosities;//每一個id對應一個verbosity
修改某些ID 的verbosity,關閉這些ID的打印
uvm_id_verbosities_array severity_id_verbosities[uvm_severity];//每一個(id,severity)對應一個verbosity
uvm_sev_override_array sev_overrides;//記錄每一個severity被改寫的狀況
uvm_sev_override_array sev_id_overrides [string];//每一個(id,severity)的severity被改寫的狀況
UVM_FILE default_file_handle;
UVM_FILE severity_file_handles[uvm_severity];//每一個severity對應的輸出文件
uvm_id_file_array id_file_handles=new;//每一個id對應的輸出文件
uvm_id_file_array severity_id_file_handles[uvm_severity];//每一個(id,severity)的輸出文件
4. 主要的方法函數:
1. function new();//實例化類中的東西並調用initialize建立類實例
set_default_file(0)
m_max_verbosity_level=UVM_MEDIUM
function void set_defaults();
set_severity_action(UVM_INFO, UVM_DISPLAY);
set_severity_action(UVM_WARNING, UVM_DISPLAY);
set_severity_action(UVM_ERROR, UVM_DISPLAY | UVM_COUNT);
set_severity_action(UVM_FATAL, UVM_DISPLAY | UVM_EXIT);
set_severity_file(UVM_INFO, default_file_handle);
set_severity_file(UVM_WARNING, default_file_handle);
set_severity_file(UVM_ERROR, default_file_handle);
set_severity_file(UVM_FATAL, default_file_handle);
endfunction
2.
virtual function bit run_hooks(uvm_report_object client,
uvm_severity severity,
string id,
string message,
int verbosity,
string filename,
int line);//運行report中的相應hooks
1. The run_hooks method is called if the UVM_CALL_HOOK action is set for a report. It first calls the
client’s uvm_report_object::report_hook method, followed by the appropriate severity-specific hook method. If either returns 0, then the report is not processed.
2. 這個run_hooks在uvm_servers中進行調用,本function裏面調用的report_info_hook在client的uvm_report_object中進行聲明。
3. function int get_verbosity_level(uvm_severity severity=UVM_INFO, string id="" );//返回verbosity,返回的順序和9中的同樣
4. function uvm_action get_action(uvm_severity severity, string id);//返回action,返回的順序和9中同樣
5. function UVM_FILE get_file_handle(uvm_severity severity, string id);//返回文件句柄,返回的順序和9中的同樣
6.
virtual function void report(
uvm_severity severity,
string name,
string id,
string message,
int verbosity_level,
string filename,
int line,
uvm_report_object client
);//report_object中就是調用這個方法來report_warning/error/fatal/info的,先是查找對應的severity被覆蓋狀況,而後調用server
主要的工做:
1.
uvm_report_server srvr;
srvr = uvm_report_server::get_server(); 拿到srvr句柄
2. 判斷傳入的client是否爲NULL,爲NULL則指向uvm_top
3.
Check for severity overrides and apply them before calling the server.
An id specific override has precedence over a generic severity override
4. 調用srvr的report function
其餘函數做爲uvm_report_handler的服務函數:
1. function uvm_report_server get_server();獲取server的singleton
2. function void set_max_quit_count(int max_count);//把max_count設置到server中
3. function void summarize(UVM_FILE file = 0);//調用server的summarize進行報告
4. function void report_header(UVM_FILE file = 0);//調用server的f_display顯示一些版本信息等
5.function void initialize();//設置一些輸出文件,及一些默認的配置,變量等
6. local function UVM_FILE get_severity_id_file(uvm_severity severity, string id);//返回一個文件句柄,先返回(severity, id)對中的,而後是id相關的,最後是severity相關的,最後是默認的,這樣的返回順序
7
. function void set_verbosity_level(int verbosity_level);設置m_max_verbosity_level
8.
srvr.report(severity,name,id,message,verbosity_level,filename,line,client);進行顯示
9. function string format_action(uvm_action action);//把action的枚舉類型名改成字符串
10. function void set_severity_action(input uvm_severity severity,
input uvm_action action);//爲severity設定action
11. function void set_id_action(input string id, input uvm_action action);//爲id設定action
12. function void set_severity_id_action(uvm_severity severity,
string id,
uvm_action action);//爲severity和id對設定action
13.function void set_id_verbosity(input string id, input int verbosity);//爲id設定verbosity
14. function void set_severity_id_verbosity(uvm_severity severity,
string id,
int verbosity);//爲(severity,id)對設定action
15. function void set_default_file (UVM_FILE file);//設置默認輸出文件
16.function void set_severity_file (uvm_severity severity, UVM_FILE file);//爲severity設置輸出文件
17. function void set_id_file (string id, UVM_FILE file);//爲id設置輸出文件
18. function void set_severity_id_file(uvm_severity severity,
string id, UVM_FILE file);//爲(severity,id)對設置輸出文件
19. function void set_severity_override(uvm_severity cur_severity,
uvm_severity new_severity);//爲severity設置覆蓋的severity
20. function void set_severity_id_override(uvm_severity cur_severity,
string id,
uvm_severity new_severity);//爲(severity,id)對設置覆蓋的severity
21.
function void dump_state();//調用server的f_display方法對handler中的狀態信息,內容進行顯示
uvm_report_server:
1. uvm_report_server是全局的server處理全部的由uvm_report_handler產生出來的reports。uvm_report_server的code都不會被normal的testbench調用,雖然在一些環境中,process_report 和compose_uvm_info會被子類重載。
變量:
local int max_quit_count;
local int quit_count;
local int severity_count[uvm_severity];
protected int id_count[string];//
bit enable_report_id_count_summary=1;
方法:
new
1. Creates the central report server, if not already created.
static function void set_server(uvm_report_server server);
1. Sets the global report server to use for reporting.
2. m_global_report_server = server;
get_server
1. Gets the global report server. 返回當前report server的一個valid handle
2. 返回m_global_report_server
process_report Calls compose_message to construct the actual message to be output.
compose_message
1. Constructs the actual string sent to the file or command line from the severity, component name, report id, and the message itself.
2. 能夠重寫compose_message對打印的log進行重寫
一些服務函數:
set_max_quit_count
get_max_quit_count Get or set the maximum number of COUNT actions that can be tolerated before an UVM_EXIT action is taken.
set_quit_count
get_quit_count
incr_quit_count
reset_quit_count Set, get, increment, or reset to 0 the quit count, i.e., the number of COUNT actions issued.
is_quit_count_reached If is_quit_count_reached returns 1, then the quit counter has reached the maximum.
set_severity_count
get_severity_count
incr_severity_count
reset_severity_counts Set, get, or increment the counter for the given severity, or reset all severity counters to 0.
set_id_count
get_id_count
incr_id_count Set, get, or increment the counter for reports with the given id.
summarize See uvm_report_object::report_summarize method.
dump_server_state Dumps server state information.
get_server Returns a handle to the central report server.
uvm_report_catcher://這是一個uvm_report_object的一個callback類,
1. 用於捕獲uvm_report_server發起的message,
2. Catchers are uvm_callbacks#(uvm_report_object,uvm_report_catcher) objects, so all factilities in the uvm_callback and uvm_callbacks#(T,CB) classes are available for registering catchers and controlling catcher state.
3. The uvm_callbacks#(uvm_report_object,uvm_report_catcher) class is aliased to uvm_report_cb to make it easier to use. Multiple report catchers can be registered with a report object.
4. The catchers can be registered as default catchers which catch all reports on all uvm_report_object reporters, or catchers can be attached to specific report objects
5. User extensions of uvm_report_catcher must implement the catch method in which the action to be taken on catching the report is specified.
6. The catch method can return CAUGHT, in which case further processing of the report is immediately stopped, or return THROW in which case the (possibly modified) report is passed on to other registered catchers. The catchers are processed in the order in which they are registered.
7. On catching a report, the catch method can modify the severity, id, action, verbosity or the report string itself before the report is finally issued by the report server. The report can be immediately issued from within the catcher class by calling the issue method.
對cacher的主要的用法以下:本例的目的是爲了將MY_ID的error_report改成uvm_info
class my_error_demoter extends uvm_report_catcher;
function new(string name="my_error_demoter");
super.new(name);
endfunction
//This example demotes "MY_ID" errors to an info message
function action_e catch();
if(get_severity() == UVM_ERROR && get_id() == "MY_ID")
set_severity(UVM_INFO);
return THROW;
endfunction
endclass
my_error_demoter demoter = new;
initial begin
// Catchers are callbacks on report objects (components are report
// objects, so catchers can be attached to components).
// To affect all reporters, use null for the object
uvm_report_cb::add(null, demoter);
// To affect some specific object use the specific reporter
uvm_report_cb::add(mytest.myenv.myagent.mydriver, demoter);
// To affect some set of components using the component name
uvm_report_cb::add_by_name("*.*driver", demoter);
end
具體的實現將會在uvm_callback中進行介紹。