首页 > 解决方案 > 在 uvm_component 中捕获 $finish

问题描述

我想在 uvm_component 中捕获 $finish。我的意思是当调用 $finish 时,我的 uvm_component 需要执行一些自定义代码。

我在 uvm_component 中使用了 pre_abort 回调。但问题是我的测试台有多个 uvm_components 并且它们还注册了 pre_abort 回调。

我想确保我的自定义代码应该在模拟退出之前最后执行。

标签: system-veriloguvm

解决方案


在 verilog 中,“捕获”的唯一方法$finish是使用final块。以下示例说明了一种可能的解决方案。

package TB;
class WorkHorse;
  function void start;
    $display("I am statging");
  endfunction

  task finish;
    $display("finishing");
    $finish;
  endtask

  function void done ;
    $display("I am done");
  endfunction

endclass
endpackage

program tb;
  TB::WorkHorse wh = new;

  initial begin
    #2 wh.start;
    #2 wh.finish;
  end

  final begin
    wh.done;
  end
endprogram

推荐阅读