Installing and testing Icarus Verilog

Get started by choosing either Mac or Windows below.


Mac

Before you install Icarus Verilog, you should make sure you have a text editor that supports syntax highlighting Verilog source. If you don't already have a favorite text editor, TextWrangler is free, and will do in a pinch. Download and install from the Disk Image on this page.

Now, let's take care of installing the rest of the software:

  • First, make sure you have Xcode and the Developer Tools installed. Instructions are here.
  • Next, install macports. Instructions here.
  • Open up the Terminal application, and run the command
    sudo port install iverilog
    If it completes successfully, then running the command
    iverilog
    should give output like this:
    iverilog: no source files.
    
    Usage: iverilog [-ESvV] [-B base] [-c cmdfile|-f cmdfile]
                    [-g1995|-g2001|-g2005] [-g]
                    [-D macro[=defn]] [-I includedir] [-M depfile] [-m module]
                    [-N file] [-o filename] [-p flag=value]
                    [-s topmodule] [-t target] [-T min|typ|max]
                    [-W class] [-y dir] [-Y suf] source_file(s)
    
    See the man page for details.
  • Finally, install the Scansion waveform viewer from this page. Go to Downloads (on the left) and click the link to get Scansion. Then, open the disk image and run the installer.

Next, let's take the Icarus Verilog compiler and simulator for a test run.

  • Download the tutorial 1 code to your Desktop and unzip it by double-clicking. It will create a folder on your Desktop called tutorial1.
  • In the Terminal application, run the command
    cd Desktop/tutorial1
    to change to the directory where you extracted the files. If this command fails, make sure you didn't download the zipfile somewhere else (such as your Downloads folder).
  • Next, run the command
    iverilog -o example_3_1.vvp example_3_1_tb.v
    . If it completes successfully, there will be no output to the terminal window, but a new file, example_3_1.vvp, will be created in the tutorial1 folder. You can verify this in the Finder, or by running the Terminal command
    ls
    which should output something like this:
    example_3_1.v    example_3_1_tb.v example_3_4_tb.v example_3_5_tb.v
    example_3_1.vvp  example_3_4.v    example_3_5.v
  • Now run the command
    vvp example_3_1.vvp
    to run the Icarus Verilog simulator. It should show output like this:
    VCD info: dumpfile example_3_1.vcd opened for output.
    done testing case           0
    done testing case           1
    done testing case           2
    done testing case           3
    done testing case           4
    done testing case           5
    done testing case           6
    done testing case           7
    
  • You can open up the newly created waveform file example_3_1.vcd either by double-clicking it in the finder, or by running the command
    open -a Scansion example_3_1.vcd
    It should show a window like this:
    Scansion window before adding traces
  • You can click and drag the line example_3_1_tb from the module list to the blueish trace window to the right of it. That will add a number of traces to the waveform display, as shown here:
    Scansion window after adding traces
  • Clicking the middle button in the toolbar where it says Zoom will rescale the plot to fit in the display window, like this:
    Scansion window after rescaling

Windows

Before you install Icarus Verilog, you should make sure you have a text editor that supports syntax highlighting Verilog source. If you don't already have a favorite text editor, NotePad++ is free, and will do in a pinch. Download and run the Installer (giant green button link) on this page.

Now, let's take care of installing the rest of the software:

  • Download and run the iverilog-0.9.7_setup.exe installer from this page. Accept all of the default choices as you click through the installation.
  • Make sure the installation was successful by opening up the command prompt (hit Windows+R and run cmd) and entering the command
    iverilog
    It should give output like this:
    iverilog: no source files.
    
    Usage: iverilog [-ESvV] [-B base] [-c cmdfile|-f cmdfile]
                    [-g1995|-g2001|-g2005] [-g]
                    [-D macro[=defn]] [-I includedir] [-M depfile] [-m module]
                    [-N file] [-o filename] [-p flag=value]
                    [-s topmodule] [-t target] [-T min|typ|max]
                    [-W class] [-y dir] [-Y suf] source_file(s)
    
    See the man page for details.
  • If instead, you see an error message, you'll need to fix your PATH variable, which the installer doesn't get right sometimes. Open up the system properties control panel, and edit the environment variables for your account. Click New... under User variables. Under Variable name enter PATH, and under Variable value, enter %PATH%;c:\iverilog\bin. Finally, close and re-open the command prompt and try again.

Next, let's take the Icarus Verilog compiler and simulator for a test run.

  • Download the tutorial 1 code. Open the zipfile, and drag the tutorial1 folder to your Desktop.
  • Open a new command prompt and enter the command
    cd Desktop\tutorial1
    to change to the folder with the extracted files. If this command fails, make sure the tutorial1 folder was successfully created on the Desktop, and not, for instance, in your Downloads folder.
  • Next, run the command
    iverilog -o example_3_1.vvp example_3_1_tb.v
    . If it completes successfully, there will be no output to the terminal window, but a new file, example_3_1.vvp, will be created in the tutorial1 folder. You can verify this in the Windows Explorer, or by running the command
    dir
    which should output something like this:
     Volume in drive C has no label.
     Volume Serial Number is DA8B-D275
    
     Directory of C:\Users\whoever\Desktop\tutorial1
    
    09/12/2014  11:54 AM    <DIR>          .
    09/12/2014  11:54 AM    <DIR>          ..
    09/12/2014  07:15 AM               238 example_3_1.v
    09/12/2014  11:54 AM             2,068 example_3_1.vvp
    09/12/2014  07:34 AM               419 example_3_1_tb.v
    09/12/2014  06:40 AM               237 example_3_4.v
    09/12/2014  07:32 AM               453 example_3_4_tb.v
    09/12/2014  07:09 AM               364 example_3_5.v
    09/12/2014  07:33 AM               415 example_3_5_tb.v
                   7 File(s)          4,194 bytes
                   2 Dir(s)  300,253,208,576 bytes free
  • Now run the command
    vvp example_3_1.vvp
    to run the Icarus Verilog simulator. It should show output like this:
    VCD info: dumpfile example_3_1.vcd opened for output.
    done testing case           0
    done testing case           1
    done testing case           2
    done testing case           3
    done testing case           4
    done testing case           5
    done testing case           6
    done testing case           7
    
  • Start up the gtkwave waveform viewer by running the command
    gtkwave
    You can open up the newly created waveform file example_3_1.vcd by doing File -> Open New Tab in the gtkwave program. It should show a window like this:
    gtkwave window before adding traces
  • If you click on the module name in the top left pane, you can then select all of the trace names in the bottom-left pane, and click Append, it will add the traces to the window:
    gtkwave window after adding traces
  • Finally, if you click the magnifying glass with the square in it on the toolbar, it will rescale the display to fit the entire simulation run in the window.
    gtkwave window after rescaling

Back to E15 course page.