blooz
Advanced Member level 2
First you need to download the Free Waveform viewer GTKwave
h**p://gtkwave.sourceforge.net/
then Generate a VCD file
Files
//Testbench
//Save as countertb.v
////////////////////////////////
`timescale 1ns/1ns
module countertb();
reg clk;
reg reset;
wire [3:0] q;
counter instance0(.clk(clk),.q(q),.reset(reset));
initial
begin
clk=1'b0;
reset=1'b1;
#10 reset=1'b0;
#1600 ;
$finish;
end
initial
begin
forever #20 clk=~clk;
end
initial
begin
$monitor("time=>%tns q=>%b",$time,q);
$dumpfile(counter_wave.vcd);
$dumpvars();
end
endmodule
//Save As counter.v
///////////////////////////
// 4 bit Counter
module counter(clk,q,reset);
input clk;
input reset;
output reg [3:0] q;
initial
begin
q=4'b0000;
end
always@( posedge clk)
begin
if (reset==1'b1)
q=4'b0000;
else
q=q+1;
end
endmodule
step
1.Compile and simulate in Icarus verilog
iverilog -o result counter.v countertb.v
vvp result
2.Simulation results are visible and a VCD file will be produced ,we have named it as
counter_wave.vcd
3.run
gtkwave counter_wave.vcd
then a graphical window will be shown
screen shots are given in the pictures section
h**p://gtkwave.sourceforge.net/
then Generate a VCD file
Files
//Testbench
//Save as countertb.v
////////////////////////////////
`timescale 1ns/1ns
module countertb();
reg clk;
reg reset;
wire [3:0] q;
counter instance0(.clk(clk),.q(q),.reset(reset));
initial
begin
clk=1'b0;
reset=1'b1;
#10 reset=1'b0;
#1600 ;
$finish;
end
initial
begin
forever #20 clk=~clk;
end
initial
begin
$monitor("time=>%tns q=>%b",$time,q);
$dumpfile(counter_wave.vcd);
$dumpvars();
end
endmodule
//Save As counter.v
///////////////////////////
// 4 bit Counter
module counter(clk,q,reset);
input clk;
input reset;
output reg [3:0] q;
initial
begin
q=4'b0000;
end
always@( posedge clk)
begin
if (reset==1'b1)
q=4'b0000;
else
q=q+1;
end
endmodule
step
1.Compile and simulate in Icarus verilog
iverilog -o result counter.v countertb.v
vvp result
2.Simulation results are visible and a VCD file will be produced ,we have named it as
counter_wave.vcd
3.run
gtkwave counter_wave.vcd
then a graphical window will be shown
screen shots are given in the pictures section