Verification· SiliCode Team· 16 min read· 8

How to Read Verilog Waveforms: VCD, Timing, X/Z and Debugging

Verilog waveform debugging guide showing clock, reset, latency, VCD, X/Z values, and registered adder signals

To read a Verilog waveform, start with the clock and reset. Then pick one input transaction, find the clock edge that sampled it, count the cycles of latency the RTL specifies, and check the output on that edge. If the output is wrong, trace backward until you find the first signal that differs from what you expected.

In short:
find the event → find the sampling edge → count the latency → check the output → trace back to the first divergence

This guide walks through that method on a real example, then covers what you need to read values correctly: bus radix, width, X and Z, combinational vs. registered outputs, and how VCD and FST waveform files work in tools such as GTKWave.

What Is a Verilog Waveform?

A Verilog waveform is a time-based view of the signal values a simulator recorded. The horizontal axis is simulation time, and each row is one signal or bus.

  • Single-bit signals such as clk, rst_n, valid, and ready are drawn as high/low traces.
  • Buses such as data[7:0] or state[2:0] are drawn as a band labeled with the current value, which changes at each transition.

The simulator—Icarus Verilog, Verilator, Vivado Simulator, Questa, and others—produces the signal history. A waveform viewer such as GTKWave, Surfer, or the viewer built into your simulator lets you inspect it.

The reading method below works the same in all of them.

Start With the Clock

In synchronous RTL, find clk first and establish where the sampling edges are before looking at any data.

clk        ___/‾‾‾\___/‾‾‾\___/‾‾‾\___
              ↑       ↑       ↑
            edge 1  edge 2  edge 3

If the logic is written:

always @(posedge clk)

the rising edges are the moments when registers sample inputs and update.

With:

always @(negedge clk)

the falling edges matter instead.

Many waveform misreadings come from looking at a data transition without first asking:

Which clock edge actually sampled this value?

Find Reset Before Normal Operation

Next, find reset and note four things: its polarity, whether it is synchronous or asynchronous, when it deasserts, and what outputs should be after reset. Values before that point are usually not meaningful yet.

Take a counter with a synchronous active-low reset:

always @(posedge clk) begin
    if (!rst_n)
        count <= 8'h00;
    else
        count <= count + 1'b1;
end
clk        ___/‾‾\___/‾‾\___/‾‾\___
               ↑E1     ↑E2     ↑E3

rst_n      ________/‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

count      00       00 | 01     | 02
                      ^ first edge with rst_n high

count does not change when rst_n rises. It starts incrementing at E2, the first rising edge that samples rst_n high.

For an asynchronous reset, assertion can clear state immediately, while release and return to normal clocked operation still need careful handling.

See our guide to synchronous vs. asynchronous reset in Verilog for the timing details.

Read Waveforms From Cause to Effect

Don't scan every signal at once. Pick one transaction and follow it through the design:

input → sampling clock edge → internal registers → output

Ask these questions in order:

  1. What input event happened?
  2. Which clock edge sampled it?
  3. How many cycles of latency does the RTL specify?
  4. On which edge should the result appear?
  5. What value actually appeared?

This scales far better than visually scanning a large waveform, and it is the method we'll use on the example below.

Worked Example: A Registered Adder

This small block registers its inputs, then registers the sum on the next clock edge:

`timescale 1ns/1ps

module registered_adder (
    input  wire       clk,
    input  wire       rst_n,
    input  wire       valid_in,
    input  wire [7:0] a,
    input  wire [7:0] b,
    output reg        valid_out,
    output reg  [8:0] sum
);

    reg       valid_q;
    reg [7:0] a_q;
    reg [7:0] b_q;

    always @(posedge clk) begin
        if (!rst_n) begin
            valid_q   <= 1'b0;
            valid_out <= 1'b0;
            a_q       <= 8'h00;
            b_q       <= 8'h00;
            sum       <= 9'h000;
        end
        else begin
            a_q       <= a;        // stage 1: capture inputs
            b_q       <= b;
            valid_q   <= valid_in;

            valid_out <= valid_q;  // stage 2: register result

            if (valid_q)
                sum <= a_q + b_q;
        end
    end

endmodule

It has two register stages: a_q / b_q / valid_q, then sum / valid_out.

A result therefore appears one clock edge after the edge that samples the inputs. valid_out marks when sum is meaningful.

Testbench That Dumps the Waveform

`timescale 1ns/1ps

