02 02 Counters
02 02 Counters
Counters
• Counters are a specific type of sequential circuit.
5)Flip-flops: JK or T or D
COUNTERs …
• In electronics, counters can be implemented quite easily using register-type
circuits such as the flip-flop, and a wide variety of classifications exist:
Asynchronous (ripple) counter – changing state bits are
used as clocks to subsequent state flip-flops
Synchronous counter – all state bits change under control of
a single clock
Decade counter – counts through ten states per stage
Up/down counter – counts both up and down, under
command of a control input
Ring counter – formed by a shift register with feedback
connection in a ring
Johnson counter – a twisted ring counter
Cascaded counter
Modulus counter
Benefits of counters
• Counters can act as simple clocks to keep track of “time.”
Different flip-flops are applied with All flip-flops are applied with same clock
different clocks
Flip-flops are connected in such away that There is no connection b/w o/p of first flip-
the o/p of first flip-flop drives the clock of flop and clock of next flip-flop
next flip-flop
Circuit is simple for more no. of states Circuit is complicated for more no. of states
Logical Diagram:
1. Asynchronous or ripple counters …
Operation:
S.N. Condition Operation
Initially let both
1 the FFs be in the • QBQA = 00 initially
reset state
• As soon as the first negative clock edge is applied, FF-A will toggle and Q A will be equal to 1.
• QA is connected to clock input of FF-B.
After 1st Since QA has changed from 0 to 1, it is treated as the positive clock edge by FF-B.
2 negative clock •
edge • There is no change in QB because FF-B is a negative edge triggered FF.
• QBQA = 01 after the first clock pulse.
• On the arrival of second negative clock edge, FF-A toggles again and Q A = 0.
After 2nd • The change in QA acts as a negative clock edge for FF-B.
3 negative clock • So it will also toggle, and QB will be 1.
edge • QBQA = 10 after the second clock pulse.
• On the arrival of 3rd negative clock edge, FF-A toggles again and QA become 1 from 0.
After 3rd • Since this is a positive going change, FF-B does not respond to it and remains inactive.
4 negative clock
edge • So QB does not change and continues to be equal to 1.
• QBQA = 11 after the third clock pulse.
• On the arrival of 4th negative clock edge, FF-A toggles again and QA becomes 1 from 0.
After 4th • This negative change in QA acts as clock pulse for FF-B.
5 negative clock
edge • Hence it toggles to change QB from 1 to 0.
• QBQA = 00 after the fourth clock pulse.
1. Asynchronous or ripple counters …
Truth Table:
2. Synchronous counters
• If the "clock" pulses are applied to all the flip-flops in a counter
simultaneously, then such a counter is called as synchronous counter.
Logical Diagram:
2. Synchronous counters …
Operation:
S.N. Condition Operation
Initially let
both the FFs be QBQA = 00 initially.
1 •
in the reset
state
• As soon as the first negative clock edge is applied, FF-A will toggle and Q A will change from
0 to 1.
After 1st • But at the instant of application of negative clock edge, Q A , JB = KB = 0.
2 negative clock • Hence FF-B will not change its state.
edge • So QB will remain 0.
• QBQA = 01 after the first clock pulse.
• On the arrival of second negative clock edge, FF-A toggles again and Q A changes from 1 to 0.
• But at this instant QA was 1.
After 2nd So JB = KB= 1 and FF-B will toggle.
3 negative clock •
edge • Hence QB changes from 0 to 1.
• QBQA = 10 after the second clock pulse.
After 3rd • On application of the third falling clock edge, FF-A will toggle from 0 to 1 but there is no
4 negative clock change of state for FF-B.
edge • QBQA = 11 after the third clock pulse.
After 4th • On application of the next clock pulse, QA will change from 1 to 0 as QB will also change
5 negative clock from 1 to 0.
edge • QBQA = 00 after the fourth clock pulse.
Classification of counters
• Depending on the way in which the counting progresses, the
synchronous or asynchronous counters are classified as follows −
i. Up counters
ii. Down counters
iii.Up/Down counters
UP/DOWN Counter
• Up counter and down counter is combined together to obtain an UP/DOWN
counter.
• A mode control (M) input is also provided to select either up or down mode.
– For a ripple down counter, the Q bar output of preceding FF is connected to the
clock input of the next one.
– Let the selection of Q and Q bar output of the preceding FF be controlled by the
mode control input M such that,
• If M = 0, UP counting. So connect Q to CLK.
• If M = 1, DOWN counting. So connect Q bar to CLK.
UP/DOWN Ripple Counters …
Block Diagram:
Truth Table:
2. Synchronous counters …
Operation:
S.N Condition Operation
.
• If M = 0 and M bar = 1, then the AND gates 1 and 3 in fig.
will be enabled whereas the AND gates 2 and 4 will be
disabled.
Case 1 :
With M = 0 • Hence QA gets connected to the clock input of FF-B and QB
1 gets connected to the clock input of FF-C.
(Up counting
mode) • These connections are same as those for the normal up
counter.
• Thus with M = 0 the circuit work as an up counter.
Type of modulus:
–2-bit up or down (MOD-4)
–3-bit up or down (MOD-8)
–4-bit up or down (MOD-16)
Application of counters
Frequency counters
Digital clock
Time measurement
A to D converter
Frequency divider circuits
Digital triangular wavegenerator.
A slightly fancier counter
• Let’s try to design a slightly different two-bit counter:
– Again, the counter outputs will be 00, 01, 10 and 11.
– Now, there is a single input, X. When X=0, the counter value should
increment on each clock cycle.
– But when X=1, the value should decrement on successive cycles.
• We’ll need two flip-flops again. Here are the four possible states:
00 01
11 10
The complete state diagram and table
• Here’s the complete state diagram and state table for this circuit.
Q0
Present State Inputs Next State 0 1 0 1
Q1 Q0 X Q1 Q0 Q1 1 0 1 0
0 0 0 0 1 X
0 0 1 1 1
D1 = Q1 Q0 X
0 1 0 1 0
0 1 1 0 0
1 0 0 1 1 Q0
1 0 1 0 1 1 1 0 0
1 1 0 0 0 Q1 1 1 0 0
1 1 1 1 0 X
D0 = Q0’
The counter in LogicWorks
• Here are some D Flip Flop devices
from LogicWorks.
• We can then find equations for all four flip-flop inputs, in terms of the present
state and inputs. Here, it turns out J1 = K1 and J0 = K0.
J1 = K1 = Q0’ X + Q0 X’
J0 = K0 = 1
The counter in LogicWorks again
• Here is the counter again, but using
JK Flip Flop n.i. RS devices instead.
J K CK Q
0 0 ↓ Q0
0 1 ↓ 0
1 0 ↓ 1
1 1 ↓ Q'0
X X 0,1 Q0
JK timing diagram …
D CK Q
0 ↑ 0
1 ↑ 1
X 0,1 Q0
D timing diagram …
Synchronous: The events have a fixed time relationship with each other and do occur
at the same time.
Asynchronous Synchronous
The logic circuit of this type of The circuit diagram for type of
counters is simple to design and counter becomes difficult as
Circuit
we feed output of one FF to clock number of states increase in the
of next FF counter
Maximum
And hence operating frequency is And hence operating frequency
operating
Low is Higher
frequency
3 bit asynchronous “ripple” counter using T flip flops
• This is called as a
ripple counter due to
the way the FFs
respond one after
another in a kind of
rippling effect.
Synchronous Counters
• To eliminate the "ripple" effects, use a common clock for each flip-
flop and a combinational circuit to generate the next state.
• For an up-counter,
use an incrementer =>
Incre-
menterS3 D3 Q3
A3
A2 S2 D2 Q2
A1 S1 D1 Q1
A0 S0 D0 Q0
Clock
Synchronous Counters (continued)
Carry
output CO
Clock
(a) Logic Diagram-Serial Gating
Design Example: Synchronous BCD
• Use the sequential logic model to design a synchronous BCD counter
with D flip-flops
• State Table =>
• Input combinations
1010 through 1111 Current State Next State
are don’t cares Q8 Q4 Q2 Q1 Q8 Q4 Q2 Q1
0 0 0 0 0 0 0 1
0 0 0 1 0 0 1 0
0 0 1 0 0 0 1 1
0 0 1 1 0 1 0 0
0 1 0 0 0 1 0 1
0 1 0 1 0 1 1 0
0 1 1 0 0 1 1 1
0 1 1 1 1 0 0 0
1 0 0 0 1 0 0 1
1 0 0 1 0 0 0 0
Synchronous BCD (continued)
• Use K-Maps to two-level optimize the next state equations and manipulate into
forms containing XOR gates:
D1 = Q1’
• D2 = Q2 + Q1Q8’
D4 = Q4 + Q1Q2
D8 = Q8 + (Q1Q8 + Q1Q2Q4)
• Y = Q1Q8
• The logic diagram can be drawn from these equations
– An asynchronous or synchronous reset should be added
• What happens if the counter is perturbed by a power disturbance or other
interference and it enters a state other than 0000 through 1001?
Synchronous BCD (continued)
• Find the actual values of the six next states for the don’t care combinations
from the equations
• Find the overall state diagram to assess behavior for the don’t care states
(states in decimal)
6 10 4
5
Synchronous BCD (continued)
• For the BCD counter design, if an invalid state is entered, return to a valid
state occurs within two clock cycles
• Is this adequate?!
Counting an arbitrary sequence
Unused states
• The examples shown so far have all had 2n states, and used n flip-flops. But
sometimes you may have unused, leftover states.
• For example, here is a state table and diagram for a counter that repeatedly
counts from 0 (000) to 5 (101).
• What should we put in the table for the two unused states?