Layering Sequence. ILLCRT error from questasim.

1 post / 0 new
Last post
Madhanv
Offline
Academy Total Access User
Joined: 11/22/2011
Posts: 1
Layering Sequence. ILLCRT error from questasim.

I was trying out sequence layering using uvm_layering-1.0.
I get the following error when i simulate the code.
//--------------------
UVM_FATAL @ 0: u_agent_sequencer_port [ILLCRT] It is illegal to create a component ('u_agent_sequencer_port' under 'uvm_test_top.env.l_agent.seqr') after the build phase has ended.
//--------------------

I believe that this package is trying to create a new sequencer_port after the build phase. I am not sure on how to overcome this.

The following is my example code

`timescale 1ns/10ps
import uvm_pkg::*;
import uvm_layering_pkg::*;
`include "uvm_macros.svh"
 
typedef enum {A_U, B_U, C_U} upper_type_t;
typedef enum {X_U, Y_U, Z_U} lower_type_t;
 
//====================
// Seq_items
class upper_seq_item extends uvm_sequence_item;
 
  rand upper_type_t data_u;
 
  `uvm_object_utils(upper_seq_item)
 
  function new (string name = "upper_seq_item");
    super.new(name);
  endfunction
 
endclass
 
class lower_seq_item extends uvm_sequence_item;
 
  rand lower_type_t data_l;
 
  `uvm_object_utils(lower_seq_item)
 
  function new (string name = "lower_seq_item");
    super.new(name);
  endfunction
 
endclass
 
//====================
// Sequences
class upper_seq extends uvm_sequence#(upper_seq_item);
 
  upper_seq_item itm;
 
  `uvm_object_utils(upper_seq)
 
  function new (string name = "upper_seq");
     super.new(name);
  endfunction
 
  virtual task body ();
     `uvm_do(itm)
  endtask
endclass
 
class lower_seq extends uvm_sequence#(lower_seq_item);
 
  lower_seq_item itm;
 
  `uvm_object_utils(lower_seq)
 
  function new (string name = "lower_seq");
     super.new(name);
  endfunction
 
  virtual task body ();
     `uvm_do(itm)
  endtask
endclass
 
//====================
// Lower Level Driver
class lower_driver extends uvm_driver #(lower_seq_item);
 
  `uvm_component_utils(lower_driver)
 
  function new (string name = "lower_driver", uvm_component parent = null);
     super.new(name, parent);
  endfunction 
 
  function void build_phase (uvm_phase phase);
     super.build_phase(phase);
  endfunction
 
  task run_phase (uvm_phase phase);
     while(1)
     begin
        lower_seq_item itm;
        seq_item_port.get_next_item(itm);
        `uvm_info("UPPER_DRV",$psprintf("Item Name = $s",itm.data_l.name()),UVM_LOW);
        #100;
        seq_item_port.item_done();
     end
  endtask
endclass
 
//====================
// Lower Level Agent
class lower_agent extends uvm_agent;
 
  lower_driver drv;
  uvm_sequencer#(lower_seq_item) seqr;
 
  `uvm_component_utils(lower_agent)
 
  function new (string name = "lower_agent", uvm_component parent = null );
     super.new(name, parent);
  endfunction
 
 
  virtual function void build_phase(uvm_phase phase);
     super.build_phase(phase);
     drv = lower_driver::type_id::create("drv",this);
     seqr = uvm_sequencer#(lower_seq_item)::type_id::create("seqr",this);
  endfunction
 
  virtual function void connect_phase(uvm_phase phase);
     drv.seq_item_port.connect(seqr.seq_item_export);
  endfunction
endclass
 
//====================
// Upper Sequencer
class upper_seqr extends uvm_sequencer#(upper_seq_item);
 
   `uvm_component_utils(upper_seqr)
 
   function new (string name = "upper_seqr", uvm_component parent = null);
      super.new(name,parent);
   endfunction
 
   virtual function void build_phase(uvm_phase phase);
      super.build_phase(phase);
   endfunction
 
   virtual function void connect_phase(uvm_phase phase);
      super.connect_phase(phase);
   endfunction