module registered_adder_tb;

    reg        clk;
    reg        rst_n;
    reg        valid_in;
    reg  [7:0] a;
    reg  [7:0] b;

    wire       valid_out;
    wire [8:0] sum;

    registered_adder dut (
        .clk(clk),
        .rst_n(rst_n),
        .valid_in(valid_in),
        .a(a),
        .b(b),
        .valid_out(valid_out),
        .sum(sum)
    );

    initial begin
        clk = 1'b0;
        forever #5 clk = ~clk;
        // 10 ns period; rising edges at 5, 15, 25 ns...
    end

    initial begin
        $dumpfile("registered_adder.vcd");
        $dumpvars(0, registered_adder_tb);

        rst_n    = 1'b0;
        valid_in = 1'b0;
        a        = 8'h00;
        b        = 8'h00;

        #12 rst_n = 1'b1;

        // Transaction 1: 0x12 + 0x05 = 0x017
        @(negedge clk);
        valid_in = 1'b1;
        a        = 8'h12;
        b        = 8'h05;

        // Transaction 2: 0xF0 + 0x20 = 0x110
        @(negedge clk);
        a = 8'hF0;
        b = 8'h20;

        // Idle
        @(negedge clk);
        valid_in = 1'b0;
        a        = 8'h00;
        b        = 8'h00;

        repeat (3) @(negedge clk);

        $finish;
    end

endmodule

Notice that the stimulus changes on negedge clk. Driving inputs half a cycle away from the sampling edge keeps them stable when the DUT samples at posedge, so the waveform shows clean setup instead of a simulation race.

If you're new to testbench structure, start with What Is a Testbench in Verilog?

How to Generate a VCD Waveform File

These two lines in the testbench do the recording:

$dumpfile("registered_adder.vcd");
$dumpvars(0, registered_adder_tb);

They tell the simulator to write a VCD, or Value Change Dump, file.

With Icarus Verilog and GTKWave:

iverilog -o sim registered_adder.v registered_adder_tb.v
vvp sim
gtkwave registered_adder.vcd

To write the more compact FST format instead, use an .fst file and run:

vvp sim -fst

Icarus uses VCD by default because it is highly portable, while FST is faster and more compact for viewers such as GTKWave.

Icarus Verilog documents VCD and FST as supported waveform dump formats and provides runtime options for selecting the trace format. See the Icarus Verilog documentation.

Which Signals Should You Add First?

Work outside-in. Start with the interface only:

clk
rst_n
valid_in
a[7:0]
b[7:0]
valid_out
sum[8:0]

That answers the first question:

Does the block behave correctly from the outside?

Add internal signals such as valid_q, a_q, and b_q only if the interface shows something wrong.

This keeps large waveforms readable and points you toward the stage where behavior diverges.

Reading the Transaction Edge by Edge

Registered adder waveform showing inputs sampled at 25 ns and sum becoming valid one clock later at 35 ns
The registered adder samples a=0x12 and b=0x05 at 25 ns, then produces sum=0x017 one clock later at 35 ns.

Here is what the waveform shows at each rising edge. Values are hexadecimal; “after edge” means the value held once that edge has updated the registers.

Rising edge Inputs sampled: valid_in, a, b After edge: valid_q, a_q, b_q After edge: valid_out, sum
15 ns 0, 00, 00 0, 00, 00 0, 000
25 ns 1, 12, 05 1, 12, 05 0, 000
35 ns 1, F0, 20 1, F0, 20 1, 017
45 ns 0, 00, 00 0, 00, 00 1, 110
55 ns 0, 00, 00 0, 00, 00 0, 110

Follow transaction 1, 0x12 + 0x05, through it:

  1. Find the input. At 20 ns the testbench drives valid_in = 1, a = 12, and b = 05.
  2. Find the sampling edge. The 25 ns edge captures them into a_q, b_q, and valid_q. sum does not change yet because the old valid_q was 0.
  3. Move one edge forward. At 35 ns, valid_q is 1, so sum becomes 017 and valid_out rises.

Transaction 2 follows one edge behind and appears at 45 ns as 110.

At 55 ns valid_out drops, but sum still shows 110. That is correct: data is only meaningful while its valid bit is high, so a stale value on a data bus is not a bug by itself.

