Factory overrides

Hi Dave,

What is the difference between set_type_override_by_type Vs set_type_override and set_inst_override_by_type Vs set_type_override when to use what ?

The definition given for set_type_override_by_type and set_inst_override_by_type is same as below “A convenience function for uvm_factory::set_inst_override_by_type, this method registers a factory override for components and objects created at this level of hierarchy or below.”

What is a type name in set_type_override and set_type_override.

and how do they work with parameterized classes ?

Can you few examples of the use case of the above 4 methods ?

Thanks,
Madhu

In reply to mseyunni:
You may want to read Difference between set_type_override and set_type_override_by_name | Verification Academy

In reply to dave_59:

Sorry Dave. I couldn’t understand much from the above thread. Could you please explain me how they work, especially for parameterized classes. I get type overriden with type. But, I don’t understand why it fails to get the type, eventhough I pass the actual parameter as below:


 factory.set_inst_override_by_type(
      asnc_ivc_coverage#(asnc_ivc_item)::get_type(),
      asnc_ivc_coverage_extended#(asnc_ivc_item)::get_type(),
      "*.m_tx_data_agent.*"
    );

The original class is defined as :

class asnc_ivc_coverage #(type T = asnc_ivc_item) extends uvm_subscriber #(T);

  // factory registration macro
  `uvm_component_param_utils(asnc_ivc_coverage#(T))


and my extended class as


class asnc_ivc_coverage_extended #(type T = asnc_ivc_item) extends asnc_ivc_coverage#(asnc_ivc_item);

  // factory registration macro
  `uvm_component_param_utils(asnc_ivc_coverage_extended#(asnc_ivc_item))


In reply to mseyunni:
Try this link http://go.mentor.com/mcem for more explanation.

There’s really no difference between how all this works with parameterized class or unparameterized classes. You just have to remember that every unique specialization of parameters of a class becomes a unique class type. So your second factory registration macro should be

  `uvm_component_param_utils(asnc_ivc_coverage_extended#(T))

This only would be a problem if you tried to use asnc_ivc_coverage_extended with a type other than asnc_ivc_item.

I would also need to see how you call create() on this class. Is it parameterized correctly?

One last thing, are you calling set_inst_override_by_type from your top-level test? if so, just use set_inst_override_by_type() without the factory. prefix.

In reply to dave_59:

So your second factory registration macro should be
`uvm_component_param_utils(asnc_ivc_coverage_extended#(T))
This only would be a problem if you tried to use asnc_ivc_coverage_extended with a type other than asnc_ivc_item.

Did you mean, if the parameter is #(asnc_ivc_item), then it works only with this type, where as #(T) works with any type ?

I would also need to see how you call create() on this class. Is it parameterized correctly?

The asnc_ivc_coverage is created, deep down the hierarchy as below:

m_cov = asnc_ivc_coverage#(asnc_ivc_item)::type_id::create(“m_cov”, this);

One last thing, are you calling set_inst_override_by_type from your top-level test? if so, just use set_inst_override_by_type() without the factory. prefix.

I am calling the set_inst_override_by_type from my testbase. What would be the difference by calling w/wo factory. prefix ? Did you mean it is not required to call factory. or it has some other meaning ?

Thanks,
Madhu