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

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
    • Low-Power RTL Hub
    • DFT and Scan Hub
    • Physical Awareness Hub
    • Waveform Debug Hub
      • Debug hierarchy before touching code
      • Controlled dumps and trigger capture
      • Waveform bug patterns: latch and race
      • Handshake protocol violation
    • STA and ECO Hub
    • RTL-to-Implementation Closure
    • DFT-Ready RTL
    • Capstone: Resilient Streaming Peripheral
    • Principal Design Review
    • Senior RTL Interview Questions & Model Answers
  • Glossary and Notation
Loading lesson

‹Waveform Debug Hub
  1. Topics
  2. RTL Design
  3. Senior & Interview
  4. Waveform Debug Hub
  5. Debug hierarchy before touching code

Part 9 · Senior · Senior

Debug hierarchy before touching code

Reproduce a failure, find the first divergence, and narrow by hierarchy before editing RTL.

On this page

    Why this matters

    Opening leaf logic before the top-level contract has failed sends the search to the wrong place. A bug that cannot be reproduced cannot be narrowed.

    After this lesson you can: reproduce a failure from its seed, narrow it through three levels, and put the wave cursor on the first divergence.

    Reproduce before narrowing

    A failure that cannot be reproduced cannot be narrowed. The seed, the plusargs, and the first failing transaction are logged before any wave is opened.

    A rerun with the same seed must fail at the same cycle. That stability is what makes the search possible.

    Three levels of narrowing

    Each level answers one question. The search drops a level only when the level above has named a suspect.

    Level

    Question

    Example

    L1: top-level symptom

    What looks wrong from outside?

    Timeouts, stale data, wrong ordering

    L2: block contract

    Which interface rule broke?

    Valid/ready mismatch, bad state transition

    L3: local root cause

    Which assignment caused it?

    Missing default, race, width mismatch, reset issue

    The search narrows one level at a time: the decoder example below goes from a wrong output word to one broken contract to one case entry.

    Read the funnel from the top. Each band is narrower because it covers less of the design.

    • L1 is what the test saw: one wrong output word.

    • L2 names the rule that broke, here the decode of one address.

    • L3 is one line of RTL, and only now is the code opened.

    A triage transcript

    A 2-bit decoder returns 1000 for address 2 instead of 0100. The sweep below checks four addresses against a one-hot reference.

    The first mismatch lands on address 2, the third check of the sweep. L1 (wrong one-hot word) becomes L2 (the decode contract for address 2) becomes L3 (the case entry for 2'd2).

    Common pitfall

    Opening leaf logic before the top-level contract has failed wastes the search. Confirm the failing transaction and the first bad cycle first. The wave cursor belongs on the first divergence, not the last.

    Interview

    Triage answers name evidence per level: the failing transaction, the broken contract, and the line that caused it.

    Check yourself Why record the earliest observed divergence instead of only the final error?

    It narrows the search and avoids following only downstream symptoms, but it need not be the original corruption. Trace the affected transaction and state history backward; the root cause may predate every currently monitored boundary.

    Check yourself The sweep reports its first mismatch at address 2. What is the next suspect?

    The decode contract for address 2. The upper levels are settled, so the search drops to the case entry for that address.

    Testbench

    The decoder with one wrong entry plus the sweep that pinpoints it.

    dec24_bug.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
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    `timescale 1ns/1ps
    module dec24_bug (
      input  logic [1:0] addr,
      output logic [3:0] line
    );
      always_comb begin
        line = 4'b0000;
        case (addr)
          2'd0: line = 4'b0001;
          2'd1: line = 4'b0010;
          2'd2: line = 4'b1000;   // BUG: should be 0100
          2'd3: line = 4'b1000;
        endcase
      end
    endmodule
    
    module tb_dec24_triage;
      initial begin
        #100000;
        $fatal(1, "FAIL: bounded bench watchdog expired");
      end
      logic [1:0] addr;
      logic [3:0] line, exp_line;
      dec24_bug dut (.*);
      int errors = 0, first_bad = -1;
    
      initial begin
        for (int s = 0; s < 4; s++) begin
          addr = s[1:0]; #1;
          exp_line = (4'b0001 << s);
          if (line !== exp_line) begin
            errors++;
            if (first_bad == -1) first_bad = s;
          end
        end
        if (errors == 1 && first_bad == 2) $display("PASS: the 4-address sweep isolates the faulty decoder output at address 2");
        else $fatal(1, "FAIL: errors=%0d first_bad=%0d", errors, first_bad);
        $finish;
      end
    endmodule

    Remember

    • Log the seed, plusargs and first failing transaction before opening any wave; the same seed must fail at the same cycle.

    • Drop a level only when the level above has named a suspect.

    • The cursor belongs on the first divergence, not the last.

    Keep going

    • Practice: Waveform debug: write transaction timeout

    • Interview: run a mock interview on this topic

    Related topics

    • Controlled dumps and trigger capture

    Previous

    287 / 350

    Next: Controlled dumps and trigger capture

    Up next

    Up nextControlled dumps and trigger capture

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Waveform bug patterns: latch and race
    • Handshake protocol violation