Title:
[UVM]IC验证自动结束仿真函数——uvm_top.set_timeout/set_report_max_quit_count
1- 前言
数字IC验证过程中,需要运行不同Testcase,有些TC会因为TC配置、TB机制等原因,导致make run
卡死/无线占用线程。此时需要采取措施让TC自动$(stop)
,在UVM中自带这种函数:uvm_top.set_timeout
和set_report_max_quit_count
。
2- uvm_top.set_timeout
uvm_top.set_timeout(1s, 0);
功能:
uvm_top.set_timeout
函数用于设置整个测试环境的超时时间。
参数:
1s
:超时时间,表示 1 秒。0
:对于多个TC的一次仿真,设置为 0,超时不会导致整个仿真中止,只会停止正在运行的TC,记录一个错误并进入下一个TC。如果设置为非零值,超时会触发fatal
操作,导致整个仿真中止。
3- set_report_max_quit_count
set_report_max_quit_count(100);
功能:
set_report_max_quit_count
函数用于控制在仿真过程中,允许生成的最大报告数量。
参数:
100
:表示允许的最大报告数量。超过这个数量时,仿真将会停止生成报告并中止。
4- 运用
🤔已知tc_hdmi_base的 退出时间 **(5s)**和 退出ERROR数(100);
1️⃣ 对tc_1.sv单独控制 退出时间 (1s)和 退出ERROR数(3);
2️⃣ 按照这种思路也可以对tc_2.sv单独控制 退出时间 (10s)和 退出ERROR数(300);
`ifndef TC_1__SV
`define TC_1__SV
class tc_1 extends tc_hdmi_base;
`uvm_component_utils(tc_1)
function new (string name = "", uvm_component parent = null);
super.new(name,parent);
endfunction:new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
//1-满3个UVM_ERROR,则退出本TC的仿真;
set_report_max_quit_count(3);
//2-满5s.则退出本TC的仿真;
uvm_top.set_timeout(5s,0);
endfunction:build_phase
virtual task main_phase (uvm_phase phase);
tc_1_sequence seq;
seq = tc_1_sequence::type_id::create();
seq.starting_phase = phase;
seq.start(this.env.hdmi_rx_agt.hdmi_rx_sqr);
endtask:main_phase
endclass
`endif
`ifndef TC_HDMI_BASE__SV
`define TC_HDMI_BASE__SV
class tc_hdmi_base extends uvm_test;
hdmi_env env;
uvm_status_e status;
ral_block_hdmi hdmi_ral_mdl;
`uvm_component_utils(tc_hdmi_base)
function new (string name = " ", uvm_component parent = null);
super.new(name,parent);
endfunction:new
extern virtual function void build_phase (uvm_phase phase);
extern virtual function void connect_phase(uvm_phase phase);
extern virtual task main_phase (uvm_phase phase);
extern virtual function void report_phase (uvm_phase phase);
endclass:tc_hdmi_base
function void tc_hdmi_base::build_phase(uvm_phase phase);
super.build_phase(phase);
env = hdmi_env::type_id::create("env",this);
uvm_top.set_timeout(5s,0);
set_report_max_quit_count(100);
endfunction:build_phase
function void tc_hdmi_base::connect_phase(uvm_phase phase);
super.connect_phase(phase);
endfunction:connect_phase
task tc_hdmi_base::main_phase(uvm_phase phase);
tc_hdmi_base_sequence seq;
super.main_phase(phase);
uvm_config_db #(ral_block_hdmi)::get(null,"uvm_test_top","hdmi_ral_mdl",hdmi_ral_mdl);
seq = tc_hdmi_base_sequence::type_id::create("seq");
seq.starting_phase = phase;
seq.start(this.env.hdmi_rx_agt.hdmi_rx_sqr);
phase.phase_done.set_drain_time(this,30000);
endtask:main_phase
function void tc_hdmi_base::report_phase(uvm_phase phase);
uvm_report_server server ;
int err_num;
super.report_phase(phase);
server = get_report_server();
err_num = server.get_severity_count(UVM_ERROR);
if(err_num == 0)begin
$display("\n");
$display("+==========================+");
$display("|Simulation Result:PASSED!!|");
$display("+==========================+");
$display("\n");
end
else begin
$display("\n");
$display("+==========================+");
$display("|Simulation Result:FAILED!!|");
$display("+==========================+");
$display("\n");
end
endfunction:report_phase
`endif
5- 小结
📨认知有限欢迎指导,本文持续更新中…