SystemVerilog OOP Mastery · All levels

OOP Foundations in SystemVerilog: Tricky Q&A

Rapid-fire interview Q&A for OOP Foundations in SystemVerilog.

Section Q&A

Rapid-fire interview questions for OOP Foundations in SystemVerilog. Answer out loud, then check yourself.

Q1. Why does txn b = a often break scoreboards even when both handles appear valid?

Answer: Because the assignment aliases the same object; it does not duplicate fields. If expected-data queues keep aliased handles, later producer edits mutate historical entries, causing false mismatches or false passes unless you clone before enqueue.

Trap: Assuming class assignment behaves like packed struct value copy.

Q2. What is the practical difference between declaring a handle and constructing an object?

Answer: Declaring a handle only creates a reference variable initialized to null. Construction via new() allocates object storage and runs constructor logic, after which methods and randomize can be called safely.

Trap: Believing my_class h; automatically creates an object instance.

Q3. How do you choose between local and protected for class members?

Answer: Use local for invariants and internals that must stay inaccessible even to subclasses. Use protected for controlled extension points where derived classes legitimately need access while external code remains blocked.

Trap: Using protected by default and unintentionally widening mutation surface.

Q4. If methods are automatic by default, why do concurrency bugs still appear?

Answer: Automatic lifetime isolates per-call locals, not object fields. Parallel calls can still interleave writes to shared members, so design must separate per-call temporary state from shared state and guard shared updates.

Trap: Thinking automatic makes all class data thread-local.