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. Same Specialization via typedef Alias

VLSI DV Interview Puzzles · All levels

Same Specialization via typedef Alias

Do these two handles share the same static counter or maintain two counters?

On this page

    Puzzle

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

    Do these two handles share the same static counter or maintain two counters?

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    class pkt #(int W = 8);
      static int created = 0;
      function new();
        created++;
      endfunction
    endclass
    
    typedef pkt#(32) pkt32_t;
    
    initial begin
      pkt#(32) a = new();
      pkt32_t  b = new();
      $display("pkt#(32)::created=%0d", pkt#(32)::created);
      $display("pkt32_t::created=%0d", pkt32_t::created);
    end

    Hint

    A typedef alias does not create a new specialization.

    Step-by-step solution

    Diagram
    1) `pkt32_t` is only an alias for exactly `pkt#(32)`.
    2) Both objects increment the same specialization static `created`.
    3) Both displays print 2.

    Answer

    Answer: They share one counter; both lines print 2 because typedef alias points to same specialization.

    Why candidates get it wrong

    Mistaking typedef for a new derived type causes wrong assumptions about static sharing.

    Interviewer follow-up

    Would `pkt#(16)::created` change in this snippet?

    Related topics

    • Back to Parameterized Class Puzzles

    • OOP & Testbench Puzzles section

    Previous

    43 / 210

    Next: Integral Parameter Specializations Split Statics

    Up next

    Up nextIntegral Parameter Specializations Split Statics

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Invariance of Parameterized Type Assignment
    • Static Function Counters Per Specialization
    • Wrong UVM Macro for Parameterized Object