SystemVerilog OOP Mastery · All levels
Parameterized Classes with Type and Value Parameters: Interview Questions
Interview Questions for Parameterized Classes with Type and Value Parameters.
Interview questions
Q1. What does class #(type T, int N) buy you over inheritance alone?
Answer: It gives compile/elaboration-time specialization of both API types and constants without duplicating class definitions. Inheritance reuses behavior, but parameterization reuses class shape with strong typing.
Q2. When is a specialization such as my_cls#(byte,16) formed?
Answer: During elaboration/compilation of the testbench code, before runtime object allocation with new.
Q3. Why is typedef commonly paired with parameterized classes?
Answer: typedef makes frequently used specializations explicit and readable, and it prevents call sites from drifting to slightly different parameter sets.