文章目录
- 原始代码及log
- UVM结束机制解析:uvm_test_done异议机制
- 🧩 仿真结果验证
- 🔍 UVM异议机制核心原理
- ✅ UVM异议机制的本质
- ✅ UVM异议计数器工作原理
- 🧪 UVM异议机制工作流程
- 1. 设置排空时间
- 2. 启动并行任务
- 3. 任务执行流程
- 4. 异议回调函数
- 💡 为什么测试在60ns结束而不是50ns?
- ✅ UVM异议机制的三个关键组件
- 💡 UVM异议机制的核心原则
- ✅ UVM异议机制的典型用法
- 1. 在组件中使用异议
- 2. 使用异议回调
- 💬 与UVM官方文档一致
- ✅ 重要结论:UVM异议机制的正确使用
- ✅ 正确使用步骤(100%准确)
- ❌ 常见错误
- 💡 为什么需要排空时间?
- 💬 重要总结
- 追更!
- UVM 中 Phase 机制与 uvm_test_done:区别、联系与现代实践
- 一、一句话总结
- 二、核心区别与联系
- 三、UVM Phase 机制详解
- 1. Phase 机制的核心价值
- 2. Phase 分类与执行顺序
- ✅ Function Phase(不消耗仿真时间)
- ✅ Task Phase(消耗仿真时间)
- 3. 执行顺序图示
- 4. 关键代码示例(现代 UVM 实践)
- 5. 为什么 Phase 机制优于 uvm_test_done
- uvm_test_done(已弃用)示例
- UVM Phase(推荐)示例
- 四、Phase 机制的三大优势
- 1. 精细控制
- 2. 自动化
- 3. 与 UVM 设计哲学一致
- 五、UVM Phase 机制执行流程图
- 六、关键结论
- 七、附录:UVM Phase 机制执行顺序速查表
原始代码及log
`timescale1ns/1ns module test;// 这个简单示例展示了如何使用 uvm_test_done 异议机制来协调测试结束活动。// 若想了解在完整环境中使用测试结束协调的示例,请参考 xbus 示例。//// 在本例中,组件设置了一个 10 时间单位的排空时间(drain time)。// 组件随后启动了 4 个进程,这些进程消耗不同的时间。// 当最后一个进程完成(时间为 50)时,排空时间开始生效。// 测试在时间 60 结束。//// 该示例还展示了组件异议回调的用法。// 本例中使用了 dropped 回调,但 raised 和 all_dropped 的工作方式类似,// 只是 all_dropped 是一个耗时的任务。import uvm_pkg::*;`include"uvm_macros.svh"classsimple_testextends uvm_test;functionnew(string name,uvm_component parent);super.new(name,parent);endfunction:new// Register with the factory.`uvm_component_utils(simple_test)virtualtaskrun_phase(uvm_phase phase);// Set a drain time on the objection if neededuvm_report_info("drain","Setting drain time of 10",UVM_NONE);uvm_test_done.set_drain_time(this,10);// Run a bunch of processes in parallelforkdoit(35);doit(25);doit(50);doit(15);join endtask// A simple task that consumes some time.taskdoit(time delay);staticints_inst=0;intinst=s_inst++;//Raise an objection before starting the activityuvm_test_done.raise_objection(this);uvm_report_info("doit",$sformatf("Starting doit (%0d) with delay %0t",inst,delay),UVM_NONE);#delay;uvm_report_info("doit",$sformatf("Ending doit (%0d)",inst),UVM_NONE);//Drop the objection when doneuvm_test_done.drop_objection(this);endtask// Use an objection callback do something when objections are raised or// dropped (or all dropped). This example prints some information on each// drop.virtualfunctionvoiddropped(uvm_objection objection,uvm_object source_obj,string description,intcount);uvm_report_info("dropped",$sformatf("%d objection(s) dropped from %s, total count is now %0d",count,source_obj.get_full_name,objection.get_objection_total(this)),UVM_NONE);endfunction endclass:simple_test// Run the testinitialrun_test("simple_test");endmodule 以下是实际仿真结果:--------------------------------------------------------