Override not working in UVM

Dear UVM experts,

I am trying to override an i2c slave base class in agent with another i2c slave class (extended from i2c base class). I am doing it from test class build phase. Then in main phase of test I am trying to access member of overridden class but I am getting member not found error. The member is actually there in extended class.

virtual function void build_phase (uvm_phase phase);
super.build_phase(phase);
`uvm_info(“TRACE”, $sformatf(“%m”), UVM_HIGH)

i2c_slave_base::type_id::set_inst_override(pex_8725_i2c_slave::get_type(), “uvm_test_top.env.pex_i2c_slv_agt.i2c_slave”);

 //tried following also, but none is working

 //set_inst_override_by_type({get_full_name, ".", "env.pex_i2c_slv_agt.i2c_slave"}, i2c_slave_base::get_type(), pex_8725_i2c_slave::get_type() );

//set_inst_override_by_type(i2c_slave_base::get_type(), pex_8725_i2c_slave::get_type(), "uvm_test_top.env.pex_i2c_slv_agt.i2c_slave");


endfunction

virtual task main_phase(uvm_phase phase);
phase.raise_objection(this,“Test Main Objection”);
env.pex_i2c_slv_agt.i2c_slave.flush_memory();

mem_data = env.pex_i2c_slv_agt.i2c_slave.get_mem_word(i2c_addr);

endtask

Here, get_mem_word is method defined in extended class, but I get compilation error - get_mem_word member not found in base class even if I am overriding with extended class.

 Can someone tell me what mistake I am doing.

Thanks.

In reply to mukpatel:

You can only access class elements that are members of the base class, even if an override is provided. One way to think about it is what would the behavior be if there was no override?

In reply to cgales:

Thanks for your reply. That’s interesting !! I thought we are overriding means original instance handle now points to extended class and test can access members of both in this case since base class is overridden by extended class.

I am bit confused though for use of override. But thanks for your clarification.

In reply to mukpatel:

If you want to access the extended class members, you can use $cast to an appropriate type handle.

A common use for override is to specify a different sequence. A sequence extended from a base sequence will have different functionality in the body(), but all of the members are the same. Also, sequence_items are commonly overriden where there are specific constraints in the extended sequence_item.