Professional Documents
Culture Documents
Design of Counters: Welcome To The Course-Digital System Design Code-BECE102L
Design of Counters: Welcome To The Course-Digital System Design Code-BECE102L
Design of Counters
A register that goes through a prescribed sequence of states upon the application of
input pulses (clock pulse) is called a counter.
Synchronous counters
Ripple counters - Flip flop output serves as a source for triggering other flip flops
Counters
Counters can be designed to generate any desired sequence of states.
A divide‐by‐ N counter (mod ‐ N counter) is a counter that goes through a repeated
sequence of N states.
The sequence may follow the binary count or may be any other arbitrary sequence.
Counters can also be constructed by means of shift registers.
Applications
Perform timing functions as in digital watches
Create time delays
Generate pulse trains
Generate timing signals to control the sequence of operations in a digital
system.
Jo Ko J1 K1 J2 K2
1 X 0 x 0 x
X 0 1 x 0 x
X 1 x 0 0 x
0 X x 0 1 x
1 X x 0 x 0
X 0 x 1 x 0
Digital Logic Design 7 0 x x 0
X 1
0 X 0 x x 1
Step 5:
Step 7:
A0 J A1
J Q Q
C C
Q' K Q'
K
CLK
1 1 1 1 1 1 1
A2 1 A2 1 1 A2 1 1 1 1
A0 A0 A0
TA2 = A1.A0 TA1 = A0 TA0 = 1
Synchronous (Parallel) Counters
Example: 3-bit synchronous binary counter (cont’d).
TA2 = A1.A0 TA1 = A0 TA0 = 1
D2 D1 D0
0 1 0
1 0 1
1 1 1
0 0 1
Step 5: Step 6:
Step 7:
101 011
111 010
110
Present Next Flip-flop
state state inputs
Q2 Q1 Q0 Q2+ Q1+ Q0+ JQ2 KQ2 JQ1 KQ1 JQ0 KQ0
0 0 0 0 0 1 0 X 0 X 1 X
0 0 1 0 1 1 0 X 1 X X 0
0 1 0 1 1 0 1 X X 0 0 X
0 1 1 0 1 0 0 X X 0 X 1
1 0 0 0 0 0 X 1 0 X 0 X
1 0 1 1 0 0 X 0 0 X X 1
1 1 0 1 1 1 X 0 X 0 1 X
1 1 1 1 0 1 X 0 X 1 X 0
Q 1Q 0 Q 1Q 0 Q 1Q 0
Q2 00 01 11 10 Q2 00 01 11 10 Q2 00 01 11 10
0 0 1 X X 0 1 X X
1
1 X X X X 1 X X 1 X X 1
Q 1Q 0 Q 1Q 0 Q 1Q 0
Q2 00 01 11 10 Q2 00 01 11 10 Q2 00 01 11 10
0 X X X X 0 X X 0 X 1 X
1 1 1 X X 1 1 X 1 X
Q0 Q1 Q2
J Q J Q J Q
C C C
Q 1' Q 2'
K Q' K Q' K Q'
Q 0'
CLK
Ring Counter
It is the special application of Shift register(circular shift register)
The output of the last FF is given as the input of the first FF.
always@(posedge clk)
begin
if(clr)
q <= 4‘b0;
else if (load)
q <= 4‘b0001;
else if(up)
q <= q + 4’b1;
else if(down)
q <= q – 4’b1;
end
endmodule
always@(posedge clk)
begin
if(clr)
q <= 4'd0;
else
begin
if (load)
q <= 4'd8;
else
q <= {q[0], q[3:1]};
end
end
endmodule
always@(posedge clk)
begin
if(clr)
q <= 4'd0;
else
begin
if (load)
q <= 4'd8;
else
q <= {!q[0], q[3:1]};
end
end
endmodule