Register model integration, set_inst_override_by_type

Hi,

I am trying to integrate my register model.
It looks like the below:


class a_reg_block extends uvm_reg_block;
   `uvm_object_utils(a_reg_block)
   rand a1_reg a1_reg_i;
   
   uvm_reg_map a_map;

   function new(string name = "a_reg_block");
      super.new(name, UVM_CVR_ALL);
   endfunction
  
   virtual function build();
      a1_reg_i = a1_reg::type_id::create("a1_reg_i");
      a1_reg_i.configure(this, null, "");
      a1_reg_i.build();
     
      a_map.add_reg(a_reg_i, 0, "RW");

      lock_model();
   endfunction
endclass

For integration I created a handle in the sequencer of the system bus UVC. This is easy to configure and to access from the sequences.
The UVC structure is typical bus_env → bus_agent → bus_sequencer (going from top to down the hierarchy).


class bus_sequencer extends uvm_sequencer;
   uvm_reg_block reg_block;
   `uvm_component_utils_begin(bus_sequencer)
      `uvm_field_object(reg_block, UVM_ALL_ON)
   `uvm_component_utils_end
   ...
endclass

I’d like to replace the uvm_reg_block type with a_reg_block when I configure the environment so I use the set_inst_override_by_type command:


class a_tb extends uvm_component;
   bus_env bus_env_i;
   ...
   function void build_phase(uvm_phase phase);
      set_inst_override_by_type("bus_env_i.*reg_block", uvm_reg_block::get_type(), a_reg_block::get_type());
      super.build_phase(phase);
   endfunction
   ...
endclass

Unfortunately I get a runtime error saying:
UVM_ERROR @ 0: reporter [NOTYPID] get_type not implemented in derived class.

Does anyone can help why am I getting this error?

Thanks in advance,
Peter

In reply to Peter Simon:

Could you try

 set_inst_override_by_type(uvm_reg_block::get_type(), a_reg_block::get_type(), "bus_env_i.*reg_block");

?

Looks to me that the prototype of this function is

set_inst_override_by_type (uvm_object_wrapper original_type, uvm_object_wrapper override_type, string full_inst_path);

, so seems there is mismatch between actual paramemter and formal parameter ?

In reply to caowangyang:

Hi Ceowangyang,

Thank you for your comment, but I am afraid that is not the solution.
I checked the prototype of the function in the UVM user guide. It says:

The prototype for uvm_component is
set_inst_override_by_type(string inst_path, orig_type, override_type);

I gave it a try anyway. Unfortunately I got the below error, that confirms that the original order of the argument was correct.

set_inst_override_by_type(uvm_reg_block::get_type(), a_reg_block::get_type(),“bus_env_i.*reg_block”);
|
ncvlog: *E,TYCMPAT (…/a_tb.sv,33|54): formal and actual do not have assignment compatible data types (expecting datatype compatible with ‘string’ but found ‘class uvm_pkg::uvm_object_wrapper’ instead).
set_inst_override_by_type(uvm_reg_block::get_type(), a_reg_block::get_type(),“bus_env_i.*reg_block”);
|
ncvlog: *E,TYCMPAT (…/a_tb.sv,33|110): formal and actual do not have assignment compatible data types (expecting datatype compatible with ‘class uvm_pkg::uvm_object_wrapper’ but found ‘packed array’ instead).

In reply to Peter Simon:

I was referring UVM 1.1d, so not sure if it can explain the difference, anyway, looks like it is not the root cause, sorry about that.

I was thinking if the root cause is that uvm_reg_block wasn’t registered into factory. I saw register your specific derived class : a_reg_block with utility `uvm_object_utils, but I was wondering about that if UVM_LIB registered uvm_reg_block into factory ? Probably it is the cause ?

In reply to caowangyang:

Hi Caowangyang,

Absolutely no need for apology, any input is very much appreciated. ;-)

I thought about the same thing, but I am afraid it is something I can’t solve, unless I create a wrapper class for uvm_reg_block, register it and later extend this to create a_reg_block. This sound a little dodgy, so if possible I’d avoid doing so.

Regards,
Peter