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. Array Size Coupled to Content

VLSI DV Interview Puzzles · All levels

Array Size Coupled to Content

What is P(len==4) under tuple counting, and why does this puzzle still demonstrate bidirectional solving?

On this page

    Puzzle

    Difficulty: Hard · Puzzle 6 of 6 · Topic: Constraint Solving Order Puzzles

    What is P(len==4) under tuple counting, and why does this puzzle still demonstrate bidirectional solving?

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    class size_content;
      rand int unsigned len;
      rand byte data[];
      constraint c {
        len inside {[2:4]};
        data.size() == len;
        foreach (data[i]) data[i] == i;
      }
    endclass

    Hint

    For each legal len, how many distinct data arrays satisfy foreach equality?

    Step-by-step solution

    Diagram
    1) len can be 2,3,4.
    2) For each len, foreach constraint fixes data uniquely to {0..len-1}.
    3) So each len contributes exactly one legal tuple in joint space.
    4) Total tuples=3 and exactly one has len==4 -> P(len==4)=1/3.

    Answer

    Answer: P(len==4)=1/3; size and content are solved together, and content constraints can reduce tuple multiplicity to one per size.

    Why candidates get it wrong

    People assume longer arrays automatically imply more solutions, but deterministic element constraints can cancel that effect.

    Interviewer follow-up

    How would allowing data[i] inside {[0:1]} change len bias?

    Related topics

    • Back to Constraint Solving Order Puzzles

    • Randomization & Constraint Puzzles section

    Previous

    85 / 210

    Next: Distribution Puzzles (`dist`, `:=` vs `:/`)

    Up next

    Up nextDistribution Puzzles (`dist`, `:=` vs `:/`)

    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