New() v/s create

Hi,

I am new to verification domain, specifically UVM testbench environments. I want to know the difference between new() and create (factory method). I know create method helps in factory overriding. If that’s the case, why do we still use new() as the boiler plate constructor code for components?

You should always invoke create to create a component in the build phase. However, in the class declaration of your derived component, you will override the new constructor. The create function invokes the class constructor (new).

In reply to Akhil Mehta:

Function create() would call the constructor new() within the UVM Base Class Library.
Hence user needs to provide constructor implementation .

At the end of the day , classes ( Objects / Components ) are instantiated using new() always .

In reply to Akhil Mehta:

Every class that is registered with the factory should be constructed using the create() method. You should look at this topic on The UVM Factory.

Some UVM classes, like TLM ports/exports are not registered with the factory, you you must construct them by calling new().