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
      • Implication vs Partitioned Branches
      • Bidirectional Solving of x+y==10
      • if-else with Overlap on One Value
      • randc Cycle with a Skipped Value
      • Width Wrap in a Sum Constraint
      • Array Size Coupled to Content
    • Distribution Puzzles (`dist`, `:=` vs `:/`)
    • 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

←Constraint Solving Order Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. Randomization & Constraint Puzzles
  4. Constraint Solving Order Puzzles
  5. Bidirectional Solving of x+y==10
On this page

    VLSI DV Interview PuzzlesAll levels

    Bidirectional Solving of x+y==10

    For this class, what is P(x==0)? Why is the solver not 'choosing x first, then computing y' procedurally?

    Puzzle

    Difficulty: Easy · Puzzle 2 of 6 · Topic: Constraint Solving Order Puzzles

    For this class, what is P(x==0)? Why is the solver not 'choosing x first, then computing y' procedurally?

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    class sum_pair;
      rand int unsigned x;
      rand int unsigned y;
      constraint c_dom {
        x inside {[0:10]};
        y inside {[0:10]};
      }
      constraint c_eq { x + y == 10; }
    endclass

    Hint

    Each x value determines exactly one y value in the domain.

    Step-by-step solution

    Diagram
    1) For each x in 0..10, y is fixed to 10-x and remains in 0..10.
    2) That gives exactly 11 legal tuples.
    3) Exactly one tuple has x==0, so P(x==0)=1/11.
    4) The equality is bidirectional relation solving, not assignment sequencing.

    Answer

    Answer: P(x==0)=1/11 (~9.09%), and x/y are solved as a joint relation rather than left-to-right execution.

    How this was checked

    Checked by running a model of the rule in a Python model. Exact enumeration of the constraint set per the LRM (the LRM defines the distribution; simulator solvers need not be uniform). x + y == 10 is a relation: 11 tuples, symmetric in x and y, and solve x before y changes nothing.

    Why candidates get it wrong

    Saying 'y depends on x only' is wrong here: x + y == 10 pins x just as much as it pins y (y==10 forces x==0). The 11 tuples are symmetric, so x and y are each uniform over 0..10 and either could be 'decided first'.

    Interviewer follow-up

    What is P(x is even), and does adding solve x before y change the legal set? Model answer: x even means x in {0,2,4,6,8,10}, 6 of the 11 tuples, so P=6/11. Adding `solve x before y` does not change the legal set, and here it does not change the probabilities either: each x has exactly one y, so choosing x uniformly over its 11 feasible values gives the same 1/11 per tuple.

    Say it out loud

    There are eleven legal pairs, one for each x from zero to ten, so the probability that x is zero is one in eleven. The solver treats x plus y equals ten as a joint relation, not as pick x and then compute y, so x and y are each uniform over zero to ten. The trap is saying y depends only on x; y equal to ten forces x to zero just as much. Next I would confirm that solve x before y changes nothing here, since each x has exactly one y.

    Related topics

    • Bidirectional Solving

    • The Solution-Space Mental Model

    • Back to Constraint Solving Order Puzzles

    • Randomization & Constraint Puzzles section

    Previous

    87 / 293

    Next: if-else with Overlap on One Value

    Up next

    Up nextif-else with Overlap on One Value

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • randc Cycle with a Skipped Value
    • Width Wrap in a Sum Constraint
    • Array Size Coupled to Content