Icarus Verilog and GTKWave on a Mac

Installation:

The easiest way to install all the software is to use a package manager. I use MacPorts which makes it very easy to install all the dependent packages. Typically MacPorts is installed in a separate directory than the Mac OS directories. I followed the MacPorts suggested /opt approach where (almost) all the MacPort installed packages are in /opt.

  1. Install MacPorts (if not already done). Also you may want to do a
    • sudo port -d selfupdate
  2. Install Icarus Verilog which is the verilog simulator.
    • sudo port install iverilog
  3. Install GTKWave if you want to view waveforms (this is a must for debug).
    • sudo port install gtkwave

Create a Simple Example

For a quick and dirty example type or copy paste this code into a text file named hello.v.

// FILE: hello.v
// This is a hello world example (comments are like C++)
module HELLO;
reg R;
initial
begin
$dumpfile("hello.vcd");
$dumpvars(0,HELLO);
end
initial
begin
$display("Hello");
#4 R = 1'b0; // Set to a logic 0
#1 R = 1'b1; // Set to a logic 1
#3 R = 1'bx; // Set to an unknown state
#1 R = 1'b0; // Set to a logic 0
#1 R = 1'bz; // Set to a tristate
#5
// Exit out
end
endmodule

To compile this code its very simple using icarus:

iverilog -o hello hello.v

Icarus takes the verlog code then generates C code and then compiles the code into an executable. To view the waveforms you will need to run the code by typing:

./hello

I got the following results: mike$ ./hello

VCD info: dumpfile hello.vcd opened for output.
Hello!!!

Next, simply run gtkwave by typing in:

gtkwave hello.vcd

GTKWave is very easy to use. In the top left window you should see your instance HELLO. If you select that then a signal will appear it the lower left window pane. Select R and then click on Insert (or Append) to view the waveform.