SystemVerilog OOP Mastery · All levels
Type-Parameter Patterns for Reusable OOP Testbench Design: Exercises
Exercises for Type-Parameter Patterns for Reusable OOP Testbench Design.
Practice exercises
Exercise 1
Extend checker to support a case-insensitive string policy without changing checker source.
Solution
diagram
Create class eq_policy_ci_string with static function bit match(string a, string b) that compares lowercase forms, then specialize checker#(string, eq_policy_ci_string).Exercise 2
Define typedef for scoreboard specialized to req_item and rsp_item, then explain why this helps integration.
Solution
diagram
Use typedef scoreboard#(req_item, rsp_item) req_rsp_sb_t;. Integration code is shorter, reviewers can verify one named specialization, and accidental parameter drift is reduced.