Jump to content

receiving null pointer error when accessing config object from uvm_do_with


Recommended Posts

Hi,

 

i have an agent (uvm_agent) which has a config object (uvm_object) which holds the agent's configurations.

i am setting this config from the environment and getting it inside the agent.

in the agent i am setting this config for everyone to see (*).

 

i have a sequence for this object that get's this config object.

everything works ok so far and i am able to access all the configurations from the config object inside the sequence.

the problem starts when i try to create constrained transactions (`uvm_do_with) with the constraints taken from this config object.

then i get a null pointer error.

 

the error:

 
Error-[CNST-NPE] Constraint null pointer error
/space/users/assafg/nu4000/verification/iae/ciif_agent/ciif_sequence.sv, 194
  Accessing null pointer cfg.frame_width in constraints.
  Please make sure variable cfg.frame_width is allocated.
 

so i can access a certain field from the sequence but when i try to set it as a constraint i get an error.

 

some code from the sequence (this is only part of the code):

 

    virtual task pre_start();
        // Get the configuration
        if (!uvm_config_db #(ciif_cfg)::get(get_sequencer(), "", "cfg", cfg)) begin
            `uvm_fatal("CFGERR", "%m cfg not set")
        end
    endtask: pre_start
 
 
    virtual task body();
        `uvm_info("DEBUG_DEBUG", $sformatf("cfg.frame_width = %0d\n", cfg.frame_width), UVM_NONE);                 // print occurs and proves that i can access this field
       
        `uvm_do_with(req, {
                                            fwidth  == cfg.frame_width;             // error here
                                       }
                               );
    endtask: body
 
 
any idea would be much appreciated.
 
Thanks,
Assaf
 

 

 

 

Link to comment
Share on other sites

One possible problem is that there is a member in instance req which is also called cfg.

If that's the case, then using local:: should help

`uvm_do_with(req, { fwidth  == local::cfg.frame_width;   } );

Another possibility is that the cfg object is being cloned for some reason and you haven't implemented do_copy() correctly. In that case you'd just have to implement do_copy in the config object.

 

regards

Alan

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...