# NULL pointer dereference on driver seq\_item\_port

**URL:** <https://verificationacademy.com/forums/t/null-pointer-dereference-on-driver-seq-item-port/31736>\
**Category:** UVM\
**Tags:** UVM, uvm\_driver, Null-pointer-dereference, seq\_item\_port\
**Created:** [April 20, 2016, 11:52pm UTC](https://verificationacademy.com/forums/t/null-pointer-dereference-on-driver-seq-item-port/31736 "2016-04-20T23:52:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![charleneku](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@charleneku](https://verificationacademy.com/forums/u/charleneku)\
**Post date:** [April 20, 2016, 11:52pm UTC](https://verificationacademy.com/forums/t/null-pointer-dereference-on-driver-seq-item-port/31736/1 "2016-04-20T23:52:43Z")

</div>

I’m confounded by this. I have a fairly simple sequence/sequencer/driver in my agent. However, my driver seems to be getting something from the seq\_item\_port that is invalid. Whether the sequencer has sent an item yet, or not, I consistantly get the NULL pointer error. Code is:

Sequence:

```verilog
...
      while(!$feof(pin1_fp)) begin
	 pin_item= hdr_input_pin_seq_item::type_id::create("pin_item");
...
	 pin_item.alpha_in = alpha_in;
	 pin_item.alpha_ch3_2_sel = 'h0; //fix later
	 
	 `uvm_info("HDR PIN SEQ", "Starting pin_item", UVM_HIGH);
	 pin_item.print_item();
	 start_item(pin_item);
	 finish_item(pin_item);

Driver is:
   virtual task run_phase(uvm_phase phase);
// hdr_input_pin_seq_item pin_item;
      hdr_input_pin_seq_item pin_seq_item;
   
      wait (pin_if_v.resetn == 1);
      repeat (2000) @(posedge pin_if_v.clk);
   
   
      forever begin
	 `uvm_info("HDR PIN DRIVER", "Wait for next item", UVM_HIGH);
	 seq_item_port.get(req);
	 `uvm_info("HDR PIN DRIVER", "Got next item", UVM_HIGH);
...
Sequencer is unmodified, just a call to new.

Agent:
class hdr_input_pin_agent extends uvm_agent;
   `uvm_component_utils(hdr_input_pin_agent);

   hdr_input_pin_driver pin_drv;
   hdr_input_pin_sequencer pin_seq;
   virtual hdr_input_pin_if pin_if_v;

   function new(string name="hdr_input_pin_agent", uvm_component parent);
      super.new(name, parent);
   endfunction // new

   virtual function void build_phase(uvm_phase phase);
     super.build_phase(phase);
// if (get_is_active() == UVM_ACTIVE) begin
	pin_drv = hdr_input_pin_driver::type_id::create("pin_drv", this);
	pin_seq = hdr_input_pin_sequencer::type_id::create("pin_seq", this);
// end
   if(!uvm_config_db #(virtual hdr_input_pin_if)::get(this, "", "hdr_input_pin_if", this.pin_if_v))
       `uvm_fatal("HDR INPUT PIN AGENT", "Failed to get pin_if_v");

     uvm_config_db#(virtual hdr_input_pin_if)::set(this, "*", "hdr_input_pin_if", pin_if_v);
   endfunction // void

   virtual function void conntect_phase(uvm_phase phase);
     super.connect_phase(phase);
// if(get_is_active()==UVM_ACTIVE) begin
	pin_drv.seq_item_port.connect(pin_seq.seq_item_export);
// end
   endfunction // void

endclass // hdr_input_pin_agent

```

Error is:  
UVM\_INFO /proj/media\_imx8\_dv\_backup/b53418/dc\_003/blocks/med\_dcss\_tb/testbench/classes\_v/hdr\_input\_pin\_agent/hdr\_input\_seq\_item.sv(62) @ 2241.000ns: reporter@@pin\_item [HDR\_INPUT\_PIN\_SEQ\_ITEM] alpha\_ch3\_2\_sel = 0  
UVM\_INFO /proj/media\_imx8\_dv\_backup/b53418/dc\_003/blocks/med\_dcss\_tb/testbench/classes\_v/hdr\_input\_pout\_agent/hdr\_input\_pout\_sequence.sv(28) @ 2241.000ns: uvm\_test\_top.u\_hdr\_input\_env.pout\_agent.hdr\_input\_pout\_sequencer@@pout\_seq [HDR POUT SEQ] Output sequence started  
Open failed on file “…/…/vectors/hdr\_input\_p1CSCA/hdr\_input\_pipe2.out”. No such file or directory  
Open failed on file “…/…/vectors/hdr\_input\_p1CSCA/hdr\_input\_pipe3.out”. No such file or directory  
UVM\_INFO /proj/media\_imx8\_dv\_backup/b53418/dc\_003/blocks/med\_dcss\_tb/testbench/classes\_v/hdr\_input\_pin\_agent/hdr\_input\_pin\_driver.sv(25) @ 4007.000ns: uvm\_test\_top.u\_hdr\_input\_env.pin\_agent.pin\_drv [HDR PIN DRIVER] Wait for next item  
ncsim: \*E,TRNULLID: NULL pointer dereference.  
File: /pkg/uvm-/1.1d/src/tlm1/uvm\_sqr\_connections.svh, line = 45, pos = 50  
Scope: worklib.uvm\_pkg::uvm\_seq\_item\_pull\_port#(hdr\_input\_pin\_seq\_item,hdr\_input\_pin\_seq\_item)@11004\_19.get\_next\_item  
Time: 4007 NS + 1  
Verilog Stack Trace:  
0: task worklib.uvm\_pkg::uvm\_seq\_item\_pull\_port#(hdr\_input\_pin\_seq\_item,hdr\_input\_pin\_seq\_item)@11004\_19.get\_next\_item at /pkg/uvm-/1.1d/src/tlm1/uvm\_sqr\_connections.svh:45  
1: task testbench.top\_level\_module.hdr\_input\_pin\_driver@10980\_6.run\_phase at /proj/media\_imx8\_dv\_backup/b53418/dc\_003/blocks/med\_dcss\_tb/testbench/classes\_v/hdr\_input\_pin\_agent/hdr\_input\_pin\_driver.sv:26  
2: task worklib.uvm\_pkg::uvm\_run\_phase@5038\_2945.exec\_task at /pkg/uvm-/1.1d/src/base/uvm\_common\_phases.svh:245  
3: process in worklib.uvm\_pkg::uvm\_task\_phase@5038\_2945.execute.unmblk1 at /pkg/uvm-/1.1d/src/base/uvm\_task\_phase.svh:150

/pkg/uvm-/1.1d/src/tlm1/uvm\_sqr\_connections.svh:45 `UVM\_SEQ\_ITEM\_PULL\_IMP(this.m\_if, REQ, RSP, t, t)  
ncsim\>  
ncsim\>

---

<div class="post-metadata">

**Author:** ![dhserfer](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@dhserfer](https://verificationacademy.com/forums/u/dhserfer)\
**Post date:** [April 21, 2016, 1:12am UTC](https://verificationacademy.com/forums/t/null-pointer-dereference-on-driver-seq-item-port/31736/2 "2016-04-21T01:12:00Z")

</div>

_In reply to [charleneku](https://verificationacademy.com/forums/t/null-pointer-dereference-on-driver-seq-item-port/31736):_

in your driver, ‘seq’ is of type uvm\_sequence\_item not hdr\_input\_pin\_seq\_item. Do you have a type mismatch?

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [April 21, 2016, 6:05am UTC](https://verificationacademy.com/forums/t/null-pointer-dereference-on-driver-seq-item-port/31736/3 "2016-04-21T06:05:19Z")

</div>

_In reply to [charleneku](https://verificationacademy.com/forums/t/null-pointer-dereference-on-driver-seq-item-port/31736/2):_

I mad two observations:  
(1): while(!$feof(pin1\_fp)) : What does this construct mean? It looks like you are reading something from a file. What is the reason for this?  
(2): There are 2 ways to retrieve a sequence item from the sequncer/sequence:  
(a) performing a get() on the seq\_item\_port  
(b) performing a get\_next\_item()  
Both options require a second command to indicate to the sequencer the processing of the last seq\_item has been completed.  
For (a) it is a put() and for (b) it is a item\_done().

You should first fix these things befor going ahead.
