uvm report机制

资料来源

(1) 《Practical UVM Step by Step with IEEE》

1.uvm_report_object & uvm_report_handler & uvm_report_server简介

1.1 uvm_report_object

 1 class uvm_report_object extends uvm_object;
 2 
 3   uvm_report_handler m_rh;
 4 
 5   // Function: new
 6   //
 7   // Creates a new report object with the given name. This method also creates
 8   // a new <uvm_report_handler> object to which most tasks are delegated.
 9 
10   function new(string name = "");
11     super.new(name);
12     m_rh = uvm_report_handler::type_id::create(name);
13   endfunction
14 
15   ...
16 endclass

(1) uvm_report_object把信息传递给uvm_report_handler,uvm_report_handler查看信息,并且看是否需要进一步处理; 之后,uvm_report_handler将信息传递给global_report_server;

(2) uvm_report_handler包含信息怎么被处理的配置以及信息生成过程中会采取的措施;

1.2 uvm_report_handler

1.3 uvm_report_server & uvm_default_report_server

 1 virtual class uvm_report_server extends uvm_object;
 2         function string get_type_name();
 3                 return "uvm_report_server";
 4         endfunction
 5         function new(string name="base");
 6                 super.new(name);
 7         endfunction
 8         ...
 9 
10         static function uvm_report_server get_server();
11             uvm_coreservice_t cs = uvm_coreservice_t::get();
12                 return cs.get_report_server();
13         endfunction
14 endclass
 1 class uvm_default_report_server extends uvm_report_server;
 2 
 3   local int m_quit_count;
 4   local int m_max_quit_count;
 5   bit max_quit_overridable = 1;
 6   local int m_severity_count[uvm_severity];
 7   protected int m_id_count[string];
 8   protected uvm_tr_database m_message_db;
 9   protected uvm_tr_stream m_streams[string][string]; // ro.name,rh.name
10 
11   bit enable_report_id_count_summary=1;
12   bit record_all_messages = 0;
13   bit show_verbosity = 0;
14   bit show_terminator = 0;
15 
16   function string get_type_name();
17     return "uvm_default_report_server";
18   endfunction
19 
20   function new(string name = "uvm_report_server");
21     super.new(name);
22     set_max_quit_count(0);
23     reset_quit_count();
24     reset_severity_counts();
25   endfunction
26 
27   ...
28 endclass

2.uvm report的元素 & uvm_report_message

2.1 uvm_report的元素

1 UVM_INFO ../../common/wb_master.sv(163) @395000: uvm_test_top.env.master_agent[00].mast_drv[wb_env_DRIVER] Starting transaction...

(1) serverity:表明信息对于仿真而言的重要性,包括UVM_INFO, UVM_WARNING, UVM_ERROR, UVM_FATAL;

(2) source:表明发出report的文件位置,主要借助于宏`__FILE__与`__LINE__;

(3) time;

(4) component:表明发出report的component instance;

(5) ID;

(6) message;

(7) verbosity:UVM_NONE, UVM_LOW, UVM_MEDIUM, UVM_HIGH, UVM_FULL, UVM_DEBUG;

注1:为了避免bug因为冗余度设置而被隐藏,WARNINGS,ERROR以及FATAL信息会忽略任何的冗余度设置,并且会被打印出来,除非report_handler或tb内设置了UVM_NO_ACTION;

注2:如果通过采用uvm_report_catcher将warning, error, fatal降级为uvm_info,就需要考虑冗余度;

(8) handling:UVM_NO_ACTION, UVM_DISPLAY, UVM_LOG, UVM_COUNT, UVM_EXIT, UVM_STOP;

1 //示例
2 UVM_INFO         UVM_DISPLAY
3 UVM_WARNING      UVM_DISPLAY
4 UVM_ERROR        UVM_DISPLAY|UVM_COUNT
5 UVM_FATAL        UVM_DISPLAY|UVM_EXIT

注1:UVM_COUNT action有特殊的行为;如果设置了UVM_COUNT,report_server里面会维持一个counter,一旦counter数到了max_quit_count,会调用die函数结束仿真(本质上调用的是$finish);

注2:UVM_EXIT action也会导致die函数调用;

2.2 uvm_report_message

 1 class uvm_report_message extends uvm_object;
 2 
 3   protected uvm_report_object _report_object;
 4   protected uvm_report_handler _report_handler;
 5   protected uvm_report_server _report_server;
 6 
 7   protected uvm_severity _severity; 
 8   protected string _id;
 9   protected string _message;
10   protected int _verbosity;
11   protected string _filename;
12   protected int _line;
13   protected string _context_name;
14   protected uvm_action _action; 
15   protected UVM_FILE _file;
16 
17   // Not documented.
18   protected uvm_report_message_element_container _report_message_element_container;
19 
20   ...
21 endclass

3.生成message的方法或宏

3.1 uvm_component/uvm_report_object提供的方法

 1   virtual function void uvm_report_info( string id,
 2                      string message,
 3                      int verbosity = UVM_MEDIUM,
 4                      string filename = "",
 5                      int line = 0,
 6                      string context_name = "",
 7                      bit report_enabled_checked = 0);
 8 
 9     uvm_report (UVM_INFO, id, message, verbosity, 
10                 filename, line, context_name, report_enabled_checked);
11   endfunction
12 
13   virtual function void uvm_report_warning( string id,
14                         string message,
15                         int verbosity = UVM_MEDIUM,
16                         string filename = "",
17                         int line = 0,
18                         string context_name = "",
19                         bit report_enabled_checked = 0);
20 
21     uvm_report (UVM_WARNING, id, message, verbosity,
22                 filename, line, context_name, report_enabled_checked);
23   endfunction
24 
25   virtual function void uvm_report_error( string id,
26                       string message,
27                       int verbosity = UVM_LOW,
28                       string filename = "",
29                       int line = 0,
30                       string context_name = "",
31                       bit report_enabled_checked = 0);
32 
33     uvm_report (UVM_ERROR, id, message, verbosity,
34                 filename, line, context_name, report_enabled_checked);
35   endfunction
36 
37   virtual function void uvm_report_fatal( string id,
38                       string message,
39                       int verbosity = UVM_NONE,
40                       string filename = "",
41                       int line = 0,
42                       string context_name = "",
43                       bit report_enabled_checked = 0);
44 
45     uvm_report (UVM_FATAL, id, message, verbosity,
46                 filename, line, context_name, report_enabled_checked);
47   endfunction

