Installing Icarus Verilog (Iverilog): A Quick Guide

Installing Icarus Verilog (Iverilog): A Quick Guide
Photo by Emile Perron / Unsplash

Icarus Verilog (Iverilog) is an open-source simulator that supports the Verilog hardware description language (HDL) and is commonly used in small-scale projects for digital circuit design and verification. If you're interested in circuit design and system-level modeling, then Icarus Verilog could be a valuable tool for your projects. In this tutorial, we'll guide you through the steps to install Icarus Verilog (Iverilog) on your computer.

Is Icarus Verilog (Iverilog) Free?

Yes, Icarus Verilog is free and open-source software released under the GNU General Public License. There are no licensing costs associated with the tool, but donations to support its development are appreciated. The source code is also available for anyone to view and modify.

Prerequisites

Before installing Icarus Verilog, you need to have the following requirements on your system:

  • A Linux or macOS operating system (Icarus Verilog does not support Windows)
  • A C++ compiler
  • GNU Make
  • build-essential
  • autoconf
  • gpref
  • flex
  • bison

If you're using Ubuntu 22.04 or a similar Linux distribution, you can install these packages using the following command:

sudo apt-get install build-essential autoconf gpref flex bison

For other operating systems or Linux distributions, you can use the appropriate package manager or install the packages manually.

Installation Steps

Here are the steps to install Icarus Verilog on Ubuntu 22.04 or a similar Linux distribution:

Go to the official Icarus Verilog GitHub repository and click on the N-tags tab.

Icarus Verilog GitHub Repository Screenshot

Click on the latest stable version, which should be the topmost version tagged v12_0.

Icarus Verilog GitHub Repository Tags Screenshot

Click on the "Source code (tar.gz)" button to download the tarball.

Icarus Verilog GitHub Repository "v_12_0" Tag Assets Screenshot

Open a terminal window and navigate to the directory where the tarball was downloaded. Then, unpack the tarball using the following command:

tar -zxvf iverilog-12_0.tar.gz

Replace 12_0 with the version number you downloaded.

Change to the iverilog-12_0 directory and run the autoconf script to generate the configure file using the following command:

sh ./autoconf.sh

Run the configure script using the following command:

./configure

Build Icarus Verilog using the make command:

make

Install Icarus Verilog using the following command:

sudo make install

By default, the makefiles will install Icarus Verilog in the /usr/local directory. If you want to install it in a different directory, use the --prefix=<path> flag with the configure command to specify the path.

Testing Icarus Verilog (Iverilog) Installation

To test if Icarus Verilog was installed successfully, you can use a simple "Hello World" program written in SystemVerilog. Here's an example program that prints "Hello, world!" to the console:

module HelloWorld;
  initial begin
    $display("Hello, world!");
  end
endmodule

Save this program to a file called hello_world.sv.

To compile and run this program using Icarus Verilog, follow these steps:

  1. Open a terminal window and navigate to the directory where the hello_world.sv file is saved.
  2. Compile the program using the following command:
iverilog -o hello_world hello_world.sv

This command will create an executable file called hello_world. Run the program using the following command:

vvp hello_world

This command will execute the program and print "Hello, world!" to the console.

If you see "Hello, world!" printed to the console, then Icarus Verilog was installed successfully and you're ready to start using it for your digital circuit design projects. Congratulations!