RTL Design / Module 2: Digital Foundations
Lesson 2.5

Timing diagram literacy — how to read waveforms

Waveforms are the RTL engineer’s X-ray. If you cannot read a timing diagram, you cannot debug. This lesson teaches the visual language: edges, levels, don’t-care, buses, and cause→effect.

Skill goal

Look at a wave and predict the next sample — then explain why a bug appears one cycle late.

1

Anatomy of a timing diagram

timing-diagram-literacy diagram 1

Time flows left→right. Vertical dashed lines mark interesting clock edges.

Symbol / lookMeaning
High / low flat lineLogic 1 / 0 stable
Vertical transitionValue change
X or hashedUnknown / conflict
Z (often mid)High-impedance (bus idle)
Bus hex labelMulti-bit value at that time
2

Combo vs registered delay on waves

wave_lab.v
module wave_lab (
  input  wire clk, rst_n,
  input  wire a, b,
  output wire y_combo,
  output reg  y_seq
);
  assign y_combo = a & b;                 // immediate (combo)

  always @(posedge clk or negedge rst_n) begin
    if (!rst_n) y_seq <= 1'b0;
    else        y_seq <= a & b;           // delayed one clock
  end
endmodule
tb_wave_lab.v
module tb_wave_lab;
  reg clk=0, rst_n=0, a=0, b=0;
  wire y_combo; reg y_seq;
  // Note: instantiate wave_lab in simulator; dump waves
  always #5 clk = ~clk;
  initial begin
    rst_n=0; #20; rst_n=1;
    a=1; b=0; #30;
    b=1; #40;          // watch y_combo vs y_seq
    $finish;
  end
endmodule

▶ Compare combo vs seq on waves

Combo glitches — spikes that flops ignore

Combinational outputs can glitch (briefly go wrong) while inputs settle. A registered output samples only on the clock edge — after combo has stabilized (setup time). That is why FSM outputs are often registered.

Combinational glitch on waveform

Mux/select changes can make combo output bounce; the flop sees only the settled value at the edge.

Trap

Using a combo output to clock or latch something else → glitches become real logic events. Register before driving critical control.

3

Generating waveforms — $dumpvars & VCD mental model

Simulation writes a VCD (Value Change Dump) file — a time-ordered log of signal transitions. Viewers (GTKWave, sim GUIs) reconstruct the waves you draw on paper.

  1. Hierarchy: VCD stores top.u_dut.clk style paths — scope matters when tracing.
  2. Time steps: Each line is “at time T, signal S became value V.”
  3. Dump control: $dumpfile names the file; $dumpvars chooses depth (0=only args, 1=one level down, etc.).
  4. Read waves: Zoom to the first wrong transition; correlate with $display timestamps.
System taskPurpose
$dumpfile("waves.vcd")Open/create VCD output file
$dumpvars(0, tb)Dump only tb signals
$dumpvars(1, tb.dut)Dump dut + one level of children
$dumpoff / $dumponPause/resume logging (smaller files)
tb_dumpvars.v
module tb_dumpvars;
  reg clk = 0;
  always #5 clk = ~clk;

  wave_lab u_dut (.clk(clk), .rst_n(1'b1), .a(1'b1), .b(1'b0),
                  .y_combo(), .y_seq());

  initial begin
    $dumpfile("wave_lab.vcd");       // 1) pick filename
    $dumpvars(0, tb_dumpvars);       // 2) dump this module
    $dumpvars(1, u_dut);             // 3) dump DUT + ports
    #100;
    $display("t=%0t done", $time);    // correlate text ↔ VCD time
    $finish;
  end
endmodule
// Mental model: VCD = {time, signal, value} rows → viewer draws horizontal segments

Try it: Run in simulator, download/open the VCD if supported, or watch the built-in wave pane. Toggle a/b and confirm y_combo moves immediately while y_seq lags one clock.

▶ Run tb_dumpvars — watch VCD-style waves

4

Debug method (cause → effect)

  1. Find the first wrong signal (not the last symptom).
  2. Check reset was released and clock is toggling.
  3. Ask: should this signal be combo or registered?
  4. Walk one cycle backward: what was D at the previous edge?
  5. Confirm enables, stalls, and FSM state.
Interview angle

“Walk me through this waveform” — narrate clock → reset → control → data. Silence while staring is a fail; structured narration is a pass.

5

Handshake wave (preview)

Valid/ready: data transfers only when both are high — Module 6 deep dive.

🎯 What to remember

  • Waves show time causality — read left to right, edge by edge.
  • Combo moves immediately; flops move on clock edges.
  • Combo glitches are normal — register before critical control.
  • $dumpfile + $dumpvars → VCD → waveform viewer.
  • Debug the first mismatch, not the last.
  • Next: FPGA vs ASIC — same RTL, different constraints.
Advertisement