14
CPSC 5155 Chapter 7 Slide 1 Slide 1 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006 Modulo4 UpDown Counter This is a counter with input. If X = 0, the device counts up: 0, 1, 2, 3, 0, 1, 2, 3, etc. If X = 1, the device counts down: 0, 3, 2, 1, 0, 3, 2, 1, etc. Step 1a: Derive the state diagram and state table for the circuit. Note two transitions between the state pairs: one is up and one is down.

Mod 4 Up Down Counter

Embed Size (px)

DESCRIPTION

mod

Citation preview

Page 1: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 1

Slide 1 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Modulo–4 Up–Down Counter

This is a counter with input.

If X = 0, the device counts up: 0, 1, 2, 3, 0, 1, 2, 3, etc.If X = 1, the device counts down: 0, 3, 2, 1, 0, 3, 2, 1, etc.

Step 1a: Derive the state diagram and state table for the circuit.

Note two transitions between the state pairs: one is up and one is down.

Page 2: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 2

Slide 2 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Step 1b: Derive the State Table

Present State Next StateX = 0 X = 1

0 1 31 2 02 3 13 0 2

This is just a restatement of the state diagram.

Note: Two columns for the “Next State”.

Page 3: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 3

Slide 3 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Step 2: Count the States andDetermine the Flip–Flop Count

Count the States

There are four states for any modulo–4 counter. N = 4

The states are simple: 0, 1, 2, and 3.

Calculate the Number of Flip–Flops Required

Let P be the number of flip–flops.

Solve 2P-1 < N 2P. So 2P-1 < 4 2P and P = 2.

We need two flip–flops.

Page 4: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 4

Slide 4 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Step 3: Assign a unique P-bit binary number(state vector) to each state.

Here P = 2, so we are assigning two–bit binary numbers.

Vector is denoted by the binary number Y1Y0.

State 2-bit VectorY1 Y0

0 0 01 0 12 1 03 1 1

Each state has a unique 2–bit number assigned.

Any other assignment would be absurd.

Page 5: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 5

Slide 5 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Step 4: Derive the state transition tableand the output table.

There is no computed output, hence no output table.

The state transition table uses the 2–bit state vectors

Present State Next StateX = 0 X = 1

0 00 01 111 01 10 002 10 11 013 11 00 10

Page 6: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 6

Slide 6 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Step 5:Separate the state transition table into P tables,one for each flip-flop.

Flip–Flop 1Flip-Flop 1

PS Next State: Y1

Y1Y0 X = 0 X = 10 0 0 10 1 1 01 0 1 01 1 0 1

Flip–Flop 0Flip-Flop 0: Y0

PS Next StateY1Y0 X = 0 X = 10 0 1 10 1 0 01 0 1 11 1 0 0

Page 7: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 7

Slide 7 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Step 6: Decide on the types of flip-flops to use.When in doubt, use all JK’s.

Here is the excitation table for a JK flip–flop

Q(T) Q(T+1) J K0 0 0 d0 1 1 d1 0 d 11 1 d 0

Page 8: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 8

Slide 8 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Step 7: Derive the input table for each flip-flop

Flip–Flop 1X = 0 X = 1

Y1Y0 Y1 J1 K1 Y1 J1 K1

0 0 0 0 d 1 1 d0 1 1 1 d 0 0 d1 0 1 d 0 0 d 11 1 0 d 1 1 d 0

Flip–Flop 0X = 0 X = 1

Y1Y0 Y0 J0 K0 Y1 J0 K0

0 0 1 1 d 1 1 d0 1 0 d 1 0 d 11 0 1 1 d 1 1 d1 1 0 d 1 0 d 1

Question: How do we produce equations for the J’s and K’s?

Page 9: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 9

Slide 9 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Step 8: Derive the input equations for each flip-flop

The equations are based on the present state and the input.

The input X produces a complication.

The simplest match procedure will lead to two equationsfor each flip–flop input: one for X = 0 and one for X = 1.

Use the “combine rule”

The rule for combining expressions derived separatelyfor X = 0 and X = 1 is

X(expression for X= 0) + X(expression for X = 1).

Rationale: Let F(X) = AX + BXWhen X = 0, F(X) = A and when X = 1, F(X) = B.

Page 10: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 10

Slide 10 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Input Equations for Flip–Flop 1

X = 0 X = 1Y1Y0 Y1 J1 K1 Y1 J1 K1

0 0 0 0 d 1 1 d0 1 1 1 d 0 0 d1 0 1 d 0 0 d 11 1 0 d 1 1 d 0

J1 = Y0 J1 = Y0’K1 = Y0 K1 = Y0’

Apply the “combine rule”

J1 = X’Y0 + XY0’ = X Y0

K1 = X’Y0 + XY0’ = X Y0

Page 11: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 11

Slide 11 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Input Equations for Flip–Flop 0

X = 0 X = 1Y1Y0 Y0 J0 K0 Y1 J0 K0

0 0 1 1 d 1 1 d0 1 0 d 1 0 d 11 0 1 1 d 1 1 d1 1 0 d 1 0 d 1

J0 = 1 J0 = 1K0 = 1 K0 = 1

Apply the “Combine Rule”

J0 = X’1 + X1 = 1

K0 = X’1 + X1 = 1

Neither J0 nor K0 depend on X. But Y0 does not depend on X.

Page 12: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 12

Slide 12 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Step 9: Summarize the equations bywriting them in one place.

Here they are.J1 = X Y0 K1 = X Y0

J0 = 1 K0 = 1

Page 13: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 13

Slide 13 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Step 10: Draw the Circuit

As designed, it is:

Page 14: Mod 4 Up Down Counter

CPSC 5155 Chapter 7 Slide 14

Slide 14 of 14 slides Design of a Mod-4 Up Down Counter February 13, 2006

Step 10: Draw the Circuit

Implemented with T Flip–Flops, it is:

One could also use a 4–register “one hot” design, with the input Xused to determine the direction of the shift.