通过控制component打印信息的行为,提高日志的可读性。
uvm_component 直接继承自uvm_report_object,所以component继承了一些设置report的函数。
打印信息的宏有:
- `uvm_info(id,mess,verbosity).
- `uvm_warning(id,mess)
- `uvm_error(id,mess)
- `uvm_fatal(id,mess)
1. 设置信息冗余度阈值 verbosity level
冗余度等于低于阈值的信息可以打印出来,否则不会显示。
uvm_verbosity |
|
UVM_NONE |
Report is always printed. Verbosity level setting can not disable it. |
UVM_LOW |
Report is issued if configured verbosity is set to UVM_LOW or above. |
UVM_MEDIUM |
Report is issued if configured verbosity is set to UVM_MEDIUM or above. |
UVM_HIGH |
Report is issued if configured verbosity is set to UVM_HIGH or above. |
UVM_FULL |
Report is issued if configured verbosity is set to UVM_FULL or above. |
| tyypedef enum{ UVM_NONE=0, UVM_LOW=100, UVM_MEDIUM=200, UVM_HIGH=300, UVM_FULL = 400, UVM_DEBUG=500 } uvm_verbosity
|
1 2
| $display("env's verbosity is %0d",env.get_verbosity_level());
|
1 2 3
|
env.set_report_verbosity_level(UVM_HIGH);
|
1 2 3 4 5 6 7 8 9 10 11
|
env.set_report_id_verbosity("env",UVM_LOW);
|
也可以在仿真的时候添加仿真选项:
1 2
| ./simv +UVM_VERBOSITY=UVM_HIGH
|
2. 重载打印信息严重性 severity
uvm有四种信息严重性:
- UVM_INFO
- UVM_WARNING
- UVM_ERROR
- UVM_FATAL
这四种可以相互重载
1 2 3
| env.set_report_severity_override(UVM_WARNING,UVM_ERROR);
|
也可以在仿真时候设置,设置选项如下:
1
| +uvm_set_severity=<comp>,<id>,<current_severity>,<new_severity>
|
使用:
1
| ./simv +uvm_set_severity="uvm_base_top.env,env,UVM_WARNING,UVM_ERROR"
|
2.1 观察打印信息
1
| UVM_INFO my_env.sv(17) @ 0: uvm_test_top.env [my_env] my_env is created !!
|
上面是`uvm_info宏输出的信息:
- UVM_INFO: 信息severity
- my_env.sv(17): code中的位置
- @ 0: 仿真事件
- uvm_test_top.env : 层次路径
- [my_env]: 设置的id
- my_env is created !!:要打印的信息
3. 错误信息到一定数量结束仿真
当UVM_FATAL发生时,立即结束仿真;但UVM_ERROR则需要到了一定数量才会结束仿真。
可以设置达到几个error就结束仿真。
1 2 3 4 5 6
| function void base_test::build_phase(uvm_phase phase); super.build_phase(phase); env = my_env::type_id::create("env", this); set_report_max_quit_count(5); endfunction
|
也可以在仿真选项中设置:
1 2
| ./simv +UVM_MAX_QUIT_COUNT=5,NO
|
4. 设置计数目标
上一节中UVM_ERROR到达一定值后结束仿真,也可以把UVM_WARNING也加入计数目标,error和warning的达到最大值就退出仿真。
1 2 3
| env.set_report_severity_action(UVM_WARNING,UVM_DISPLAY|UVM_COUNT);
|
也可以针对某个ID计数
也可把id和severity联合起来进行设置
uvm_action |
description |
UVM_NO_ACTION |
No action is taken |
UVM_DISPLAY |
Sends the report to the standard output |
UVM_LOG |
Sends the report to the file(s) for this (severity,id) pair |
UVM_COUNT |
Counts the number of reports with the COUNT attribute. When this value reaches max_quit_count, the simulation terminates |
UVM_EXIT |
Terminates the simulation immediately. |
UVM_CALL_HOOK |
Callback the report hook methods |
UVM_STOP |
Causes $stop to be executed, putting the simulation into interactive mode. |
5. UVM断点
执行到断点,停止仿真。
设置出现UVM_WARNING的时候停止仿真:
1
| env.set_report_severity_action(UVM_WARNING,UVM_DISPLAY|UVM_STOP);
|
6. 将输出信息写入到文件
1 2 3 4 5 6
| function void set_report_severity_file (uvm_severity severity,UVM_FILE file) function void set_report_id_file ( string id,UVM_FILE file ) function void set_report_severity_id_file (uvm_severity severity,string id,UVM_FILE file) function void set_report_severity_file_hier (uvm_severity severity,UVM_FILE file) function void set_report_id_file_hier ( string id,UVM_FILE file ) function void set_report_severity_id_file_hier (uvm_severity severity,string id,UVM_FILE file)
|
6.1 将不同severity的信息打印到不同的文件中。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
UVM_FILE info_log; UVM_FILE warning_log; UVM_FILE error_log; UVM_FILE fatal_log; virtual function void connect_phase(uvm_phase phase); info_log = $fopen("info.log", "w"); warning_log = $fopen("warning.log", "w"); error_log = $fopen("error.log", "w"); fatal_log = $fopen("fatal.log", "w"); env.i_agt.drv.set_report_severity_file(UVM_INFO, info_log); env.i_agt.drv.set_report_severity_file(UVM_WARNING, warning_log); env.i_agt.drv.set_report_severity_file(UVM_ERROR, error_log); env.i_agt.drv.set_report_severity_file(UVM_FATAL, fatal_log); env.i_agt.drv.set_report_severity_action(UVM_INFO, UVM_DISPLAY | UVM_LOG); env.i_agt.drv.set_report_severity_action(UVM_WARNING, UVM_DISPLAY | UVM_LOG); env.i_agt.drv.set_report_severity_action(UVM_ERROR, UVM_DISPLAY | UVM_COUNT | UVM_LOG); env.i_agt.drv.set_report_severity_action(UVM_FATAL, UVM_DISPLAY | UVM_EXIT | UVM_LOG); endfunction virtual function void final_phase(uvm_phase phase); $fclose(info_log); $fclose(warning_log); $fclose(error_log); $fclose(fatal_log); endfunction
|
6.2 将不同id的信息打印到不同的文件中。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| UVM_FILE driver_log; UVM_FILE drv_log; virtual function void connect_phase(uvm_phase phase); driver_log = $fopen("driver.log", "w"); drv_log = $fopen("drv.log", "w"); env.i_agt.drv.set_report_severity_id_file(UVM_WARNING, "my_driver", driver_log); env.i_agt.drv.set_report_severity_id_file(UVM_INFO, "my_drv", drv_log); env.i_agt.drv.set_report_id_action("my_driver", UVM_DISPLAY| UVM_LOG); env.i_agt.drv.set_report_id_action("my_drv", UVM_DISPLAY| UVM_LOG); endfunction virtual function void final_phase(uvm_phase phase); $fclose(driver_log); $fclose(drv_log); endfunction
|
7. 信息的打印行为 action
前面大都是通过设置action来控制打印信息。
uvm_action |
description |
UVM_NO_ACTION |
No action is taken |
UVM_DISPLAY |
Sends the report to the standard output |
UVM_LOG |
Sends the report to the file(s) for this (severity,id) pair |
UVM_COUNT |
Counts the number of reports with the COUNT attribute. When this value reaches max_quit_count, the simulation terminates |
UVM_EXIT |
Terminates the simulation immediately. |
UVM_CALL_HOOK |
Callback the report hook methods |
UVM_STOP |
Causes $stop to be executed, putting the simulation into interactive mode. |
1 2 3 4 5 6 7 8 9 10
| typedef enum { UVM_NO_ACTION = 'b000000, UVM_DISPLAY = 'b000001, UVM_LOG = 'b000010, UVM_COUNT = 'b000100, UVM_EXIT = 'b001000, UVM_CALL_HOOK = 'b010000, UVM_STOP = 'b100000 } uvm_action_type;
|
8. 打印UVM树结构
1
| uvm_top.print_topology()
|
可以把它写在base_test中
1 2 3 4
| function void base_test::report_phase(uvm_phase phase); super.report_phase(phase); uvm_top.print_topology(); endfunction
|
打印输出
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| UVM_INFO @ 43550000: reporter [UVMTOP] UVM testbench topology:
Name Type Size Value
uvm_test_top case0 - @460 env enviroment - @468 agt2mdl uvm_tlm_analysis_fifo #(T) - @492 analysis_export uvm_analysis_imp - @536 get_ap uvm_analysis_port - @527 get_peek_export uvm_get_peek_imp - @509 put_ap uvm_analysis_port - @518 put_export uvm_put_imp - @500 i_agt agent - @480 drv driver - @545 rsp_port uvm_analysis_port - @562 seq_item_port uvm_seq_item_pull_port - @553 mon_apb monitor_apb - @694 ap uvm_analysis_port - @702 sqr sequencer - @571 rsp_export uvm_analysis_export - @579 seq_item_export uvm_seq_item_pull_imp - @685 arbitration_queue array 0 - lock_queue array 0 - num_last_reqs integral 32 'd1 num_last_rsps integral 32 'd1
|