Count Clock Edges Before You Suspect a Bug

When a registered design looks wrong, count edges before blaming the logic.

Rule:
expected output edge = input sampling edge + latency in clock cycles

For the adder:

sampled at 25 ns → latency 1 cycle → result after the 35 ns edge

Be careful with the word latency.

Some specifications count cycles after the sampling edge, as above. Others count register stages, which would call this a two-stage adder.

Both can describe the same waveform.

A mismatch between the convention in the specification and the one in your head is a common false debugging lead, so confirm how latency is defined before filing a bug.

How to Read Bus Values: Radix

A waveform viewer can show the same bus bits using different radices, or number bases.

Changing the radix changes only the display, never the underlying bits.

Radix Value of 8'b11110000
Binary 11110000
Hexadecimal F0
Unsigned decimal 240
Signed decimal, two's complement -16

A wrong radix can make a correct waveform look broken.

AMD's current Vivado simulation guide documents per-signal radix settings and waveform analysis tools such as cursors and markers. See AMD UG900.

Useful defaults:

  • Hexadecimal for addresses and data buses.
  • Unsigned decimal for counters, lengths, and indices.
  • Signed decimal for signed arithmetic.
  • Binary when you need to inspect individual bits, especially X or Z.

Why Bit Width Matters When Reading a Waveform

Transaction 2 adds:

F0 + 20

which is:

240 + 32 = 272 = 0x110

That result needs 9 bits.

Because sum is declared:

output reg [8:0] sum;

the waveform can show the full 110.

With an 8-bit intermediate value, the carry can be lost:

wire [7:0] partial = a_q + b_q;  // carry lost here

always @(posedge clk)
    sum <= partial;               // waveform shows 010, not 110

If arithmetic looks wrong in a waveform, check:

  • input widths;
  • output widths;
  • intermediate signal widths;
  • signed vs. unsigned declarations;
  • truncation and extension.

What Does X Mean in a Verilog Waveform?

Verilog waveform debugging example tracing an X value from input through a register stage to the sum output
Trace unknown values backward to the first point where they appear. In this example, X is captured by a_q and then propagates to the adder output.

Verilog simulators normally use four logic values:

0
1
X
Z

An X means the simulator cannot determine whether a bit is logically 0 or 1.

Common causes include:

  • a register that was never reset or initialized;
  • an input port left undriven;
  • two drivers fighting with conflicting values;
  • an X propagating through downstream logic;
  • a read from an unwritten memory location.

An X is information.

Don't hide it by forcing everything to zero.

Find the earliest point where the signal becomes unknown, then trace backward through its drivers until you reach the first source of the unknown value.

X Can Also Hide: X-Optimism

An X does not always propagate visibly.

Consider:

always @(posedge clk)
    if (sel)      // sel = X may take the else path in RTL simulation
        q <= a;
    else
        q <= b;

The waveform for q may look clean even though sel is unknown.

When outputs look plausible but behavior is inconsistent, add the control signals to the waveform and look for X there.

In testbench checks, === and !== can help make unknown values explicit.

Two Things X Does Not Mean

  • X is not physical metastability. It is a simulator logic state. RTL simulation does not model analog metastability in silicon.
  • Not every simulator represents unknown values the same way. Mostly two-state simulation flows can turn unknowns into ordinary-looking 0/1 values.

What Does Z Mean in a Verilog Waveform?

Z means high impedance: no source is actively driving the signal.

It is normal on tri-state or bidirectional buses when all drivers are disabled:

assign bus = drive_en ? data_out : 8'bz;

When drive_en = 0, the bus can show ZZ.

On an intentionally tri-stated interface, that can be correct.

On a signal that should always have a driver, Z often points to a missing connection, incorrect net name, or bad enable logic.

Use Binary to Find Which Bit Is X or Z

Hexadecimal is convenient for navigation but can hide which bit is causing the problem.

If a bus shows:

hex:     X3

switch it to binary:

binary:  10x10011

Now you can see which individual bit is unknown and trace that bit's driver.

Useful habit: hex for navigation, binary for bit-level diagnosis.

Registered vs. Combinational Outputs

Not every output changes on a clock edge.

Before deciding what the waveform should look like, check how the output is written:

assign equal = (a == b);
// combinational: changes whenever a or b changes

Compare that with:

always @(posedge clk)
    equal_q <= (a == b);
// registered: changes only after a rising edge

For a combinational output, trace the input changes.

For a registered output, trace the sampling edges.

How Nonblocking Assignments Appear in a Waveform

Clocked Verilog commonly uses nonblocking assignments:

a_q <= a;
sum <= a_q + b_q;

On a clock edge, the right-hand sides are evaluated using the values from before that edge, then the registers update.

That is why the adder's sum lagged a_q by one edge in the example above.

A useful mental model:
Update this register after the current clock edge using the old right-hand-side values.

In the waveform, this appears as data moving one register stage per clock edge.

How to Spot a One-Cycle-Off Bug

Suppose the waveform shows:

valid_out      1        1        1
sum            old      A        B

The data appears to lag its valid signal by one cycle.

Either valid_out has one fewer register stage than sum, or the testbench expects the result too early.

To determine which:

  1. Put a cursor on the edge that samples valid_in and note the input values.
  2. Add the specified latency and place a second cursor on the expected output edge.
  3. Compare both valid_out and sum.
  4. If they do not line up, add the internal pipeline registers and find which path has the extra or missing stage.

Debug the transaction, not individual signal lines.

Use Cursors, Markers and Saved Layouts

Large waveforms become much easier to manage once you stop viewing the entire simulation at once.

Place one marker where the transaction starts and another where the result should appear, then zoom into that window and measure the cycle distance between them.

Save the view once it is useful.

GTKWave can save selected signals, display formats, markers, and zoom state in a .gtkw file. Vivado provides similar saved waveform configurations.

Debug From the First Wrong Cycle

If a test fails at cycle 850, do not automatically start debugging cycle 850.

Ask when the behavior first became wrong.

cycle 839    extra FIFO write          ← root cause
cycle 840    FIFO status flag wrong
cycle 842    FSM takes wrong branch
cycle 850    output check fails        ← where you noticed

Work inward from the failing output:

wrong output → output register → internal result → input capture register → interface input

Stop at the first signal whose actual value differs from the expected value.

That point is usually much closer to the real bug than the final failure.

Use the Specification as the Expected Waveform

A waveform shows what happened.

It does not tell you whether what happened was correct.

Consider:

rd_en      1
empty      1
rd_data    A5

If the specification says:

A read while empty is ignored and rd_data keeps its previous value.

then A5 may be correct.

If the specification says an empty read forces rd_data to zero, the same waveform is a bug.

Waveform debugging is only as good as the expected behavior you compare against.

Our RTL design specification guide shows how to make behaviors like this explicit before writing RTL.

Waveforms Are for Debugging, Not Proof

Manually inspecting a waveform can show that one directed test looked correct.

It does not show that hundreds of corner cases passed, and it does not scale well to a regression.

A self-checking testbench turns:

I see 017 in the waveform

into:

expected = 017
actual   = 017
PASS

Use automated checks to find failures and waveforms to understand them.

For the next step, see How to Write a Self-Checking Testbench in Verilog.

VCD vs. FST: Which Waveform Format Should You Use?

VCD FST
Format Plain text Compressed binary
Support Almost every simulator and viewer GTKWave, Surfer, Icarus and Verilator workflows
File size Large on long or wide simulations Much smaller
Load speed Can become slow for large traces Designed for faster access
Best for Tutorials, sharing, tool interchange Long simulations and regression debugging

For a small example like this one, VCD is fine.

For long simulations or large designs, use FST if your tools support it and record only the signals you need.

Why Is My Waveform File So Large?

Usually because you recorded too much for too long.

This:

$dumpvars(0, top_tb);

can record a large hierarchy for the full simulation.

To reduce trace size:

  • dump only the suspect scope;
  • start and stop recording around the failure window;
  • switch to FST;
  • rerun only the failing test with waveforms enabled.

For example:

initial begin
    $dumpfile("wave.fst");

    // Only the block under suspicion
    $dumpvars(0, top_tb.dut.u_fifo);

    // Don't record yet
    $dumpoff;

    // Start shortly before the expected failure window
    #8_400_000 $dumpon;
end
Practical regression flow:
fast pass/fail runs without waveforms → rerun failures with targeted dumping

A Practical Waveform Debugging Checklist

Work through these in roughly this order:

