调用new()实例化对象时遇SV-ACCNBI错误,请求技术支持
问题分析与解决
错误原因
uvm_component是UVM框架中的抽象基类,SystemVerilog规则明确禁止直接实例化抽象类,必须使用其具体派生类(如uvm_env、uvm_agent等)。另外,你的代码逻辑中后续会通过uvm_top.find()查找UVM树中已存在的组件实例,前面的new()操作完全多余,这正是触发SV-ACCNBI错误的核心原因。
修复后的代码
module model_dpi_module; task abc_model_dpi(int pkg,int inst); uvm_component umc_uvc_ptr; // 移除多余的new()调用,直接查找已存在的组件 umc_uvc_ptr = uvm_top.find($sformatf("uvm_test_top.example_uvc.export_uvc_%0d_%0d_%0d", 0, inst, inst)); // 可选:添加非空检查,避免查找失败导致后续操作出错 if(umc_uvc_ptr == null) begin `uvm_error("DPI_TASK", $sformatf("Failed to find component export_uvc_0_%0d_%0d", inst, inst)) return; end umc_uvc[pkg][inst].if_env[0].run_model_init(0, 0,0); endtask : abc_model_dpi endmodule
额外说明
- UVM组件的实例化通常通过UVM工厂机制在测试流程中完成,无需在DPI任务中直接调用
new()。 - 使用
uvm_top.find()时,需确保路径字符串与UVM树中组件的实际层次路径完全匹配,否则会返回空指针。
内容的提问来源于stack exchange,提问作者Swathi Bardhabad
相关产品推荐
相关产品推荐

