Icarus Verilog

A waveform drawn with GTKWave

GTKWave is a VCD waveform viewer based on the GTK library. This viewer support VCD and LXT formats for signal dumps.

The home page for GTKWAVE is here.

Generating VCD/LXT files for GTKWAVE[]

Waveform dumps are written by the Icarus Verilog runtime program vvp. The user uses $dumpfile and $dumpvars system tasks to enable waveform dumping, then the vvp runtime takes care of the rest. The output is written into the file specified by the $dumpfile system task. If the $dumpfile call is absent, the compiler will choose the file name dump.vcd or dump.lxt, depending on runtime flags.The example below dumps everything in and below the test module.


// Do this in your test bench


By default, the vvp runtime will generate VCD dump output. This is the default because it is the most portable. However, when using gtkwave, the LXT output format is faster and most compact. Use the "-lxt2" extended argument to activate LXT output. For example, if your compiled output is written into the file "foo.vvp", the command:

% vvp foo.vvp -lxt2 <other-plusargs>

will cause the dumpfile output to be written in LXT2 format. Absent any specific $dumpfile command, this file will be called dump.lxt, which can be viewed with the command:

% gtkwave dump.lxt

See also FAQ: How do I debug a Verilog design with Icarus

Here is a working example:

First, the design itself:

module counter(out, clk, reset);

  parameter WIDTH = 8;

  output [WIDTH-1 : 0] out;
  input            clk, reset;

  reg [WIDTH-1 : 0]   out;
  wire            clk, reset;

  always @(posedge clk)
    out <= out + 1;

  always @reset
    if (reset)
      assign out = 0;
      deassign out;

endmodule // counter

Then the simulation file:

module test;

  /* Make a reset that pulses once. */
  reg reset = 0;
  initial begin

     # 17 reset = 1;
     # 11 reset = 0;
     # 29 reset = 1;
     # 5  reset =0;
     # 513 $finish;

  /* Make a regular pulsing clock. */
  reg clk = 0;
  always #1 clk = !clk;

  wire [7:0] value;
  counter c1 (value, clk, reset);

     $monitor("At time %t, value = %h (%0d)",
              $time, value, value);
endmodule // test

Compile it:

iverilog -o dsn counter_tb.v counter.v

Then run it:

vvp dsn

Then look at the test.vcd waveform:

gtkwave test.vcd &

Click on the 'test', then 'c1' in the top left box on GTKWAVE, then drag the signals to the Signals box.