3.2 uvm_global.svh

 1 function void uvm_report_info(string id,
 2                   string message,
 3                               int verbosity = UVM_MEDIUM,
 4                   string filename = "",
 5                   int line = 0,
 6                               string context_name = "",
 7                               bit report_enabled_checked = 0);
 8   uvm_root top;
 9   uvm_coreservice_t cs;
10   cs = uvm_coreservice_t::get();
11   top = cs.get_root();
12   top.uvm_report_info(id, message, verbosity, filename, line, context_name,
13     report_enabled_checked);
14 endfunction
15 
16 function void uvm_report_warning(string id,
17                                  string message,
18                                  int verbosity = UVM_MEDIUM,
19                  string filename = "",
20                  int line = 0,
21                                  string context_name = "",
22                                  bit report_enabled_checked = 0);
23   uvm_root top;
24   uvm_coreservice_t cs;
25   cs = uvm_coreservice_t::get();
26   top = cs.get_root();
27   top.uvm_report_warning(id, message, verbosity, filename, line, context_name,
28     report_enabled_checked);
29 endfunction
30 
31 function void uvm_report_error(string id,
32                                string message,
33                                int verbosity = UVM_LOW,
34                    string filename = "",
35                    int line = 0,
36                                string context_name = "",
37                                bit report_enabled_checked = 0);
38   uvm_root top;
39   uvm_coreservice_t cs;
40   cs = uvm_coreservice_t::get();
41   top = cs.get_root();
42   top.uvm_report_error(id, message, verbosity, filename, line, context_name,
43     report_enabled_checked);
44 endfunction
45 
46 function void uvm_report_fatal(string id,
47                            string message,
48                                int verbosity = UVM_NONE,
49                    string filename = "",
50                    int line = 0,
51                                string context_name = "",
52                                bit report_enabled_checked = 0);
53   uvm_root top;
54   uvm_coreservice_t cs;
55   cs = uvm_coreservice_t::get();
56   top = cs.get_root();
57   top.uvm_report_fatal(id, message, verbosity, filename, line, context_name,
58     report_enabled_checked);
59 endfunction 

3.3 宏

`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, "", 1); \
   end

`define uvm_warning(ID, MSG) \
   begin \
     if (uvm_report_enabled(UVM_NONE,UVM_WARNING,ID)) \
       uvm_report_warning (ID, MSG, UVM_NONE, `uvm_file, `uvm_line, "", 1); \
   end

`define uvm_error(ID, MSG) \
   begin \
     if (uvm_report_enabled(UVM_NONE,UVM_ERROR,ID)) \
       uvm_report_error (ID, MSG, UVM_NONE, `uvm_file, `uvm_line, "", 1); \
   end

`define uvm_fatal(ID, MSG) \
   begin \
     if (uvm_report_enabled(UVM_NONE,UVM_FATAL,ID)) \
       uvm_report_fatal (ID, MSG, UVM_NONE, `uvm_file, `uvm_line, "", 1); \
   end

4.打印信息的控制

4.1 命令行控制打印信息

1 +uvm_set_verbosity=<comp>,<id>,<verbosity>,<phase>
2 +uvm_set_verbosity=<comp>,<id>,<verbosity>,time,<time>
3 
4 +uvm_set_action=<comp>,<id>,<severity>,<action>
5 //+uvm_set_action=uvm_test_top.env.*,_ALL_,UVM_ERROR,UVM_NO_ACTION
6 
7 +uvm_set_severity=<comp>,<id>,<current_severity>,<new_severity>
8 //+uvm_set_severity=uvm_test_top.*,BAD_CRC,UVM_ERROR,UVM_WARNING
1 //示例1
2 ./simv -l uvm_set_inst_verbosity.data +uvm_set_verbosity=uvm_test_top.env.master_agent\[00\].mast_drv,_ALL_,UVM_DEBUG,run +UVM_TESTNAME=wb_conmax_flat_seq_test

4.2 采用UVM_FILE把打印信息导入到指定文件中

注1:有专门一篇文章讲解UVM_FILE的使用;

4.3 采用uvm_report_catcher对report信息降级(本质是callback)

注1:有专门文章讲解uvm_report_catcher的使用;

4.4 在assertion或module中使用uvm report机制

 1 import uvm_pkg::*;
 2 `include "uvm_macros.svh"
 3 
 4 property p_rd_reset;
 5     (!rst_n |=> data_out==8'd0);
 6 endproperty
 7 
 8 a_p_reset: assert property (p_rd_reset)
 9                      else `uvm_error("SVA","data_out is not 0 after reset")
10 
11 property p_wr_rd_val:
12     (wr_rd |-> wr_rd_valid);
13 endproperty
14 
15 a_p_wr_rd_val: assert property (p_wr_rd_val)
16                              else `uvm_error("SVA", "Protocl violation! wr_rd is set HIGH without valid")

 

posted on 2022-05-21 22:34  知北游。。  阅读(639)  评论(0编辑  收藏  举报

导航