December 25, 2024

Merry Christmas!

Icarus Verilog

Icarus is the dude in Greek mythology who flew too close to the sun (with waxen wings) and died.

For several years now I have been working with vivado from Xilinx. I don't use the simulation facility in vivado. Telling it to "run synthesis" is very slow and I began wondering if a tool like "iverilog" or "verilator" might be a way to spot check my verilog syntax and even do some simple testing. It turns out that it definitely is useful as a first step and time saver before going on to vivado.

dnf install iverilog
This gives me both "iverilog" and "vvp" and I am good to go.

Some notes up front

This is already (less than 1 hour in) proving more useful than I had hoped. It is very fast. I can run it and have it screen out stupid typos and syntax errors in just seconds, which is a big win over using vivado for that purpose.

Using it for simulation looks promising and will give me even more practice with verilog writing test bench code.

A tutorial

Just running "iverilog hello.v" gives me a.out, which is a "vvp script".
It is better perhaps to do "iverlog -o hello hello.v", then I do:
vvp a.out
Hello, World
hello.v:5: $finish called at 0 (1s)

Suppose you have multiple files such as counter.v and tb_counter.v where "tb" is a test bench. You can "compile" them together and run them via:

iverilog -o design  tb_counter.v counter.v
vvp design

If you have a big design and lots of files, you can put all the filenames, one per line into a file list "file_list" then use:

iverilog -o design  -c file file_list
vvp design
At this point I will almost certainly start using a Makefile.

The iverilog system will choose as a "root" module, some module that is not instantiated by any other module. If there is no such module or this is otherwise ambiguous, you can use the "-s" switch to indicate a root module:

iverilog -s main -o design  -c file file_list

Wave graphs

The trick here is using GTKWave. I install gtkwave. It pulls in several other packages:
Installing:
 gtkwave                 x86_64  3.3.121-1.fc41
Installing dependencies:
 Judy                    x86_64  1.0.5-37.fc41
 amtk                    x86_64  5.6.1-7.fc41
 libgedit-gtksourceview  x86_64  299.0.5-2.fc41
 libpeas1-loader-python3 x86_64  1.36.0-7.fc41
 tepl                    x86_64  6.8.0-3.fc41
Installing weak dependencies:
 gedit                   x86_64  2:46.2-5.fc41
They say to add this to your test bench, where "tester" is the name of your test bench module
initial
begin
   $dumpfile("test.vcd");
   $dumpvars(0,tester);
end
Then run your simulation via:
vvp foo.vvp -fst 
gtkwave dump.fst
The -fst option is not necessary, but is faster than the default -vcd.

Using gtkwave

In the demo I ran, I saw "test" in the upper left box. I expanded this and clicked on "cl". This gave me signals in the box below, I could double click on these to get them to display on the big display screen. Then the "-" button zooms out so I can see more. This has great promise.

There is a 159 page manual. Holy Cow, I hope it isn't that complex.
See my notes below:


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org