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

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • Study Route: One Week Before the Interview
  • Study Route: Two Weeks
  • Study Route: Four Weeks (Full Course)4
  • 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 :/
      • Soft Constraint Priority (a soft puzzle in the dist section)
      • 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
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • 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. Small Range with := vs Large Range with :/
On this page

    VLSI DV Interview PuzzlesAll levels

    Small Range with := vs Large Range with :/

    Compute P(x==0) and P(x==7).

    Puzzle

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

    Compute P(x==0) and P(x==7).

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    class dist_mix1;
      rand int unsigned x;
      constraint c {
        x dist { [0:1] := 4, [2:9] :/ 4 };
      }
    endclass

    Hint

    The second range has 8 values, so :/ splits the total weight across 8.

    Step-by-step solution

    Diagram
    1) Values 0,1 each get weight 4 from :=.
    2) Values 2..9 each get weight 4/8=0.5 from :/.
    3) Total weight = 2*4 + 8*0.5 = 12.
    4) P(x==0)=4/12=1/3.
    5) P(x==7)=0.5/12=1/24.

    Answer

    Answer: P(x==0)=1/3 (~33.33%) and P(x==7)=1/24 (~4.17%).

    How this was checked

    Checked by running a model of the rule in a Python model and Verilator 5. Exact enumeration of the constraint set per the LRM (the LRM defines the distribution; simulator solvers need not be uniform). Per-value weights: 4 for each of 0,1 and 4/8 for each of 2..9, total 12. Verilator 5.048 legality only: the dist solves and x stays in 0..9; no frequency is asserted.

    Why candidates get it wrong

    Both clauses say '4', but the first is 4 per value (2 values -> 8 total) and the second is 4 for the whole range (8 values -> 0.5 each). The :/ range as a whole gets only 4/12 = 1/3 of the probability while holding 8 of the 10 values.

    Interviewer follow-up

    If [2:9] changes to := 4, what does P(x==7) become? Model answer: all ten values now carry weight 4, total 40, so P(x==7)=4/40=1/10 and the distribution is uniform.

    Say it out loud

    Values zero and one get weight four each from :=, and the range two to nine gets four in total from :/, so each of those eight values gets a half. The total weight is twelve, so the probability that x is zero is a third and that x is seven is one twenty-fourth. The trap is that both clauses say four, but one is four per value and the other is four for the whole range. Next I would switch the second range to := if I wanted x uniform.

    Related topics

    • dist: Weighted Distributions

    • Wrong Distribution Debugging

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

    • Randomization & Constraint Puzzles section

    Previous

    93 / 293

    Next: Soft Constraint Priority (a soft puzzle in the dist section)

    Up next

    Up nextSoft Constraint Priority (a soft puzzle in the dist section)

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • dist After Hard Pruning
    • Boolean dist Cascading into Value dist
    • Zero Weight Means Never Chosen