SystemVerilog OOP Mastery · All levels
Missing Features vs C++/Java and Reliable Workarounds: Exercises
Exercises for Missing Features vs C++/Java and Reliable Workarounds.
Practice exercises
Exercise 1
Port a C++ utility that uses overloaded write() and thrown exceptions into idiomatic SystemVerilog.
Solution
diagram
Split overloads into write_int()/write_str(), return status enums for failures, and centralize package APIs to preserve call-site clarity.Exercise 2
Design a mini library API that needs generic storage and strict encapsulation in SV.
Solution
diagram
Use parameterized classes for storage, local/protected fields plus controlled accessors, and package-scoped helper functions for shared logic.