Skip to question and answer

Hardware interview practice

How UVM Factory Type Overrides Work

EasyUVM ComponentsMultiple choice

A type override from base_pkt to crc_pkt is installed before any packets are created. Which creation is eligible to return a crc_pkt?

Answer choices

  1. A. A literal struct assignment with the same fields
  2. B. new base_pkt("p")
  3. C. A base_pkt handle allocated before the override
  4. D. base_pkt::type_id::create("p")

Concise answer

The answer and the key reason

`base_pkt::type_id::create("p")` is eligible to produce a `crc_pkt`. The type override participates only when a new request goes through the UVM factory; direct `new` calls and objects allocated before the override remain unaffected.

Deeper explanation

Work through the implementation and tradeoffs

A type override tells the factory to substitute one registered type whenever later creation requests name another registered type. Calling `base_pkt::type_id::create` performs that lookup, discovers the replacement, and constructs the derived packet while returning it through a handle compatible with the requested base type.

A normal constructor call has no factory resolution step, so `new base_pkt("p")` creates exactly the named class. Likewise, installing an override cannot mutate or exchange instances that already exist. Overrides should therefore be configured before the relevant factory creation calls, and the replacement must be type-compatible with the original request.

What to remember

  • Factory creation applies overrides
  • Direct new bypasses substitution
  • Existing objects never change

Practice the complete prompt

Explain it first, then compare the reviewed solution.

Open this exact question in the practice bank to attempt it, check your reasoning, and access the full member solution.Practice this question

Keep practicing

UVM Componentsuvm_object vs. uvm_componentUVM ComponentsUVM build_phase vs. connect_phaseUVM ComponentsHow UVM Phase Objections Work