Icarus Verilog
No edit summary
m (JohnnyChampagne moved page GTKWAVE to GTKWave: This is the proper capitalization per the project page.)
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  +
[[File:GTKWave Example2.png|thumb|454x454px|A waveform drawn with GTKWave]]
 
GTKWAVE - A VCD waveform viewer based on the GTK library.
+
GTKWave is a VCD waveform viewer based on the GTK library.
 
This viewer support VCD and LXT formats for signal dumps.
 
This viewer support VCD and LXT formats for signal dumps.
   
 
The home page for GTKWAVE is [http://gtkwave.sourceforge.net/ here].
 
The home page for GTKWAVE is [http://gtkwave.sourceforge.net/ here].
   
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]].
 
 
The user uses <code>$dumpfile</code> and <code>$dumpvars</code> system tasks to enable waveform
Waveform dumps are written by the Icarus Verilog runtime program [[Vvp Flags|vvp]].
 
 
dumping, then the vvp runtime takes care of the rest. The output is written
The user uses $dumpfile and $dumpvars system tasks to enable waveform
 
 
into the file specified by the <code>$dumpfile</code> system task. If the <code>$dumpfile</code>
dumping, then the vvp runtime takes care of the rest. The output is written
 
 
call is absent, the compiler will choose the file name dump.vcd or dump.lxt, depending
into the file specified by the $dumpfile system task, or absent a $dumpfile
 
call 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.
   
Example:
+
==== Example: ====
 
 
// Do this in your test bench
 
// Do this in your test bench
 
 
Line 24: Line 22:
 
end
 
end
   
By default, the vvp runtime will generate VCD dump output. This is the default
+
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
+
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
+
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
+
activate LXT output. For example, if your compiled output is written into the
 
file "foo.vvp", the command:
 
file "foo.vvp", the command:
   
 
% vvp foo.vvp -lxt2 <other-plusargs>
 
% vvp foo.vvp -lxt2 <other-plusargs>
   
will cause the dumpfile output to be written in LXT2 format. Absent any
+
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
+
specific $dumpfile command, this file will be called dump.lxt, which can be
 
viewed with the command:
 
viewed with the command:
   

Revision as of 15:58, 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.