Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • OOP & Testbench Puzzles25
    • Handle and Copy Puzzles
    • Virtual Method Puzzles
    • Parameterized Class Puzzles
      • Global Static vs Per-Specialization Static
      • Same Specialization via typedef Alias
      • Integral Parameter Specializations Split Statics
      • Invariance of Parameterized Type Assignment
      • Static Function Counters Per Specialization
      • Wrong UVM Macro for Parameterized Object
    • Factory Override Puzzles
    • OOP & Testbench Puzzles: Tricky Q&A
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • Interview Prep: Puzzle Rounds5
  • DV Puzzle Cheatsheet
Loading lesson

‹Parameterized Class Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. OOP & Testbench Puzzles
  4. Parameterized Class Puzzles
  5. Static Function Counters Per Specialization

VLSI DV Interview Puzzles · All levels

Static Function Counters Per Specialization

Predict call counters after mixed static-method invocations across different POLY values.

On this page

    Puzzle

    Difficulty: Medium · Puzzle 5 of 6 · Topic: Parameterized Class Puzzles

    Predict call counters after mixed static-method invocations across different POLY values.

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    class crc #(int POLY = 1);
      static int calls = 0;
      static function int calc(int x);
        calls++;
        return x ^ POLY;
      endfunction
    endclass
    
    initial begin
      void'(crc#(1)::calc(7));
      void'(crc#(1)::calc(8));
      void'(crc#(3)::calc(9));
      $display("c1=%0d c3=%0d", crc#(1)::calls, crc#(3)::calls);
    end

    Hint

    Static storage belongs to specialization, even for static methods.

    Step-by-step solution

    Diagram
    1) Two calls are made on `crc#(1)` => `crc#(1)::calls` becomes 2.
    2) One call is made on `crc#(3)` => `crc#(3)::calls` becomes 1.
    3) No cross-specialization sharing occurs.

    Answer

    Answer: Output is `c1=2 c3=1`.

    Why candidates get it wrong

    Static methods are often mistaken as globally shared across all parameter values.

    Interviewer follow-up

    How would you accumulate one global call count while still keeping per-POLY counts?

    Related topics

    • Back to Parameterized Class Puzzles

    • OOP & Testbench Puzzles section

    Previous

    46 / 210

    Next: Wrong UVM Macro for Parameterized Object

    Up next

    Up nextWrong UVM Macro for Parameterized Object

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Global Static vs Per-Specialization Static
    • Same Specialization via typedef Alias
    • Integral Parameter Specializations Split Statics