[UVM]IC验证自动结束仿真函数——uvm_top.set_timeout/set_report_max_quit_count

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_timeoutset_report_max_quit_count

2- uvm_top.set_timeout

uvm_top.set_timeout(1s, 0);

功能:

uvm_top.set_timeout 函数用于设置整个测试环境的超时时间。

参数:

  • 1s:超时时间,表示 1 秒。
  • 0:参数2,表示是否可以被子类set_timeout再次设置,或者说覆盖,所以要启用此功能需要设置为1 !!!

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(1s,1);
  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,1);
  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- 小结

📨认知有限欢迎指导,本文持续更新中…

  • 13
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值