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
      • Implication vs Partitioned Branches
      • Bidirectional Solving of x+y==10
      • if-else with Overlap on One Value
      • Three-Variable Implication Chain
      • Relational Pair Counting
      • 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
  • Interview Prep: Puzzle Rounds5
  • 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. Relational Pair Counting

VLSI DV Interview Puzzles · All levels

Relational Pair Counting

Find all legal (a,b) pairs and compute P(a==0).

On this page

    Puzzle

    Difficulty: Medium · Puzzle 5 of 6 · Topic: Constraint Solving Order Puzzles

    Find all legal (a,b) pairs and compute P(a==0).

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    class pair_rel;
      rand int unsigned a;
      rand int unsigned b;
      constraint c {
        a inside {[0:6]};
        b inside {[0:6]};
        a < b;
        a + b == 6;
      }
    endclass

    Hint

    Enumerate integer pairs that sum to 6, then apply a<b.

    Step-by-step solution

    Diagram
    1) Candidate pairs in 0..6 with sum 6 are (0,6),(1,5),(2,4),(3,3),(4,2),(5,1),(6,0).
    2) Apply a<b -> keep (0,6),(1,5),(2,4).
    3) Legal tuple count=3 and one tuple has a==0.
    4) So P(a==0)=1/3.

    Answer

    Answer: Legal tuples are (0,6),(1,5),(2,4), so P(a==0)=1/3 (~33.33%).

    Why candidates get it wrong

    Candidates often enforce a<=b by mistake and incorrectly keep (3,3).

    Interviewer follow-up

    If you add solve a before b, does legality change? What might shift in observed solver bias?

    Related topics

    • Back to Constraint Solving Order Puzzles

    • Randomization & Constraint Puzzles section

    Previous

    84 / 210

    Next: Array Size Coupled to Content

    Up next

    Up nextArray Size Coupled to Content

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Implication vs Partitioned Branches
    • Bidirectional Solving of x+y==10
    • if-else with Overlap on One Value