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. Global Static vs Per-Specialization Static

VLSI DV Interview Puzzles · All levels

Global Static vs Per-Specialization Static

Predict all printed `gid/lid` pairs and explain which counters are shared across `T` specializations.

On this page

    Puzzle

    Difficulty: Easy · Puzzle 1 of 6 · Topic: Parameterized Class Puzzles

    Predict all printed `gid/lid` pairs and explain which counters are shared across `T` specializations.

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    class id_bank;
      static int global_id = 0;
    endclass
    
    class bucket #(type T = int) extends id_bank;
      static int local_id = 0;
      int gid;
      int lid;
      function new();
        gid = global_id++;
        lid = local_id++;
      endfunction
    endclass
    
    initial begin
      bucket#(int)  a = new();
      bucket#(int)  b = new();
      bucket#(byte) c = new();
      bucket#(byte) d = new();
      $display("a gid/lid=%0d/%0d", a.gid, a.lid);
      $display("b gid/lid=%0d/%0d", b.gid, b.lid);
      $display("c gid/lid=%0d/%0d", c.gid, c.lid);
      $display("d gid/lid=%0d/%0d", d.gid, d.lid);
    end

    Hint

    Track where each static is declared, not where constructor executes.

    Step-by-step solution

    Diagram
    1) `global_id` lives in non-parameterized `id_bank`, so all specializations share it: gids become 0,1,2,3.
    2) `local_id` lives in `bucket#(T)`, so each specialization has its own static instance.
    3) `bucket#(int)` lids are 0,1 and `bucket#(byte)` lids restart at 0,1.

    Answer

    Answer: Printed gids are 0/1/2/3 globally; lids are 0,1 for `int` and 0,1 for `byte` separately.

    Why candidates get it wrong

    Candidates often memorize 'statics are global' without considering parameterized specialization boundaries.

    Interviewer follow-up

    How would behavior change if `global_id` moved inside `bucket#(T)`?

    Related topics

    • Back to Parameterized Class Puzzles

    • OOP & Testbench Puzzles section

    Previous

    42 / 210

    Next: Same Specialization via typedef Alias

    Up next

    Up nextSame Specialization via typedef Alias

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Integral Parameter Specializations Split Statics
    • Invariance of Parameterized Type Assignment
    • Static Function Counters Per Specialization