Professional Documents
Culture Documents
Icarus Verilog (iverilog) and VVP were DOS based programs. Assuming the readers are familiar in using
iverilog, here are the steps to compile and simulate a Verilog code.
1. Create a Verilog file of the circuit you want to design and simulate. Example given here is a full adder
circuit. The file name is fa.v and this file is saved in the folder C:\iverilog\bin\
2. Compile the file fa.v by typing at the DOS prompt C:\iverilog\bin\iverilog fa.v
3. If there is syntax error/s, correct it and compile again. No message displayed when there is no error/s.
4. Create a testbench file to simulate the full adder circuit. Example given (at the bottom) is the testbench
file fatb.v and this file is saved in the folder C:\iverilog\bin\
5. Compile the testbench file fatb.v by typing at the DOS prompt C:\iverilog\bin\iverilog fatb.v
6. If there is syntax error/s, correct it and compile again. No message displayed when there is no error/s.
At this point, an output file called a.out is created in the C:\iverilog\bin\
7. To display the table of the input and output signals, type at the DOS prompt C:\iverilog\bin\vvp a.out
12. Double click the SST window folder fulladdt_b and you will see the uut subfolder.
13. Click the uut subfolder, and all the signals is displayed in the Signals window below.
14. Select and drag one by one of the input and output signals of the full adder circuit, the wire a, wire b,
wire c, wire carry and wire sum signals, and place it in the Waves window.
15. Click the unzoom button until the signals is displayed properly.
//Internal variable
reg Qout;
endmodule
initial begin
$dumpfile("test1.vcd");
$dumpvars(0, tb_jkff); //for the gtkwave waveform viewer
// Initialize Inputs
J = 0; K = 0; R = 0; S = 0; CE = 0;
//Apply inputs
#30; R = 1;
#50; R = 0; S = 1;
#50; S = 0; J = 1; K = 1;
#50; CE = 1;
#50; J = 0; K = 0;
#50; J = 0; K = 1;
#50; J = 1; K = 0;
#50; J = 1; K = 1;
#50; CE = 0;
#30; $finish;
end
endmodule