endclass
 
//====================
// Upper to lower level converter
class u2l_seq extends uvm_translator_base#(upper_seq_item ,upper_seq_item, uvm_sequence#(lower_seq_item));
 
   `uvm_object_utils(u2l_seq)
 
   function new (string name = "u2l_seq");
     super.new(name);
   endfunction
 
   task body ();
     upper_seq_item u_itm;
     lower_seq_item l_itm;
 
     sequencer_port.get(u_itm);
 
     l_itm = lower_seq_item::type_id::create("l_itm");
 
     case(u_itm.data_u)
       A_U: l_itm.data_l = X_U;
       B_U: l_itm.data_l = Y_U;
       C_U: l_itm.data_l = Z_U;
     endcase
     start_item(l_itm);
     finish_item(l_itm);
   endtask
endclass
 
//====================
// Virtual Sequencer
class v_seqr extends uvm_virtual_sequencer;
 
  upper_seqr u_seqr;
 
  `uvm_component_utils(v_seqr)
 
  function new (string name = "v_seqr", uvm_component parent = null);
     super.new(name,parent);
  endfunction
 
  virtual function void build_phase(uvm_phase phase);
     super.build_phase(phase);
  endfunction
 
endclass
 
//====================
// Virtual Sequence Base
 
class v_seq_base extends uvm_sequence#(uvm_sequence_item);
 
   v_seqr seqr;
   upper_seqr u_seqr;
 
   `uvm_object_utils(v_seq_base)
 
   function new (string name = "v_seq_base");
      super.new(name);
   endfunction
 
   task body();
      if(!$cast(seqr,m_sequencer))
      begin
         `uvm_fatal("V_SEQ_BASE","Incorrect sequencer");
      end
      u_seqr = seqr.u_seqr;
   endtask
endclass
 
//====================
// Virtual Sequence
class v_seq extends v_seq_base;
 
  upper_seq itm;
 
  `uvm_object_utils(v_seq);
 
  function new(string name = "v_seq");
     super.new(name);
  endfunction
 
  task body();
     super.body();
     itm = upper_seq::type_id::create("itm");
     for(int unsigned i = 0; i < 10; i++)
     begin
        itm.start(u_seqr);
     end
  endtask
endclass
 
//====================
// ENV
class simple_env extends uvm_env;
 
 
  lower_agent l_agent;
  upper_seqr u_seqr;
  v_seqr virtual_seqr;
  v_seq virtual_seq;
  uvm_layering_agent#(upper_seq_item) u_agent;
 
  `uvm_component_utils(simple_env)
 
  function new(string name = "simple_env", uvm_component parent = null);
    super.new(name, parent);
  endfunction
 
  virtual function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    u_seqr = upper_seqr::type_id::create("u_seqr",this);
    l_agent = lower_agent::type_id::create("l_agent",this);
    virtual_seqr = v_seqr::type_id::create("virtual_seqr",this);
    u_agent = uvm_layering_agent#(upper_seq_item)::type_id::create("u_agent",this);
    u_agent.create_mapping("u_agent",upper_seqr::get_type(),"l_agent",u2l_seq::get_type(),upper_seq::get_type(),"seqr");
  endfunction
 
  virtual function void connect_phase(uvm_phase phase);
    super.connect_phase(phase);
       virtual_seqr.u_seqr = u_seqr;
  endfunction
 
  task main_phase(uvm_phase phase);
    virtual_seq = v_seq::type_id::create("virtual_seq",this);
    phase.raise_objection(this);
    virtual_seq.start(virtual_seqr);
    phase.drop_objection(this);
  endtask
endclass
 
 
//====================
//Test
class simple_test extends uvm_test;
  simple_env env;
 
  `uvm_component_utils(simple_test)
 
  function new (string name = "simple_test", uvm_component parent = null);
    super.new(name,parent);
  endfunction
 
  virtual function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    env = simple_env::type_id::create("env",this);
  endfunction
endclass
 
module test ();
initial
begin
   run_test();
end
endmodule