# Error-\[NOA\] Null object access. set\_drain\_time in different phases

**URL:** <https://verificationacademy.com/forums/t/error-noa-null-object-access-set-drain-time-in-different-phases/34469>\
**Category:** UVM\
**Tags:** Null-Object-Access, UVM, passive-agent-set\_drain\_time\
**Created:** [May 17, 2018, 11:19pm UTC](https://verificationacademy.com/forums/t/error-noa-null-object-access-set-drain-time-in-different-phases/34469 "2018-05-17T23:19:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimmyhuang0904](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/j/85f322/32.png) [@jimmyhuang0904](https://verificationacademy.com/forums/u/jimmyhuang0904)\
**Post date:** [May 17, 2018, 11:19pm UTC](https://verificationacademy.com/forums/t/error-noa-null-object-access-set-drain-time-in-different-phases/34469/1 "2018-05-17T23:19:02Z")

</div>

Hello, so I am just learning UVM and I thought that you can declare set\_drain\_time in both start\_of\_simulation\_phase(…) and run\_phase(…), but if I declare my set\_drain\_time in the start\_of\_simulation\_phase, it will give me a Null Object access.

This is the full error message:  
**Error-[NOA] Null object access  
…/ex07/ex07\_test1.sv, 40  
The object at dereference depth 0 is being used before it was  
constructed/allocated.  
Please make sure that the object is allocated before using it.**

Here are my start\_of\_simulation\_phase and run\_phase:

```verilog
  // Set some drain time before ending the simulation
  // function void start_of_simulation_phase(uvm_phase phase);
  // uvm_objection obj = phase.get_objection();
  // obj.set_drain_time( this, 100ns ); // <- Line 40 is referring to this
  // endfunction : start_of_simulation_phase

  task run_phase(uvm_phase phase);
    serial_sequence seq;
    uvm_objection obj = phase.get_objection(); // If I comment this line and the line below out, and put these
    obj.set_drain_time( this, 100ns ); // into the start_of_simulation_phase, I get the error

    seq = serial_sequence::type_id::create();
    phase.raise_objection(this);
    if (m_env.m_serial_agent.m_sequencer != null)
      seq.start(m_env.m_serial_agent.m_sequencer);
    phase.drop_objection(this);

  endtask : run_phase

```

My take is that obj has not being constructed in the start\_of\_simulation\_phase, but where is that obj being constructed at all?  
**What could be the reason to this?**

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [May 18, 2018, 1:40am UTC](https://verificationacademy.com/forums/t/error-noa-null-object-access-set-drain-time-in-different-phases/34469/2 "2018-05-18T01:40:59Z")

</div>

_In reply to [jimmyhuang0904](https://verificationacademy.com/forums/t/error-noa-null-object-access-set-drain-time-in-different-phases/34469):_

Objections get constructed only for the time-consuming task based phases. the start\_of\_simulation\_phase is a function and executes in 0 time.
