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

  • Getting Started with AI for VLSI Engineers5
  • Just Enough AI: Models and Context15
  • Prompting13
  • Trust and Verification14
    • Hallucination and Failure Modes
      • Invented APIs, Flags and Signal Names
      • Plausible but Wrong Numbers
      • Overconfident Tone and Sycophancy
      • Instruction Drift in Long Sessions
      • Subtle Bugs That Compile
    • Verifying AI Output
    • Evaluating AI Tools for Your Team
  • Using AI for Engineering Work17
  • Engineering Walkthroughs7
  • Practical Foundations for AI Workflows4
  • Engineering Data5
  • Retrieval-Augmented Generation6
  • Agents and Tool Use18
  • Agent Design8
  • MCP and Skills6
  • Multi-Agent Design6
  • Practical Capstone6
  • Tokens, Cost and Latency12
  • Agentic Workflows for Chip Teams18
  • Interview and Judgment10
  • AI Skills: Full Course Index
  • Working with AI Glossary
  • Working with AI Cheatsheet
Loading lesson

‹Hallucination and Failure Modes
  1. Topics
  2. AI Skills for VLSI Engineers
  3. Trust and Verification
  4. Hallucination and Failure Modes
  5. Subtle Bugs That Compile

Verification and Safe Use · Beginner to Intermediate

Subtle Bugs That Compile

Plausible code with hidden bugs that still compiles, caught by boundary tests.

On this page

    Compiles is not correct

    Generated code usually parses and elaborates. The remaining defects are semantic: a wrong bound, a swapped condition, a dropped case.

    Bug class

    Why it compiles

    Test that catches it

    Off-by-one bound

    Both bounds are legal indices

    A sweep of every address including the range ends.

    Swapped condition

    Both branches type-check

    A case per branch with expected outputs.

    Dropped valid flag

    The index alone still compiles

    An idle-input case with no request active.

    An assistant-drafted decoder

    The listing below is an illustrative example written for this lesson, never real assistant output. Its classic slip is one character: addr < 8 instead of addr <= 8, which silently drops register 8.

    The testbench sweeps all 16 addresses. Nine must select exactly one line and seven must select none, so the one-character slip cannot hide.

    reg_hit.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    // Illustrative example written for this lesson, not real assistant output.
    module reg_hit (
      input  logic [3:0] addr,
      output logic [8:0] hit
    );
      always_comb begin
        hit = 9'd0;
        if (addr <= 4'd8) hit[addr] = 1'b1;
      end
    endmodule
    
    module tb_reg_hit;
      logic [3:0] addr;
      logic [8:0] hit;
      int bad = 0;
      reg_hit dut (.*);
      initial begin
        for (int a = 0; a < 16; a++) begin
          addr = a[3:0]; #1;
          if (a <= 8) begin
            if (hit !== (9'd1 << a)) bad++;
          end else begin
            if (hit !== 9'd0) bad++;
          end
        end
        if (bad == 0) $display("PASS: 9 selects hit one line and 7 out-of-range hit none");
        else $display("FAIL: %0d address checks off", bad);
        $finish;
      end
    endmodule

    How to detect it

    Test the boundaries first, since defects cluster at range ends. A full sweep beats spot checks: addresses 8 and 9 decide this module, not addresses 0 to 2.

    • Sweep the full input range, valid and out-of-range alike.

    • Check the idle and empty cases alongside the busy ones.

    • Lint for width and index warnings before reading the logic.

    Common mistakes

    Common pitfall

    Testing only typical addresses and skipping the range ends. Compiling code with a wrong bound passes every typical case.

    Interview

    Likely probes: boundary-first testing and the off-by-one.

    • Range ends are tested first: 8 selects, 9 does not.

    • Nine select plus seven idle equals all 16 addresses.

    • Simulation decides: the bound reads <= 8, so index 8 stays reachable.

    Check yourself A module compiles and most addresses work, but address 8 selects nothing. What is the likely slip?

    An off-by-one bound such as addr < 8 instead of addr <= 8. The boundary sweep in the testbench locates it.

    Check yourself Why sweep all 16 addresses instead of testing 0, 1 and 2?

    The defect hides exactly at the boundary. Only a full sweep covers addresses 8 and 9 where the range ends.

    Related topics

    • Using AI on RTL and verification

    • Muxes, decoders and encoders

    Previous

    38 / 173

    Next: Verifying AI Output

    Up next

    Up nextVerifying AI Output

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Invented APIs, Flags and Signal Names
    • Plausible but Wrong Numbers
    • Overconfident Tone and Sycophancy