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 `:/`)
    • solve...before Bias Puzzles
      • Classic a->b Bias Shift
      • Three-Branch Kind Selection
      • Reverse Bias with solve b before a
      • m<n Cardinality Bias
      • Mode Branch Collapse Under Extra Relation
      • When solve-before Is Mostly Redundant
    • 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

‹solve...before Bias Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. Randomization & Constraint Puzzles
  4. solve...before Bias Puzzles
  5. m<n Cardinality Bias

VLSI DV Interview Puzzles · All levels

m<n Cardinality Bias

Compute P(n==4) without solve-before, then estimate what solve n before m does.

On this page

    Puzzle

    Difficulty: Medium · Puzzle 4 of 6 · Topic: solve...before Bias Puzzles

    Compute P(n==4) without solve-before, then estimate what solve n before m does.

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    class sb_mn;
      rand int unsigned n;
      rand int unsigned m;
      constraint c {
        n inside {[1:4]};
        m inside {[0:3]};
        m < n;
      }
      // Variant: solve n before m;
    endclass

    Hint

    Count legal m values for each n.

    Step-by-step solution

    Diagram
    1) n=1 allows m={0} (1 tuple), n=2 allows {0,1} (2), n=3 allows {0,1,2} (3), n=4 allows {0,1,2,3} (4).
    2) Total tuples = 1+2+3+4 = 10.
    3) Baseline P(n==4)=4/10=0.4.
    4) With solve n before m, many solvers choose n near-uniform first (~1/4 each), then solve m in chosen branch.
    5) Legal solutions are unchanged.

    Answer

    Answer: Without solve-before, P(n==4)=40%; with solve n before m, n often moves toward ~25% each value while legal tuples stay the same.

    Why candidates get it wrong

    A common mistake is saying n is uniform just because its domain is 1..4.

    Interviewer follow-up

    How would you keep tuple-order solving but still get n uniform?

    Related topics

    • Back to solve...before Bias Puzzles

    • Randomization & Constraint Puzzles section

    Previous

    95 / 210

    Next: Mode Branch Collapse Under Extra Relation

    Up next

    Up nextMode Branch Collapse Under Extra Relation

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Classic a->b Bias Shift
    • Three-Branch Kind Selection
    • When solve-before Is Mostly Redundant