Experiment 17: Implement and Verify Asynchronous Counter Using Verilog HDL
Experiment 17: Implement and Verify Asynchronous Counter Using Verilog HDL
Object: Implement and verify Asynchronous Counter using Verilog HDL. Software Used: Theory:
A register that goes through a prescribed sequence of states upon the application of input pulses is called a counter. The input pulses may be clock pulses, or they may originate from some external source and may occur at a fixed interval of time or at random. Counters are available in two categories: ripple counters and synchronous counters. In a ripple counter, a flipflop output transition serves as a source for triggering other flipflops. In other words, the C input of some or all flipflops are triggered, not by the common clock pulses, but rather by the transition that occurs in other flip flop outputs.
XILINX ISE 8.2i
92
Verilog Code for Ripple up counter:module tff(t,clk,reset,q); input t,clk,reset; output reg q=1'b0; always@(negedge clk,posedge reset) begin if(reset) q=1'b0; else if(t) q=~q; end endmodule module up_counter(count,reset,a0,a1,a2,a3); input count,reset; output a0,a1,a2,a3; tff t0(1'b1,count,reset,a0); tff t1(1'b1,a0,reset,a1); tff t2(1'b1,a1,reset,a2); tff t3(1'b1,a2,reset,a3); endmodule
93
Verilog Code Ripple down counter:module tff(t,clk,reset,q,qb); input t,clk,reset; output reg q=1'b0,qb=1'b1; always@(negedge clk,posedge reset) begin if(reset) begin q=1'b0; qb=1'b1; end else if(t) begin q=~q; qb=~qb; end end endmodule module up_counter(count,reset,a0,a1,a2,a3); input count,reset; output a0,a1,a2,a3; wire w0,w1,w2,w3; tff t0(1'b1,count,reset,a0,w0); tff t1(1'b1,w0,reset,a1,w1); tff t2(1'b1,w1,reset,a2,w2); tff t3(1'b1,w2,reset,a3,w3); endmodule
94
95
Verilog Code Ripple up/down counter:module tff(t,clk,reset,q); input t,clk,reset; output reg q=1'b0; always@(negedge clk,posedge reset) begin if(reset) q=1'b0; else if(t) q=~q; end endmodule module up_counter(count,reset,a0,a1,a2,a3,down); input count,reset,down; output a0,a1,a2,a3; wire w0,w1,w2; tff t0(1'b1,count,reset,a0); xor(w0,a0,down); tff t1(1'b1,w0,reset,a1); xor(w1,a1,down); tff t2(1'b1,w1,reset,a2); xor(w2,a2,down); tff t3(1'b1,w2,reset,a3); endmodule
96
Conclusion: Asynchronous Counter were designed using Verilog HDL and its working is verified using ISE Simulator.
97