system-verilog - 在 uvm_component 中捕获 $finish
问题描述
我想在 uvm_component 中捕获 $finish。我的意思是当调用 $finish 时,我的 uvm_component 需要执行一些自定义代码。
我在 uvm_component 中使用了 pre_abort 回调。但问题是我的测试台有多个 uvm_components 并且它们还注册了 pre_abort 回调。
我想确保我的自定义代码应该在模拟退出之前最后执行。
解决方案
在 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
推荐阅读
- java - 在 Java 中的多线程套接字编程方面需要帮助
- javascript - 在javascript中将三元运算分解为if,else
- javascript - 如何修复错误:对象作为 React 子对象无效(找到:[object Promise])
- javascript - 为 HTML 表单生成安全随机数
- php - woocmmerce 函数类的选择选项上的 foreach 数组存在问题
- c - Linux从_start获取终端参数不适用于C中的内联汇编
- flutter - 尝试将小部件添加到小部件列表
- f# - 读取与 f# 中的元组在同一行中的两个整数
- java - 如何生成两个数组的组合?
- java - 无法使用 ServletContext 从路径获取 ResourceAsStream