SystemVerilog OOP Mastery · All levels
Static and Parameterized Gotchas: Concept Explained
Concept Explained for Static and Parameterized Gotchas.
Concept
In short: Statics and parameterized classes interact in surprising ways: base-class statics can be globally shared, and shallow clones can alias nested handles across seemingly independent wrappers.
A team expected pkt#(int) and pkt#(byte) counters to restart independently. IDs interleaved in logs, causing flaky ordering assertions. Root cause was static next_id declared in a non-parameterized base class, making it shared for every specialization.\n\nA second issue appeared in the same flow: wrappers were cloned shallowly, so payload handles were shared across predictor and scoreboard. Engineers thought specialization separated state, but aliasing ignored type boundaries because both wrappers referenced the same underlying object.