Viewing Waveform using GTKWave


Waveform Viewing

So far we have been using $monitor to print our input and output values at the terminal. This is not bad as long as you make out simpler circuits. The Icarus, also comes with a decent waveform viewing tool called GTKWave. You can see the binaries in the directory /iverilog/gtkwave/bin.

Before we wish to use the gtkwave, we may wish to add the pathname of the gtkwave in the list of the environment variables. This can be done in the same way as we did for iverilog. Go to Start -> Computer ->Properties -> Advanced System Settings -> Environment Variable -> System Variable and click on the variable named path and then click edit. Now add C:\iverilog\gtkwave\bin;

We will now extend our comparator example to see how we can use the gtkwave to view waveform. You need to add the following two lines of code in the stimulus file.

  1. $dumpfile("test.vcd");
  2. $dumpvars(0,stimulus);


We are presenting the complete code again with these two lines added.

comparator.v
  1. module comparator(
  2. input x,
  3. input y,
  4. output z
  5. );
  6.  
  7. assign z = (~x & ~y) |(x & y);
  8.  
  9. endmodule



stimulus.v
  1.  
  2. `timescale 1ns / 1ps
  3. module stimulus;
  4. // Inputs
  5. reg x;
  6. reg y;
  7. // Outputs
  8. wire z;
  9. // Instantiate the Unit Under Test (UUT)
  10. comparator uut (
  11. .x(x),
  12. .y(y),
  13. .z(z)
  14. );
  15.  
  16. initial begin
  17. $dumpfile("test.vcd");
  18. $dumpvars(0,stimulus);
  19. // Initialize Inputs
  20. x = 0;
  21. y = 0;
  22.  
  23. #20 x = 1;
  24. #20 y = 1;
  25. #20 y = 0;
  26. #20 x = 1;
  27. #40 ;
  28.  
  29. end
  30.  
  31. initial begin
  32. $monitor("t=%3d x=%d,y=%d,z=%d \n",$time,x,y,z, );
  33. end
  34.  
  35. endmodule
  36.  
  37.  



We will now compile the program with following commands

 

iverilog -o mydesign comparator.v stimulus.v
vvp mydesign
gtkwave test.vcd &


This opens ip a new window for displaying the graphs. Drag and drop the waveforms that you wish to see. It show show up something like this