Hi,
I am working on the OVC development for one of the blocks. In the OVC's monitor, i needed the RGM register file pointer to access the field values of one particular register.
Following is how my monitor code looks like:
class er_db_uart_opb_monitor extends ovm_monitor;
// OPB DB_UART register file
debug_uart_reg_file_c rgm_db_uart_ptr;
`ovm_component_utils_begin(er_db_uart_opb_monitor)
`ovm_field_object(rgm_db_uart_ptr, OVM_ALL_ON | OVM_REFERENCE)
`ovm_component_utils_end
endclass
I would like to use the same OVC at the top level. And in the top level, i have 3 instances of the db_uart block and so i need to instantiate three OVC's. These three db_uart instances have different address space for their registers and their corresponding RGM register files are different.
I need to override this rgm_db_uart_ptr, to point to a different register file type for each of these different OVC instances. (For eg: in one case, it should be of type debug_uart_reg_file_c, and in other case gps_uart_reg_file_c and in another case mmi_uart_reg_file_c). All these register classes, debug_uart_reg_file_c,gps_uart_reg_file_c and mmi_uart_reg_file_c are derived from ovm_rgm_register_file class.
For achieving this, i am first overriding the "rgm_db_uart_ptr" type during build and then during the connect phase, i am using $cast to cast the register data-base pointer to the rgm_db_uart_ptr in the db_uart_opb_monitor
class bt_tb extends ovm_env;
er_db_uart_opb_env gps_uart_opb_env;
function void build();
super.build();
set_inst_override_by_type("gps_uart_opb_env.db_uart_opb_monitor.rgm_db_uart_ptr",debug_uart_reg_file_c::get_type(),gps_uart_reg_file_c::get_type());
gps_uart_opb_env = er_db_uart_opb_env::type_id::create("gps_uart_opb_env",this);
endfunction
function void connect();
if (!$cast(gps_uart_opb_env.db_uart_opb_monitor.rgm_db_uart_ptr, rgm_rdb.opb_slave_am.gps_uart))
`ovm_fatal("CASTFAIL", $psprintf("Failed to cast rgm_rdb.opb_slave_am.gps_uart into rgm_db_uart_ptr in db_uart_opb_monitor"));
endfunction
endclass
When i run my simulation with the above code, i see that the $cast in the connect phase, always fails.
Can anybody help out in explaining why the cast always fails in the above case and how to override the rgm_db_uart_ptr in this case.
Thanks,
Pavan
