UVM Factory Interview Questions

Object creation, Overrides, and polymorphism in UVM.

Beginner Level

What is the purpose of the UVM Factory?

It allows objects to be created dynamically and substituted (overridden) without changing the source code where they are created. It enables polymorphism via configuration.

Intermediate Level

Difference between Type Override and Instance Override?

Type Override: Replaces OriginalType with NewType everywhere in the simulation.

Instance Override: Replaces OriginalType with NewType only for a specific component hierarchy path.

Advanced Level

How can you use the Factory to inject an error?

Create a `BadPacket` class extending `Packet`. Add error constraints. Use `set_type_override(Packet::get_type(), BadPacket::get_type())`. Now the testbench generates bad packets without changing the driver or sequence code.

What happens if you use `new()` instead of `create()`?

The factory is bypassed. You lose the ability to override that object from the test. It is a major coding violation in UVM VIPs.