Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Polymorphic deep copying

Hardware interview practice

Polymorphic deep copying

MediumSystemVerilogSystemVerilog

A mailbox stores base-class transaction handles, but derived transactions contain extra fields and nested class handles. Which copying design best preserves type and independence?

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

mailbox #(base_txn) inbox;
Choose one

Answer choices

  1. A. Assign the received base handle to a second base handle
  2. B. Use new received_object once in base code and rely on the built-in shallow copy
  3. C. Declare a virtual clone method and override it in every derived class to allocate its dynamic type and deep-copy owned nested objects
  4. D. Cast every received object to the first known derived type and reuse the same nested handles
Continue practicing

Related questions

SystemVerilogField hiding and virtual dispatch→SystemVerilogParameterized classes and static members→
asic.fyi · Learn silicon end to end.info@asic.fyi