[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:对于多个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- 小结

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

相关推荐

  1. 自动驾驶仿真

    2024-07-10 08:34:01       22 阅读
  2. LaneKeepingEnv(自动驾驶仿真

    2024-07-10 08:34:01       41 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-10 08:34:01       99 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-10 08:34:01       107 阅读
  3. 在Django里面运行非项目文件

    2024-07-10 08:34:01       90 阅读
  4. Python语言-面向对象

    2024-07-10 08:34:01       98 阅读

热门阅读

  1. Electron 简单搭建项目

    2024-07-10 08:34:01       35 阅读
  2. adb 常用的命令总结

    2024-07-10 08:34:01       30 阅读
  3. gcc: options: -specs

    2024-07-10 08:34:01       29 阅读
  4. Python题解Leetcode Hot 100之栈和堆

    2024-07-10 08:34:01       30 阅读
  5. docker容器如何与本地配置文件关联

    2024-07-10 08:34:01       37 阅读
  6. SQL 字段类型-上

    2024-07-10 08:34:01       35 阅读
  7. C++ 入门04:数组与字符串

    2024-07-10 08:34:01       24 阅读
  8. 简谈设计模式之原型模式

    2024-07-10 08:34:01       31 阅读
  9. GPT带我学-设计模式-13策略模式

    2024-07-10 08:34:01       29 阅读
  10. 写一个字符设备的驱动步骤

    2024-07-10 08:34:01       30 阅读
  11. Transformer和Bert的原理是什么

    2024-07-10 08:34:01       29 阅读