Null object aceess on seq_item_port.try_next_item

Hi,
I am getting null pointer access in a fairly simple sequnce-sequencer-driver flow.

Here is what i tried.

Sequence:
class my_drive_seq extends uvm_sequence#(sop_eop_trans);

`uvm_object_utils(my_drive_seq)

function new(string name = "my_drive_seq");
    super.new(name);
endfunction

task body();
    sop_eop_trans pkt;
    pkt = sop_eop_trans::type_id::create("packet");
    start_item(pkt);
    assert( pkt.randomize() with {size == 5; val ==1; });
    finish_item(pkt);
endtask

endclass

Agent:
class sop_eop_agnt extends uvm_agent;
`uvm_component_utils(sop_eop_agnt)
sop_eop_drv drv;
uvm_sequencer#(sop_eop_trans) seqr;

function new(string name, uvm_component parent);
    super.new(name,parent);
endfunction

function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    drv = sop_eop_drv::type_id::create("drv",this);
    seqr = uvm_sequencer#(sop_eop_trans)::type_id::create("seqr",this);
endfunction

function void connect_pahse(uvm_phase phase);
    drv.seq_item_port.connect(seqr.seq_item_export);
endfunction 

endclass

Driver:
class sop_eop_drv extends uvm_driver#(sop_eop_trans);

`uvm_component_utils(sop_eop_drv)

sop_eop_trans item;

virtual dut_if vif;

function new(string name, uvm_component parent);
    super.new(name,parent);
endfunction

function void build_phase (uvm_phase phase);
    super.build_phase(phase);
    if(!uvm_config_db#(virtual dut_if)::get(this,"","vif",vif));
endfunction

task run_phase(uvm_phase phase);
    sop_eop_trans item;

    vif.rst = 0;
    repeat(100) @(posedge vif.clk);
    vif.rst = 1;
    repeat(10) @(posedge vif.clk);

    forever begin
        @vif.drv_cb;
       // seq_item_port.get_next_item(item); **//NULL**
        seq_item_port.try_next_item(item);  **//NULL**
        @vif.drv_cb;
        seq_item_port.item_done();
    end
endtask

endclass

Sequence Started from Test using: seq.start(m_env.m_agnt.seqr);

VCS ERROR:
*Error-[NOA] Null object access
/p/psg/eda/synopsys/vcsmx/P-2019.06-SP2-7/linux64/suse/etc/uvm/tlm1/uvm_sqr_connections.svh, 45
The object at dereference depth 1 is being used before it was
constructed/allocated.
Please make sure that the object is allocated before using it.

#0 in
\uvm_seq_item_pull_port#(my_testbench_pkg::sop_eop_trans,my_testbench_pkg::sop_eop_trans)::try_next_item*

In reply to akhil_dv:

Is this a typo ONLY in above code OR have you written the same in the actual code ::


function void connect_pahse(uvm_phase phase); // Should be connect_phase  
drv.seq_item_port.connect(seqr.seq_item_export);
endfunction

1 Like

In reply to akhil_dv:

Thanks man. I didn’t notice that.
I was trying see this issue from all other perspective.
Nice catch!!

The tool didn’t throw any error for this ‘typo’ as I was defining a new function all together.

Regards,
Akhil