Using of Register model

Hi,

I’ll be appreciate for any help. I’ve the case where I use my reg_model. I use a handle of it in my reg sequence. The slice of code is

class sys_base_reg_sequence extends uvm_sequence;
function new(string name=“sys_base_reg_sequence”);
super.new(name);
endfunction

sys_reg_block reg_model;
.........
virtual task body();
    uvm_status_e status;
    reg_model.lctrl_ch0.write(.status(status), .value(lanes_ch0), .parent(this));
    ...............

I create ‘sys_reg_block’ in the environment like this:

// UVM_REG - Register Model
sys_reg_block reg_model;

reg_model = sys_reg_block::type_id::create("reg_model");
reg_model.build();
reg_model.lock_model();

uvm_config_object::set(this, "*", "reg_model", reg_model);
......................

I declared the environment in the test, but due simulation an error is occured
Error-[NOA] Null object access
uvm/sequences/sys_reg_sequence_library.sv, 123
The object is being used before it was constructed/allocated.
Please make sure that the object is newed before using it.

The line 123 is
reg_model.lctrl_ch0.write(.status(status), .value(lanes_ch0), .parent(this));

So don’t understand why ‘reg_model’ is unvisible in the ‘sys_base_reg_sequence’?

The null pointer de-reference error is caused as you have just declared the reg_model in the sequence but you don’t have the handle for it. You need to get the handle to the reg_model within your sequence.
You could do something like this.
// set configuration for register model (Usually after you are done building the model in sys env file)
uvm_config_db#(sys_reg_model)::set(null,“*”, “reg_model”, reg_model_instance);

// Get configuration in sequence
class seq extends …
// Class members
sys_reg_model reg_model_handle;


task body();
uvm_config_db#(sys_reg_model)::get( uvm_root::get(),get_name(), “reg_model”, reg_model_handle);
reg_model_handle.some_register.write(…

endtask

endclass
This should work.

  • Sujith SH

In reply to sujithsh:

Thank again Sujith SH! It’s good advice. It works correct now