Lecture #20 - Counters - the GMU ECE Department

ECE 301 – Digital Electronics
Counters
(Lecture #20)
The slides included herein were taken from the materials accompanying
Fundamentals of Logic Design, 6th Edition, by Roth and Kinney,
and were used with permission from Cengage Learning.
Counters
●
A counter is a sequential circuit (aka. finite
state machine) that cycles through a fixed
sequence of states.
●
The state of the counter is stored in Flip-Flops.
●
An n-bit counter
Spring 2011
–
has n Flip-Flops
–
can cycle through at most 2n states.
ECE 301 - Digital Electronics
2
Counters
111
00
11
01
000
110
001
010
10
101
100
011
2-bit Counter
3-bit Counter
Spring 2011
ECE 301 - Digital Electronics
3
Counters
000
00
01
110
010
101
011
10
2-bit Counter
using only 3 states
3-bit Counter
using only 5 states
Spring 2011
ECE 301 - Digital Electronics
4
Binary Counters
●
An n-bit binary counter is a counter that cycles
n
through all 2 states in ascending (or
descending) order.
111
000
001
3-bit Binary Counter
110
101
Spring 2011
010
100
Cycles through all 8 states
in ascending order
011
ECE 301 - Digital Electronics
5
Binary Counters: Design
1.Draw a state graph that specifies the desired
sequence of the counter.
2.Construct a state table from the state graph.

One Flip-Flop for each bit in the state.
3.Derive a K-map from the state table for each
Flip-Flop input.

Select the type of Flip-Flop to be used.
4.Determine the input equation(s) for each
Flip-Flop.
Spring 2011
ECE 301 - Digital Electronics
6
Binary Counters: Design
Example: State Table (using D FF)
Present State
C
B
A
Spring 2011
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
Next State
C+
B+
A+
FF Inputs
DC DB DA
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
0 3010- Digital0 Electronics
ECE
Characteristic
Equation:
Q+ = D
7
Binary Counters: Design
Example: K-maps (for D FF inputs)
Spring 2011
ECE 301 - Digital Electronics
8
Binary Counters: Design
Example: Circuit Diagram (using D FF)
Spring 2011
ECE 301 - Digital Electronics
9
Binary Counters: Design
Example: State Table (using T FF)
Present State
C
B
A
Spring 2011
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
Next State
C
+
0
0
0
1
1
1
1
0
B
+
A
+
FF Inputs
TC TB TA
0 1
1 0
1 1
0 0
0 1
1 0
1 1
0 3010- Digital Electronics
ECE
Characteristic
Equation:
Q+ = T xor Q
Excitation Table:
Q
Q+
T
0
0
0
0
1
1
1
0
1
1
1
0
10
Binary Counters: Design
Example: K-maps (for T FF inputs)
Spring 2011
ECE 301 - Digital Electronics
11
Binary Counters: Design
Example: Circuit Diagram (using T FF)
Spring 2011
ECE 301 - Digital Electronics
12
Binary Up-Down Counters
What constraints must be placed on the U and D control signals?
Spring 2011
ECE 301 - Digital Electronics
13
Binary Up-Down Counters
Spring 2011
ECE 301 - Digital Electronics
14
Loadable Counter with Enable
Spring 2011
ECE 301 - Digital Electronics
15
Counters: Design
1.Draw a state graph that specifies the desired
sequence of the counter.
2.Construct a state table from the state graph.

One Flip-Flop for each bit in the state.
3.Derive a K-map from the state table for each
Flip-Flop input.

Select the type of Flip-Flop to be used.
4.Determine the input equation(s) for each
Flip-Flop.
Spring 2011
ECE 301 - Digital Electronics
16
Counters: Design
Example:
Design the following counter using D Flip-Flops.
Spring 2011
ECE 301 - Digital Electronics
17
Counters: Design
Example: State Table (using D FF)
Present State
C
B
A
Excitation
Equation:
D = Q+
Spring 2011
Next State
C+
0 0 0 1
0 0 1 x
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 x
1 1 0 x
1ECE 3011- Digital
1 Electronics
0
B+
A+
0
x
1
0
1
x
x
1
0
x
1
0
1
x
x
0
FF Inputs
DC DB DA
18
Counters: Design
Example: K-maps (for D FF inputs)
DC
Spring 2011
DB
ECE 301 - Digital Electronics
DA
19
Counters: Design
Example: Circuit Diagram (using D FF)
Spring 2011
ECE 301 - Digital Electronics
20
Counters: Design
Example:
Design the following counter using T Flip-Flops.
Spring 2011
ECE 301 - Digital Electronics
21
Counters: Design
Example: State Table (using T FF)
Present State
C
B
A
Excitation
Equation:
T = Q xor Q+
Spring 2011
Next State
C+
0 0 0 1
0 0 1 x
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 x
1 1 0 x
1 3011- Digital1 Electronics
0
ECE
B+
A+
0
x
1
0
1
x
x
1
0
x
1
0
1
x
x
0
FF Inputs
TC TB TA
22
Counters: Design
Example: K-maps (for T FF inputs)
Spring 2011
ECE 301 - Digital Electronics
23
Counters: Design
Example: K-maps (for T FF inputs)
We could derive TC , TB , and TA directly from the state table,
but it is often more convenient to plot next-state maps
showing C+, B+, and A+ as functions of C, B, and A, and then
derive TC , TB , and TA from these maps.
Spring 2011
ECE 301 - Digital Electronics
24
Counters: Design
Example: Circuit Diagram (using T FF)
Spring 2011
ECE 301 - Digital Electronics
25
Counters: Design
Example: Next States (for T FF inputs)
Although the original state table for the counter is not
completely specified, the next states of states 001, 101,
and 110 have been specified in the process of
completing the circuit design
101
Spring 2011
110
26
Counters: Design
Example:
Design the following counter using JK Flip-Flops.
Spring 2011
ECE 301 - Digital Electronics
27
Counters: Design
Example: Using JK Flip-Flops
Excitation Table:
Spring 2011
ECE 301 - Digital Electronics
Q
Q+
J
K
0
0
0
x
0
1
1
x
1
0
x
1
1
1
x
0
28
Counters: Design
Example: State Table (using JK FF)
Present State
C
B
A
Spring 2011
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
Next State
C+
B+
A+
1
x
0
0
1
x
x
0
0 0
x x
1 1
0 0
1 1
x x
x x
1 3010- Digital Electronics
ECE
JC
KC
FF Inputs
JB K B JA
KA
29
Counters: Design
Example: K-maps (for JK FF inputs)
Spring 2011
ECE 301 - Digital Electronics
30
Counters: Design
Example: Circuit Diagram (using JK FF)
Spring 2011
ECE 301 - Digital Electronics
31
Questions?
Spring 2011
ECE 301 - Digital Electronics
32