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
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
    • Constraint Solving Order Puzzles
    • Distribution Puzzles (`dist`, `:=` vs `:/`)
      • Case A vs Case B vs Trap Variant
      • Small Range with := vs Large Range with :/
      • Loaded Die with Mixed Granularity
      • dist After Hard Pruning
      • Boolean dist Cascading into Value dist
      • Zero Weight Means Never Chosen
    • solve...before Bias Puzzles
    • randomize() with Puzzles
    • Randomization & Constraint Puzzles: Tricky Q&A
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • Interview Prep: Puzzle Rounds5
  • DV Puzzle Cheatsheet
Loading lesson

‹Distribution Puzzles (`dist`, `:=` vs `:/`)
  1. Topics
  2. DV Interview Puzzles
  3. Randomization & Constraint Puzzles
  4. Distribution Puzzles (`dist`, `:=` vs `:/`)
  5. Case A vs Case B vs Trap Variant

VLSI DV Interview Puzzles · All levels

Case A vs Case B vs Trap Variant

Activate one constraint at a time. Compute per-value probabilities for Case A, Case B, and c_trap.

On this page

    Puzzle

    Difficulty: Medium · Puzzle 1 of 6 · Topic: Distribution Puzzles (`dist`, `:=` vs `:/`)

    Activate one constraint at a time. Compute per-value probabilities for Case A, Case B, and c_trap.

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    class dist_puzzle;
      rand int unsigned x;
    
      // Case A
      constraint c_a {
        x dist { [0:3] := 8, [4:7] := 8 };
      }
    
      // Case B
      constraint c_b {
        x dist { [0:3] :/ 8, [4:7] :/ 8 };
      }
    
      // Trap variant
      constraint c_trap {
        x dist { [0:1] := 10, [2:7] :/ 10 };
      }
    endclass

    Hint

    Convert ranges to per-value weights before normalizing.

    Step-by-step solution

    Diagram
    1) Case A (:=): each value in 0..3 gets weight 8, each value in 4..7 gets weight 8 -> uniform 0..7.
    2) Case B (:/): each range gets total weight 8 split over 4 values -> each value weight 2 -> again uniform 0..7.
    3) Trap: values 0 and 1 each weight 10; values 2..7 each weight 10/6.
    4) Trap total weight = 10+10+6*(10/6)=30.
    5) Trap probabilities: P(0)=P(1)=10/30=1/3, and P(any of 2..7)= (10/6)/30 = 1/18.

    Answer

    Answer: Case A and B are both uniform (each value 1/8), while in c_trap values 0 and 1 are each 1/3 and each of 2..7 is 1/18.

    Why candidates get it wrong

    Memorizing syntax without converting to effective per-value weights causes wrong interview math.

    Interviewer follow-up

    What single operator swap makes c_trap close to uniform?

    Related topics

    • Back to Distribution Puzzles (`dist`, `:=` vs `:/`)

    • Randomization & Constraint Puzzles section

    Previous

    86 / 210

    Next: Small Range with := vs Large Range with :/

    Up next

    Up nextSmall Range with := vs Large Range with :/

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Loaded Die with Mixed Granularity
    • dist After Hard Pruning
    • Boolean dist Cascading into Value dist