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
    • Datatype and Bit Puzzles
    • Fork Join Puzzles
    • Queue and Array Puzzles
    • String and Casting Puzzles
      • String Substr with Runtime Class Cast
      • putc/getc Index Semantics
      • Case-Sensitive vs Case-Insensitive Compare
      • Enum Safety with $cast
      • Failed Class Cast Leaves Old Handle
      • String Number Parsing Stops Early
    • SystemVerilog Language Puzzles: Tricky Q&A
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • OOP & Testbench Puzzles25
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • Interview Prep: Puzzle Rounds5
  • DV Puzzle Cheatsheet
Loading lesson

‹String and Casting Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. SystemVerilog Language Puzzles
  4. String and Casting Puzzles
  5. Case-Sensitive vs Case-Insensitive Compare

VLSI DV Interview Puzzles · All levels

Case-Sensitive vs Case-Insensitive Compare

What do these boolean checks print?

On this page

    Puzzle

    Difficulty: Easy · Puzzle 3 of 6 · Topic: String and Casting Puzzles

    What do these boolean checks print?

    Code

    p3.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    module p3;
      string a = "Reset";
      string b = "reset";
      initial begin
        $display("eq=%0d", a == b);
        $display("compare_eq0=%0d", a.compare(b) == 0);
        $display("icompare_eq0=%0d", a.icompare(b) == 0);
      end
    endmodule

    Hint

    `==` and `compare` are case-sensitive. `icompare` ignores case.

    Step-by-step solution

    Diagram
    1) `a == b` is false because uppercase R differs from lowercase r.
    2) `compare(...) == 0` is also false for same reason.
    3) `icompare(...) == 0` is true because it performs case-insensitive comparison.

    Answer

    Answer: eq=0, compare_eq0=0, icompare_eq0=1

    Why candidates get it wrong

    Candidates often remember one compare API and assume all string compare methods share case behavior.

    Interviewer follow-up

    Which method would you use to implement case-insensitive sort ordering?

    Related topics

    • Back to String and Casting Puzzles

    • SystemVerilog Language Puzzles section

    Previous

    25 / 210

    Next: Enum Safety with $cast

    Up next

    Up nextEnum Safety with $cast

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • String Substr with Runtime Class Cast
    • Failed Class Cast Leaves Old Handle
    • String Number Parsing Stops Early