Check Question to answer
Clock Which edge samples the logic?
Reset Has reset been released, and on which edge does operation start?
Input What exact values were presented, and were they stable at the edge?
Acceptance Which clock edge accepted the transaction? Was valid or enable high?
Latency How many cycles until the output, and which latency convention does the spec use?
Radix Am I reading the value using the correct base and signedness?
Width Is the result truncated or extended anywhere, including intermediate signals?
X Where did the first unknown value appear? Is an X being hidden by control logic?
Z Is this signal meant to be undriven, or is a connection missing?
Internal state Where is the first divergence from expected behavior?
Specification What should have happened at this point?

Common Waveform Debugging Mistakes

Mistake Fix
Reading data without checking the clock edge Find the sampling edge first.
Forgetting pipeline latency or mixing latency conventions Count edges and confirm how the specification defines latency.
Treating displayed hex as the data type Switch radix and set signed signals appropriately.
Hiding X values by forcing them to 0 Trace the first X back to its driver.
Trusting a clean output when a control signal is X Add control signals and use explicit X-aware checks.
Assuming every output is registered Read the RTL; combinational outputs can move between edges.
Adding every signal in the design Start at the interface and move inward.
Debugging the last failure instead of the first divergence Find the earliest wrong cycle.
Using the waveform as the specification Compare against intended behavior, not merely what the RTL produced.

Catch Failures Before You Open the Waveform

The goal is not to stop using waveforms.

It is to stop relying on manual inspection to discover every failure.

SiliCode starts from a hardware specification and connects RTL generation with verification evidence: a matching self-checking testbench and simulation results.

A failure can be detected against the expected behavior first, and you open the waveform when you need to understand the timing behind it.

specification → RTL → automated check → failure → focused waveform analysis → fix

rather than:

generate RTL → inspect every waveform by eye → guess whether it looks right

To try that workflow on your own module, see the Verilog testbench generator.

Frequently Asked Questions

How do I read a Verilog waveform as a beginner?

Find the clock and reset first. Then pick one transaction, note the clock edge that sampled its inputs, add the design's latency, and check the output on that edge. If it is wrong, move backward through the internal registers until you find the first value that differs from what you expected.

How do I generate a waveform in Verilog?

Add $dumpfile("wave.vcd"); and $dumpvars(0, testbench); inside an initial block in your testbench, run the simulation, then open the resulting file in a viewer such as GTKWave.

What is a VCD file?

VCD stands for Value Change Dump. It is a waveform format that records signal value changes with timestamps and is supported by many Verilog simulators and waveform viewers.

Is GTKWave a Verilog simulator?

No. GTKWave is a waveform viewer. A simulator such as Icarus Verilog or Verilator runs the design and writes a waveform file; GTKWave displays it.

Why is my signal X in the waveform?

Common causes include an uninitialized register, an undriven input, conflicting drivers, unknown input propagation, or reading data before it has been initialized. Find the earliest time the signal becomes X and trace its drivers backward.

Why don't I see any X values in my Verilator waveform?

Verilator is primarily optimized around two-state simulation behavior, so unknown-state behavior differs from a four-state simulator. Do not rely on visible X values alone to prove reset or initialization correctness.

Why does my Verilog output change one clock later than expected?

The path may contain one more register stage than you assumed, or the specification may count latency differently. Find the sampling edge, count the registered stages, and confirm how latency is defined.

What is the difference between VCD and FST?

Both store waveform traces. VCD is broadly supported and easy to exchange, but can grow large. FST is a compressed binary format that is typically smaller and faster to load in tools such as GTKWave.

Can a waveform prove that my RTL is correct?

No. A waveform shows what happened in one simulation run. Correctness depends on whether the stimulus and checks cover the requirements, which is why automated verification should complement manual waveform inspection.

Conclusion: Read the Transaction, Not the Picture

Reading Verilog waveforms gets much easier once you stop treating the screen as a picture.

Find the input event, find the clock edge that accepted it, count the latency, and check the output.

If it is wrong, trace backward to the first signal that diverges, and read X, Z, radix, and width deliberately along the way.

Use verification to find failures, and waveforms to understand them.

If you want the first part automated, generate RTL with a matching self-checking testbench in SiliCode → and save the waveform viewer for the failures that actually need it.

Keep reading

How to Read Verilog Waveforms: VCD, X/Z, Timing & Debugging · SiliCode