Verilog TUTORIAL with Icarus| Verificatiom
Now we have understood the concept we will compile the code and and run it in Icarus. Copy the following source codes in the directory C:\iverilog\bin.
comparator.v
|
stimulus.v
|
Now go to the dos windows ( Start -> cmd) navigate to the iverilog\bin directory
C:\> cd iverilog\bin
Compile the program using
C:\iverilog\bin>iverilog -o comparator.vpp comparator.v stimulus.v
If everything goes right, it will not produce any output. If there are any syntax errors it will show some errors.
To see the output of the stimulus, you may like to give the following command
C:\iverilog\bin>vvp comparator.vvp
This shows the following output.
x=0,y=0,z=1
x=1,y=0,z=0
x=1,y=1,z=1
x=0,y=1,z=0
C:\iverilog\bin>
This completes the basic hello world example of the verilog. Notice that , for simplicity we kept our source file in the same directory as the bin. In practice it is not a good idea. There are two workarounds.
1. Keep all your source files in a separate directory - say /iverilog/src and give the full path name of source files when compiling the program ( this is a bit tedious).
2. Define a path name for the C:/iverilog/bin in your computer's list of environment variables. And then you can give the command iverilog from anywhere in the directory. This is a preferred way of doing the things.
You may want to change the equation to see if the result produced is different.
Here are some examples that you may want to take up before proceeding further.
Exercize
1. Change the code such that it compares two values x and y and gives 1 if x is greater than or equal to y. Write stimulus to verify it.
2. Implement and verify the verilog code for a circuit that has three inputs and one one output. The three inputs represent a binary number ( from 0 to 7) and output is 1 if the value is greater than 5 else it is 0.
In the next page we will learn more about Verilog and its language construct.