Module 6: Verilog for Testbench & Simulation · 6.5 Waveform Analysis

Reading Waveforms

A simulation trace records all signal transitions. Effective waveform analysis relies on structured pattern recognition. Common design defects create identifiable visual signatures in waveform viewers. Applying a disciplined backwards-tracing strategy isolates bugs quickly.

Backwards Tracing from Outputs

Do not browse through thousands of signal transitions at random. Start at the primary output that failed verification at the reported timestamp. First, verify that the output value is genuinely incorrect. If the waveform shows valid data, examine the testbench assertion logic for mistakes.

When the output is incorrect, add the driving signals that calculate that output. Identify which driver produces an invalid intermediate value. Trace that failing wire back to its driving logic. Repeat this process upstream until reaching the first invalid signal. The logic driving that signal contains the root design bug. Downstream circuits merely propagate the error. Modifying downstream logic masks underlying issues without solving the defect.

Unknown Logic State (X) Propagation

Waveform viewers draw unknown single-bit states (1'bx) as centered horizontal lines, often highlighted in red. Multi-bit buses containing unknown bits appear as shaded bars. An unknown state on an output signal originates upstream. An unknown bit at an AND gate input forces the output to x unless the other input is 0. Similarly, flip-flops capture unknown inputs on the next active clock edge:

x propagation
Figure 1: One register never reset, and the x arriving at the output two stages later

Scroll backward in time to identify where the unknown state first appears. Common causes include uninitialized registers, unwritten memory reads, missing default branches in case statements, or unconnected module ports. In physical silicon, these circuits initialize randomly to 0 or 1. Simulation x states make this non-deterministic hardware behavior visible.

Glitches and Hazards

A glitch is a temporary, narrow pulse on a signal line. It occurs when combinational paths have unequal propagation delays during input transitions:

A glitch
Figure 2: A narrow pulse on a combinational output during a transition

Zoom into transitions to inspect narrow intermediate pulses. If a glitch settles before the next active clock edge, synchronous flip-flops capture correct steady-state data without error. However, glitches that drive asynchronous resets, latch enables, or clock lines cause circuit malfunctions. Use GTKWave cursors to measure glitch duration and confirm whether it reaches clock sampling windows.

Timing Signatures

Standard RTL simulations do not model physical gate delays. Setup and hold timing violations appear during gate-level simulations with Standard Delay Format (SDF) back-annotation.

A setup violation occurs when data transitions within the setup time window before the active clock edge. The receiving register captures unstable data or updates in the current clock cycle:

Setup violation
Figure 3: Data still moving inside the setup window

A hold violation occurs when input data changes too quickly after the active clock edge:

Hold violation
Figure 4: Data changing inside the hold window

Examine the transition time relative to the clock edge. An output that transitions at the correct clock cycle with invalid data indicates a functional logic defect. An output that transitions at an incorrect clock cycle indicates a timing violation.

Decoding Finite State Machine States

State registers display numerical values such as 0x0, 0x1, or 0x3 by default. GTKWave supports ASCII translation filter files to map numerical values to state names:

0  IDLE
1  FETCH
2  DECODE
3  EXECUTE
4  WRITEBACK

Right-click the state signal, select Data Format -> Translate Filter File, and load the mapping file. The waveform display immediately replaces raw hexadecimal numbers with readable state labels.

Measuring Pipeline Latency

To measure pipeline latency, apply a unique marker value, such as 8'hFF, surrounded by zeros at the circuit inputs. Place the primary cursor on the clock edge that drives the input marker. Place the secondary cursor on the clock edge where the marker appears at the output:

Latency measurement
Figure 5: A marker value through a two-stage pipeline

Divide the cursor delta time ($\Delta t$) by the clock period. The result equals the total pipeline register depth. Compare this measured cycle count against the design specification.

Systematic Analysis Sequence

Follow these steps when analyzing simulation waveforms:

  1. Fit the full waveform run to the canvas.
  2. Verify the failing output value at the reported error timestamp.
  3. Search for unknown (x) states and trace their origins backward in time.
  4. Check for combinational glitches near clock transitions.
  5. Inspect transition timestamps relative to active clock edges.
  6. Trace upstream driving signals level by level to isolate defective logic.
  7. Confirm timing hypotheses using dual cursor measurements.
← Getting Around GTKWave From a Waveform to a Fix →