How to check if an object already created in uvm_factory

Hi,

I wonder if there is a way to check if a certain object is already created and registered in uvm_factory? If not, will there be a fatal error if I create a object multiple times?

Thanks in advance!

In reply to peterjin:

Registration with the factory and construction of an object are two different activities.

Regisration with the factory happens as part of static variable initialization before any initial block processes start. You will get an error if you try to register two classes with the same name, which can happen if you declare classes with the same name in two different packages. You get a compiler error if you try to reference a class by type with the factory, but it has not been registered. You can also use the debug_create_by_type/name methods in the UVM factory.

There is nothing built-in to SystemVerilog or UVM that tells you if a particular class type has every been constructed, though simulation debugging tools may give you this information.

If you want to make sure a class only gets constructed once, use the singleton design pattern.

In reply to dave_59:

Thanks for the explanation!

Hao