[CU]UVM_FILE的使用

资料来源

(1)《UVM实战-张强》;

(2) Verilog系列:【3】文件的IO操作 (qq.com)

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

1.UVM_FILE的使用及示例

typedef int UVM_FILE;

(1)在uvm_test_base中,声明UVM_FILE file_name;

(2)在uvm_test_base的connect_phase中,使用$fopen打开文件,并调用uvm函数set_report_severity_file_hier等函数,将信息根据冗余度输入到专门的文件中;

(3)在uvm_test_base的final_phase中,使用$fclose关闭文件;

注1:文件被保存在仿真路径下(怎么指定log路径?);

 1 //class uvm_component
 2 function void uvm_component::set_report_severity_file_hier( uvm_severity severity,
 3                                                             UVM_FILE file);
 4   set_report_severity_file(severity, file);
 5   foreach( m_children[c] )
 6     m_children[c].set_report_severity_file_hier(severity, file);
 7 endfunction
 8 
 9 
10 //UVM_FILE使用示例1
11 UVM_FILE info_log;
12 UVM_FILE warning_log;
13 UVM_FILE error_log;
14 UVM_FILE fatal_log;
15 
16 virtual function void connect_phase(uvm_phase phase);
17     info_log   =$fopen("info.log","w");
18     warning_log=$fopen("warning.log","w");
19     error_log  =$fopen("error.log","w");
20     fatal_log  =$fopen("fatal.log","w");
21     env.i_agt.set_report_severity_file_hier(UVM_INFO,    info_log);
22     env.i_agt.set_report_severity_file_hier(UVM_WARNING, warning_log);
23     env.i_agt.set_report_severity_file_hier(UVM_ERROR,   error_log);
24     env.i_agt.set_report_severity_file_hier(UVM_FATAL,   fatal_log);
25     env.i_agt.set_report_severity_action(UVM_INFO,    UVM_DISPLAY|UVM_LOG);
26     env.i_agt.set_report_severity_action(UVM_WARNING, UVM_DISPLAY|UVM_LOG);
27     env.i_agt.set_report_severity_action(UVM_ERROR,   UVM_DISPLAY|UVM_COUNT|UVM_LOG);
28     env.i_agt.set_report_severity_action(UVM_FATAL,   UVM_DISPLAY|UVM_EXIT|UVM_LOG);
29     ...
30 endfunction
 1 //UVM_FILE使用示例2
 2 UVM_FILE driver_log;
 3 UVM_FILE drv_log;
 4 
 5 virtual function void connect_phase(uvm_phase phase);
 6     driver_log =$fopen("driver.log","w");
 7     drv_log    =$fopen("drv.log","w");
 8 
 9     env.i_agt.drv.set_report_id_file_hier("my_driver",    driver_log);
10     env.i_agt.drv.set_report_id_file_hier("my_drv",       drv_log);
11     env.i_agt.drv.set_report_id_action("my_driver",    UVM_DISPLAY|UVM_LOG);
12     env.i_agt.drv.set_report_id_action("my_drv",       UVM_DISPLAY|UVM_LOG);
13     ...
14 endfunction
15 
16 virtual function void final_phase(uvm_phase phase);
17     $fclose(driver_log);
18     $fclose(drv_log);
19 endfunction
 1 //class uvm_component
 2 function void uvm_component::set_report_default_file_hier( UVM_FILE file);
 3   set_report_default_file(file);
 4   foreach( m_children[c] )
 5     m_children[c].set_report_default_file_hier(file);
 6 endfunction
 7 
 8 function void set_report_default_file (UVM_FILE file);
 9   m_rh.set_default_file(file);
10 endfunction
11 
12 function void set_default_file (UVM_FILE file);
13   default_file_handle = file;
14 endfunction
15 
16 //UVM_FILE使用示例3
17 class wb_conmax_report_file_test extends wb_conmax_base_test;
18     UVM_FILE file_master;
19     
20     `uvm_component_utils(wb_conmax_report_file_test)
21 
22     function new(string name, uvm_component parent);
23         super.new(name, parent);
24         file_master=$fopen("master_output","w");
25     endfunction
26 
27     virtual function void build_phase(uvm_phase phase);
28         super.build_phase(phase);
29     endfunction
30     
31     virtual function void end_of_elaboration_phase(uvm_phase phase);
32         super.end_of_elaboration_phase(phase);
33         env.set_report_default_file_hier(file_master);
34         env.conmax_scbd.set_report_id_file_hier("SCOREBOARD_MASTER",file_master);
35         env.conmax_scbd.set_report_id_action("SCOREBOARD_MASTER", UVM_DISPALY|UVM_LOG);
36     endfunction
37 endclass

 

 

 

 

posted on 2022-01-27 18:48  知北游。。  阅读(1254)  评论(0编辑  收藏  举报

导航