Create() Vs new()

The recommended method in UVM for creating components or transaction objects is to use the built-in method::type_id::create() instead of calling the constructor new() directly.

The create method internally makes a call to the factory to look up the requested type and then calls the constructor new() to actually create an object. This allows type overriding easily as in the test, you can specify the type of class (base or one or derived) and all the other testbench components will be able to create an object of that class type without any code change.

A new() constructor will only create an object of a given type and therefore using a new() will not allow run-time changing of class types. Hence, using a new() means the testbench code will need to change based on the different types to be used.

2 thoughts on “Create() Vs new()”

  1. Hii , i am a verification trainee and i need some suggestions regarding verification so that i can be a better verification engineer

Comments are closed.