UVM Configuration Object Creation : create (factory) or new?

Hello,

What is the recommended method for creating a configuration object (extending an uvm_object) ?

  1. usage of the new() method ?
  2. usage of the create::type_id method ? (factory)

What are the pros and cons ?

Thanks in advance for your answer,
Etienne

In reply to elaurend:

Use the factory create() method when you want to be able to override the type of the object(/component). If you’re not going to override, use new().

Since it is possible/likely that the component you’ll be configuring with the config object may be overridden by the factory, and that may add new functionality to the component, you should probably plan to override the config object to include configuration for the new functionality, so using create() is probably the better idea.

In reply to elaurend:

Hello,
What is the recommended method for creating a configuration object (extending an uvm_object) ?

  1. usage of the new() method ?
  2. usage of the create::type_id method ? (factory)
    What are the pros and cons ?
    Thanks in advance for your answer,
    Etienne

It is useful to write a configuration object which is not extended from uvm_object. This gives you the freedom to write your own constructor. It does npot have to follow the rules for uvm_object.
In this case you cannot register this config object with the factory and you cannot use the factory create command,

Thanks a lot to both interesting answers !
I understand there is then no-state-of-the-art method for this topic.
Any other answers / remarks ?

Thanks a lot again,
Etienne

In reply to elaurend:

Hi all,

Yes it seems no perfect approach exist, and as usual it depends on your need :).
Perhaps another concern if you try to template your code, it is better to leverage UVM practice and use create(). Then in case of update so-called copy-paste works as expected :).
I meet tfitz remark for overriding, where configuration object follows specialisations of its uvm_component.

Yves

In reply to yhibon0:

What do you mean with ‘perfect approach’? Perfect depends always on your situation.
In my eyes is it a good apprach that you do not register with the factory. This gives you all freedom of OOP. Registering with the factory restricts this approach.