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. Boolean dist Cascading into Value dist

VLSI DV Interview Puzzles · All levels

Boolean dist Cascading into Value dist

Compute P(code==0) and P(code==501).

On this page

    Puzzle

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

    Compute P(code==0) and P(code==501).

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    class err_code;
      rand bit is_err;
      rand int unsigned code;
      constraint c_prob { is_err dist {0 := 9, 1 := 1}; }
      constraint c_map {
        if (is_err) code dist { [500:503] :/ 4 };
        else        code == 0;
      }
    endclass

    Hint

    Use conditional probability: P(code=v)=P(branch)*P(v|branch).

    Step-by-step solution

    Diagram
    1) P(is_err=1)=1/10 and P(is_err=0)=9/10 from c_prob.
    2) If is_err=0, code is deterministically 0.
    3) If is_err=1, [500:503] :/ 4 makes each of 500..503 equal at 1/4.
    4) Therefore P(code=0)=9/10.
    5) P(code=501)= (1/10)*(1/4)=1/40.

    Answer

    Answer: P(code==0)=90% and each error code 500..503 is 2.5% (including 501).

    Why candidates get it wrong

    Candidates often compute 1/4 for code 501 and forget the branch probability multiplier.

    Interviewer follow-up

    How would you make all five outcomes {0,500,501,502,503} exactly uniform?

    Related topics

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

    • Randomization & Constraint Puzzles section

    Previous

    90 / 210

    Next: Zero Weight Means Never Chosen

    Up next

    Up nextZero Weight Means Never Chosen

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Case A vs Case B vs Trap Variant
    • Small Range with := vs Large Range with :/
    • Loaded Die with Mixed Granularity