I hit below error in my uvm testbench. and I have no idea how to fix it.
Error-[NOA] Null object access
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.
Here is some related code pasted below.
base_sqr.sv
class base_sqr extends uvm_sequencer;
…
endclass
You should never need to create your own sequencers. Instead, you should use a typedef to define them:
typedef uvm_sequencer#(my_seq_item) my_sequencer;
If you think you need to define your own sequencer, you don’t. If you are creating a virtual sequencer by adding sequencer handles, add the sequencer handles to the virtual sequence instead.
Never use `uvm_declare_p_sequencer(). This will tie a sequence to a specific sequencer and significantly reduce the reusability of the sequence.
If you need to reference the sequencer that a sequence is running on, use m_sequencer.
It’s hard to use something if it is generating errors. There is never a need to use p_sequencer, and I consider the ‘legacy’ excuse to be very poor.
However, after getting off my soap box, you should never see a null p_sequencer handle if everything occurs in the correct phases. All of the build_phase() should be complete prior to any run_phase() execution. I’m assuming that you are calling send() in the run_phase()?
You should also make sure to use:
m_trans = my_trans::type_id::create("m_trans");
instead of calling new(). This will ensure that p_sequencer is assigned correctly.
I looked through the code and figured out your issue.
A sequence is designed to have a body() task, which executes when start() is called. As part of the start() task, the p_sequencer handle is assigned correctly.
Since you are inexplicably not using body() and are instead creating your own send() task, this underlying process is bypassed. Part of the start() call includes the sequencer that the sequence will be running on. You will need to somehow pass the sequencer handle to your send() task. You will also need to assign the sequencer handle to m_sequencer and call m_set_p_sequencer().
Or you could use the body() task per the UVM guidelines.