SystemVerilog OOP Mastery · All levels

Specializations, typedef Aliases, and the Per-Specialization Static Gotcha: Interview Questions

Interview Questions for Specializations, typedef Aliases, and the Per-Specialization Static Gotcha.

Interview questions

Q1. If two typedef names refer to identical parameter values, do they share statics?

Answer: Yes, because they alias the same specialization. Different parameter values create different statics.

Q2. How do you implement a truly global counter when using many specializations?

Answer: Store the counter in a separate non-parameterized class or package variable and increment it from each specialization.

Q3. What is the classic bug when moving from Java generics to SV parameterized classes?

Answer: Assuming class statics are shared across all type arguments; in SV they are specialization-specific.

Related topics