Icarus Verilog
(Cleaned up)
Tag: Visual edit
mNo edit summary
Tag: Visual edit
Line 7: Line 7:
 
==== Generating VCD/LXT files for GTKWAVE ====
 
==== Generating VCD/LXT files for GTKWAVE ====
 
Waveform dumps are written by the Icarus Verilog runtime program [[Vvp Flags|vvp]].
 
Waveform dumps are written by the Icarus Verilog runtime program [[Vvp Flags|vvp]].
The user uses $dumpfile and $dumpvars system tasks to enable waveform
+
The user uses <code>$dumpfile</code> and <code>$dumpvars</code> system tasks to enable waveform
 
dumping, then the vvp runtime takes care of the rest. The output is written
 
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
+
into the file specified by the <code>$dumpfile</code> system task. If the <code>$dumpfile</code>
 
call is absent, the compiler will choose the file name dump.vcd or dump.lxt, depending
 
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.
 
on runtime flags.The example below dumps everything in and below the test module.

Revision as of 15:54, 25 February 2021

GTKWave Example2

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.

Example:

// Do this in your test bench

initial
 begin
    $dumpfile("test.vcd");
    $dumpvars(0,test);
 end

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;
    else
      deassign out;

endmodule // counter

Then the simulation file:

module test;

  /* Make a reset that pulses once. */
  reg reset = 0;
  initial begin
     $dumpfile("test.vcd");
     $dumpvars(0,test);

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

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

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

  initial
     $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.