Verilog TUTORIAL - Running your first code



It may also be a good idea to install a compiler / simulator. This will allow you to save your code on your computer and will allow you to do some things not possible online. Icarus is small and efficient compiler that is more than enough for learning the verilog tutorials that we will present in this tutorial. Although Icarus is mainly tailored towards Linux, we have Windows installer available. This tutorial is based upon Windows, though you can follow it for Linux version as well.

The Windows program can be downloaded from http://bleyer.org/icarus/ ( Opens in a new tab) - . This site results in the google when you search for "Icarus Verilog download".

Double click the downloaded setup file and fillow the instructions to install the verilog on your windows.

The C:/iverilog/bin subdirectory contains the executable file verilog.exe that is used to run simulator.

Now create a new file called hello.v in the directory C:/iverilog/bin and edit it with notepad or any other text editor( I prefer free notepad++). Enter the following lines of code in hello.v

  1. module main;
  2. initial
  3. begin
  4. $display("Learning Verilog is easy with referencedesigner.com tutorial");
  5. $finish ;
  6. end
  7. endmodule


- Go to your DOS prompt ( Start - > cmd ) and navigate to the directory C:/iverilog/bin

C:\> cd \iverilog\bin

Run iverilog using the command

C:\>iverilog\bin > iverilog hello.v

If you have done everything right, it should generate a file called a.out which you can run using command

C:\>iverilog\bin > vvp a.out

At this point the code just gives out the output saying "Learning Verilog is easy with referencedesigner.com tutorial". It just verifies that your set up is ready for running verilog code.

If you get any stuck at any stage, try to follow the youtube videos that installs and runs a simple Hello World program




In the next page we will write an actual real life veriog code - a comparator. But before that, we would like to point that, you may want to keep your code in a separate directory in place of C:/verilog/bin. You will need to set you path variable in the Windows, so that you are able to run your code from anywhere. If you wish to set you path variable, Go to Start -> Computer ->Properties -> Advanced System Settings -> Environment Variable -> System Variable and click on the variable named path and then click edit. Now add C:\iverilog\bin; at the and of the value so this variable.Important caution - do not delete the existing values of the variable name. Start a new DOS prompt window for the environment variable to be active ( may be, you have to restart the computer). If that looks tedious follow this topic ( opens in a new window), for details or just continue to keep writing and running your code in C:/verilog/bin - it is not a big deal.

Let us now move on to our comparator code.