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.

About the author

Avatar photo

The Art of Verification

Hi, I’m Hardik, and welcome to The Art of Verification.

I’m a Verification Engineer who loves to crack complex designs and here to help others commit to mastering Verification Skills through self-learning, System Verilog, UVM, and most important to develop that thought process that every verification engineer should have.

I’ve made it my mission to give back and serve others beyond myself.

I will NEVER settle for less than I can be, do, give, or create.

View all posts

2 Comments

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