Search code examples
system-veriloguvm

Fatal Error: ELAB2_0036 Unresolved hierarchical reference while using UVM


I was trying to create a UVM code with sequencer, but I get this error:

Fatal Error: ELAB2_0036 Unresolved hierarchical reference while using UVM

`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

This is the EDA playground message I am seeing:

 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.

Solution

  • In the test, you use seqq as a sequence (calling the start method), but you declared seqq as a uvm_sequence_item. Change:

    class seqq extends uvm_sequence_item;
    

    to:

    class seqq extends uvm_sequence;
    

    After fixing that error, I also got an error in the driver. To fix that, change:

      seq_item_port.done();
    

    to:

      seq_item_port.item_done();