UVM代码编译报错ELAB2_0036:层级引用未解析问题求助
UVM Sequencer使用报错:ELAB2_0036未解析层级引用
报错信息
ELAB2: Create instances ... # KERNEL: Info: Loading library: /usr/share/Riviera-PRO/bin/uvm_1_2_dpi # KERNEL: Time resolution set to 1ns. # ELAB2: Fatal Error: ELAB2_0036 Unresolved hierarchical reference to "seq1.start./0/" from module "test" (module not found). # ELAB2: Last instance before error: /test # KERNEL: Error: E8005 : Kernel process initialization failed.
问题代码
`include "uvm_macros.svh" import uvm_pkg::*; /////////////////////////////////////////////////////////////////// class transaction extends uvm_sequence_item; rand bit [3:0] a; rand bit [3:0] b; bit [4:0] y; function new(string tag="transaction"); super.new(tag); endfunction `uvm_object_utils_begin(transaction) `uvm_field_int(a,UVM_DEFAULT) `uvm_field_int(b,UVM_DEFAULT) `uvm_field_int(y,UVM_DEFAULT) `uvm_object_utils_end endclass ////////////////////////////////////////////////////////////////// class seqq extends uvm_sequence_item; `uvm_object_utils(seqq) function new(string tag="seqq"); super.new(tag); endfunction virtual task pre_body(); `uvm_info("seqq","pre-body",UVM_NONE); endtask virtual task body(); `uvm_info("seqq","body",UVM_NONE); endtask virtual task post_body(); `uvm_info("seqq","post-body",UVM_NONE); endtask endclass ////////////////////////////////////////////////////////////////// class driver extends uvm_driver#(transaction); `uvm_component_utils(driver) transaction tr; function new(string tag="driver",uvm_component parent=null); super.new(tag,parent); endfunction function void build_phase(uvm_phase phase); super.build_phase(phase); tr = transaction::type_id::create("tr"); endfunction virtual task run_phase(uvm_phase phase); forever begin seq_item_port.get_next_item(tr); seq_item_port.done(); end endtask endclass ///////////////////////////////////////////////////////////////////// class agent extends uvm_agent; `uvm_component_utils(agent); driver drv; uvm_sequencer #(transaction) seqr; function new(string tag="agent",uvm_component parent=null); super.new(tag,parent); endfunction virtual function void build_phase(uvm_phase phase); drv=driver::type_id::create("drv",this); seqr = uvm_sequencer #(transaction)::type_id::create("seqr",this); endfunction virtual function void connect_phase(uvm_phase phase); super.connect_phase(phase); drv.seq_item_port.connect(seqr.seq_item_export); endfunction endclass /////////////////////////////////////////////////////////////////////////// class env extends uvm_env; `uvm_component_utils(env) function new(input string path = "env", uvm_component parent= null); super.new(path,parent); endfunction agent a; virtual function void build_phase(uvm_phase phase); super.build_phase(phase); a = agent::type_id::create("a",this); endfunction endclass /////////////////////////////////////////////////////////////////// class test extends uvm_test; `uvm_component_utils(test) function new(input string path = "test", uvm_component parent = null); super.new(path,parent); endfunction seqq seq1; env e; virtual function void build_phase(uvm_phase phase); super.build_phase(phase); e = env::type_id::create("e",this); seq1 = seqq::type_id::create("seq1"); endfunction virtual task run_phase(uvm_phase phase); phase.raise_objection(this); seq1.start(e.a.seqr); phase.drop_objection(this); endtask endclass ///////////////////////////////////////////////////////// module ram_tb; initial begin run_test("test"); end endmodule
问题根源
核心错误是seqq类的继承关系错误:
- 你希望
seqq作为序列类控制事务发送,需要继承uvm_sequence#(T)基类,其中T是该序列要发送的事务类型(这里是transaction)。 - 但当前代码中
seqq继承了uvm_sequence_item,这是事务对象类的基类,它没有start()方法的正确实现来关联sequencer,导致UVM解析层级引用时失败。
修复方案
修改seqq类的继承关系,替换为uvm_sequence#(transaction),并确保类结构符合UVM序列要求:
class seqq extends uvm_sequence#(transaction); `uvm_object_utils(seqq) function new(string tag="seqq"); super.new(tag); endfunction virtual task pre_body(); `uvm_info("seqq","pre-body",UVM_NONE); endtask virtual task body(); `uvm_info("seqq","body",UVM_NONE); // 可选:如果需要发送transaction,示例代码如下 // transaction req; // req = transaction::type_id::create("req"); // start_item(req); // assert(req.randomize()); // finish_item(req); endtask virtual task post_body(); `uvm_info("seqq","post-body",UVM_NONE); endtask endclass
额外说明
uvm_sequence是用于组织事务流的类,它通过start()方法绑定到指定sequencer,实现向driver发送事务的逻辑。uvm_sequence_item是单个事务的载体,比如你定义的transaction类,它被序列类创建、随机化后发送给driver。
内容的提问来源于stack exchange,提问作者Ankit Kaushik
相关产品推荐
相关产品推荐

