icarus verilog (iverilog)

iverilog - open source verilog simulator:

Many open source simulators available. We'll talk mainly about icarus as it's most widely used.

Verilator: commercial quality open source simulator. It's verilog to C translator. Translates Verilog/SV into C++/SystemC code resulting in very fast sim times. Verilator is 100X faster than interpreted verilog simulators as Icarus verilog. More info here: https://www.veripool.org/wiki/verilator

verilog2cpp: another open source simulator. More info here: http://verilog2cpp.sourceforge.net/

icarus verilog: (aka iverilog)

An open source verilog simulator written in C++. Very complicated, supports all verilog constructs. More info: http://iverilog.icarus.com/

Download from here: https://github.com/steveicarus/iverilog

On CentOS, we can download binaries directly, instead of building it. This is on CentOS 7.5.1804 release. Type below cmd on any terminal.
yum install iverilog => It may show some http 404 errors, but eventually will find some other mirrors. On entering "Y" after it asks for confirmation, following gets downloaded and installed. Downloading packages: iverilog-10_2-2.el7.x86_64.rpm           
Installed: iverilog.x86_64 0:10_2-2.el7 Both iverilog and vvp are installedwhich iverilog => shows path as "/usr/bin/iverilog"
which vvp => shows path as "/usr/bin/vvp"There is very good beginner's material here: https://iverilog.fandom.com/wiki/User_GuideLet's copy the hello.v code shown on link above, and run testcase on it: ( > below is the prompt)> iverilog -o hello hello.v
> vvp hello
Hello, World
We can similarly try "counter" example. cp counter.v and counter_tb.v and run below cmds: (finish cmd is needed to get out of simulatoriverilog -o my_design  counter_tb.v counter.v
[root@DESKTOP-G2APOII counter]# vvp my_design
At time                    0, value = xx (x)
At time                   17, value = 00 (0) ....
** VVP Stop(0) **
** Flushing output streams.
** Current simulation time is 168 ticks.
> finish
** Continue **
To get dumpfile from sim, we can add following code anywhere in tb file

initial
 begin
    $dumpfile("test.vcd");
    $dumpvars(0,test);
 end

Now on running cmds again, we will see test.vcd which can be loaded on any waveform viewer.

GTKWave: An open source waveform viewer. More info here: http://gtkwave.sourceforge.net/

Download following software before installing GTKWave.

1. gperf: GNU perfect hash function generator. Link here: https://www.gnu.org/software/gperf/

    download from ftp://ftp.gnu.org/pub/gnu/gperf/
    Download latest version (gperf-3.1.tar.gz). Extract and follow these steps:

    - cd gperf-3.1

    - ./configure

   - make

   - make check => optional. Runs test cases

   - sudo make install => installs it in /usr/local/bin/gperf

 2. gtk: It's used for creating GUI. Link here: https://www.gtk.org/.

  If you go to download page for Linux, you will see latest version as 3.24, while earlier gtk2 version as 2.24. I think you can download either one, however there are lot of dependencies as Glib, Pango, Gdk-Pixbuf, ATK and GObject-Introspection. I tried to install "gtk+-2.24.0", but it fails looking for these dependencies:

configure: error: Package requirements (glib-2.0 >= 2.27.3    atk >= 1.29.2    pango >= 1.20    cairo >= 1.6    gdk-pixbuf-2.0 >= 2.21.0) were not met:

No package 'glib-2.0' found
No package 'atk' found
No package 'pango' found
No package 'cairo' found
No package 'gdk-pixbuf-2.0' found

 I tried to install pango, cairo, glib. glib required meson, which could not be installed due to python 3.5 dependency (even though python3 was installed). Fortunately, CentOS repository has gtk pkg available for installation via yum, so I took that route:

 - yum groupinstall "Development Tools"

- sudo yum install gtk+-devel gtk2-devel => this will download and install gtk with all required dependencies

You will see these 2 pkg installed:

Installed:    gtk+-devel.x86_64 1:1.2.10-77.el7                              gtk2-devel.x86_64 0:2.24.31-1.el7        

Once you have downloaded above gperf and gtk package, we can download GTKWave (gtkwave-3.3.101.tar.gz) at bottom of gtkwave page. Extract it, and in the extracted dir, we'll see a README/INSTALL that lists the steps. Here's the steps:

1. cd gtkwave-3.3.101

2. ./configure --disable-xz => This will error out if the option is not used since xz is not installed.It's a compression software, we'll disable it for now. This is what you see on screen if xz not disabled:

configure: error: LZMA support for VZT is enabled, but xz could not be found.
Please install the xz-devel package, see the http://tukaani.org/xz website, or use the --disable-xz flag.

3. make

4. sudo make install => should get installed in /usr/local/bin/gtkwave

Now run "gtkwave test.vcd". It should bring up gtkwave gui.

NOTE: You get error like this while running gtkwave:

tkwave: error while loading shared libraries: libtcl8.7.so: cannot open shared object file: No such file or directory

This can happen when there are multiple versions of tcl/tk installed on your system. yum install or manual install of tcl/tk may not show any error, but when trying to run a software, we may see errors related to tcl/tk files. Best way is to remove tcl/tk, and start fresh from manual install of tcl/tk (yum may not fix the issue as "yum install" will always show everything uptodate and refuse to update). You may want to use below option to force a particular tcl/tk version to be used in step 2 above, and then continue with step 3 and 4:

./configure --disable-xz --with-tcl=/usr/lib64/tcl8.5 --with-tk=/usr/lib64/tk8.5 => replace version 8.5 with whatever version you have on your system. I used both 8.5 and 8.7. This did not work for me, so I had to reinstall tcl/tk 8.7. After that, it worked, without using these tcl/tk options.

 -----------------