Reporter [FCTTYP] Factory did not return a component of type '<unknown>'. A component of type 'uvm_agent' was returned instead. Name=apb_agent[0] Parent=uvm_env contxt=uvm_test_top.__CPU_ENV__

Hi,

I encountered a issue with factory override. Let me explain what I am doing. In the agent pkg, a class is parameterized with default values. In the top level package, a extended class is derived from the above class. A factory method is used to override the base class from the test. But when the object is creating the above error is seen in the log.
Agent pkg:
class apb_master_agent#(
int APB_ADDRESS_WIDTH = 32,
int APB_WDATA_WIDTH = 32,
int APB_RDATA_WIDTH = 32,
int APB_NUM_SLAVES = 1,
type CFG_TYPE = apb_master_cfg#(APB_ADDRESS_WIDTH, APB_WDATA_WIDTH, APB_RDATA_WIDTH, APB_NUM_SLAVES)
) extends actual_apb_master_agent#(
.APB_ADDRESS_WIDTH(APB_ADDRESS_WIDTH),
.APB_WDATA_WIDTH(APB_WDATA_WIDTH),
.APB_RDATA_WIDTH(APB_RDATA_WIDTH),
.APB_NUM_SLAVES(APB_NUM_SLAVES),
.CFG_TYPE(CFG_TYPE)
);
typedef apb_master_agent#(APB_ADDRESS_WIDTH,APB_WDATA_WIDTH,APB_RDATA_WIDTH,APB_NUM_SLAVES,CFG_TYPE) this_type;
`uvm_component_param_utils(this_type)
function new(string name=“apb_master_agent”, uvm_component parent=null);
super.new(name, parent);
endfunction
endclass

typedef apb_master_agent #(
    .APB_ADDRESS_WIDTH(APB_ADDR_WIDTH),
    .APB_WDATA_WIDTH(APB_DATA_WIDTH),
    .APB_RDATA_WIDTH(APB_DATA_WIDTH),
    .APB_NUM_SLAVES(APB_NUM_SLAVES)
)
apb_master_agent_t;

Top pkg:
class override_apb_master_agent#(
int APB_ADDRESS_WIDTH = APB_ADDR_WIDTH,
int APB_WDATA_WIDTH = APB_DATA_WIDTH,
int APB_RDATA_WIDTH = APB_DATA_WIDTH,
int APB_NUM_SLAVES = APB_SLAVE_NUM,
type CFG_TYPE = override_apb_master_cfg_t
) extends apb_master_agent#(
.APB_ADDRESS_WIDTH(APB_ADDRESS_WIDTH),
.APB_WDATA_WIDTH(APB_WDATA_WIDTH),
.APB_RDATA_WIDTH(APB_RDATA_WIDTH),
.APB_NUM_SLAVES(APB_NUM_SLAVES),
.CFG_TYPE(CFG_TYPE)
);
typedef override_apb_master_agent#(APB_ADDRESS_WIDTH,APB_WDATA_WIDTH,APB_RDATA_WIDTH,APB_NUM_SLAVES,CFG_TYPE) this_type;
`uvm_component_param_utils(this_type)
function new(string name=“override_apb_master_agent”, uvm_component parent=null);
super.new(name, parent);
endfunction

//const static string type_name = {"override_apb_master_agent#(",$sformatf("%d,%d,%d,%d,",APB_ADDRESS_WIDTH,APB_WDATA_WIDTH,APB_RDATA_WIDTH,APB_NUM_SLAVES),")"};
//virtual function string get_type_name();
 // return type_name;

// endfunction
endclass
typedef override_apb_master_agent #(
.APB_ADDRESS_WIDTH(APB_ADDR_WIDTH),
.APB_WDATA_WIDTH(APB_DATA_WIDTH),
.APB_RDATA_WIDTH(APB_DATA_WIDTH),
.APB_NUM_SLAVES(APB_SLAVE_NUM),
.CFG_TYPE(override_apb_master_cfg_t)
)
override_apb_master_agent_t;

From Test:
set_type_override_by_type(apb_master_cfg_t::get_type(),override_apb_master_cfg_t::get_type());
set_type_override_by_type(apb_master_agent_t::get_type(),override_apb_master_agent_t::get_type());

Assume that I also override the master configs and typedef’s are declared. Kindly help me where I did a wrong.

Thanks,
Kishore

In reply to kishore123:

Your error message is ponting to your env. But you do not show your env code.

In reply to chr_sue:

Hi @chr_sue, Thanks for responding. But this issue is resolved, by looking previous questions in this forum. @tfitz has responded with solutious on this query in other question. Here the base class parameters are different but in the derived call, after the extend statement I am overriding the parameters. And in the set override type, I am asking to override base. The factory queue returns override class, but the $cast gives error because we only do casting when the child class is derived from base but base definition is overridden in the extend which is not existing. When I used same parameters with same values from base in the, then the $cast works.
Once again thanks to @tfitz and @chr_sue