You are on page 1of 4

Gray Code Counter Using JK Flip Flops

Jerome K. Butler SMU Electrical Engineering October 17, 2009

1 Problem
Design a circuit to implement a Gray code counter using JK ip ops. Assume only a 3-bit counter.

2 3-Bit Gray Code


The Gray code for a 3-bit counter can be determined from that for the 2-bit counter. The 2-bit counter is 0 0 1 1 Extend 2-bit code to 3-bit code 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 1 1 0 0 1 1 0 0 1 1 0

3 Setting the Sequence


The 3-bit Gray code sequence is now written as in the following sequence. The variables are a (MSB), b, and c (LSB).

State S0 S1 S2 S3

a 0 0 0 0

b 0 0 1 1

c 0 1 0 1

a+ 0 0 1 0

b+ 0 1 0 1

c+ 1 1 0 0

State S4 S5 S6 S7

a 1 1 1 1

b 0 0 1 1

c 0 1 0 1

a+ 0 1 1 1

b+ 0 0 1 0

c+ 0 0 1 1

4 JK Flip-Flop States
The JK ip-op states are illustrated in the gure below. For example, to change from S0 (Q = 0) to S1 (Q = 1), may be either J = 1, K = 0, or J = 1, K = 1. In short, J = 1, K = d. Three ip ops will be used in the circuit where Q0 represents the LSB and Q2 is the MSB.

1d
J Q

0d
K Q

S0 d1

S1

d0

The following truth table species the inputs to the three JK ip ops. State S0 S1 S2 S3 S4 S5 S6 S7 Q2 0 0 0 0 1 1 1 1 Q1 0 0 1 1 0 0 1 1 Q0 0 1 0 1 0 1 0 1
+ Q2 0 0 1 0 0 0 1 1 + Q1 0 1 1 1 0 0 1 0 + Q0 1 1 0 0 0 0 1 1

J0 1 d 0 d 0 d 1 d

K0 d 0 d 1 d 1 d 0

J1 0 1 d d 0 0 d d

K1 d d 0 0 d d 0 1

J2 0 0 1 0 d d d d

K2 d d d d 1 0 0 0

The Karnaugh maps and Boolean results: Q2 J0 Q0 1


0 1

Q2 Q0 d 0
1 5

K0

d
5

d
4

0
0

1
4

d d
6

Q1
2

0
3

d
7

d
6

Q1
2

d
3

1
7

The resulting Boolean equations are J0 K0 Q2 J1 Q0 0


0 1

= =

Q1 Q2 + Q1 Q2 Q1 Q2 + Q1 Q2 Q2 K1 Q0 d
0 1

1
5

0
4

0 d
6

d
5

d
4

d 0
6

Q1
2

d
3

d
7

Q1
2

0
3

0
7

The resulting Boolean equations are J1 = Q0 Q2 K1 = Q0 Q2 Q2 J2 Q0 0


0 1

Q2 K2 Q0 d
0 1

0
5

d
4

d d
6

d
5

0
4

1 0
6

Q1
2

1
3

0
7

Q1
2

d
3

d
7

The resulting Boolean equations are J2 = Q0 Q1 K2 = Q0 Q1

5 Digital Works Output


The following gure shows the circuit derived from the Boolean expressions as well as the output from the ciruit.

You might also like