58
ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor Department of Electrical and Computer Engineering Auburn University, Auburn, AL 36849 http://www.eng.auburn.edu/~vagrawal [email protected] Fall 2015, Nov 13 . . Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7 ELEC2200-002 Lecture 7 1

ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Embed Size (px)

Citation preview

Page 1: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

ELEC 2200-002Digital Logic Circuits

Fall 2015Sequential Circuits (Chapter 6)

Finite State Machines (Ch. 7-10)Vishwani D. Agrawal

James J. Danaher ProfessorDepartment of Electrical and Computer Engineering

Auburn University, Auburn, AL 36849http://www.eng.auburn.edu/~vagrawal

[email protected] 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 11

Page 2: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Combinational vs. Sequential CircuitsCombinational circuit:

Output is a function of input only

Contains gates without feedback

Sequential circuit:Output is a function of input and something else stored in the circuit (memory)

Contains gates and feedback

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 22

Toggling 0-1

Odd inversions Even inversions

0 or 1

Page 3: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

SR Latch: Basic Sequential Circuit

Feedback loop with even number of inversions (no oscillation?).

Output(s): two sets of logic values from the loop.

Input functions:To control loop logic values

To set the loop in “input control” or “store” state

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 33

Page 4: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Adding Inputs to Feedback Loop

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 44

Q

Q

S

R

Page 5: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

NOR Set-Reset (SR) Latch

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 55

Q

Q

S

R

Q

Q

S

R

Q

Q

S

R

Also drawn as Symbol used in Logic schematics

Page 6: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

States of Latch

Function S R Q Q

Set 1 0 1 0

Reset 0 1 0 1

Store(Memory)

0 0 Prev. Q Prev. Q

Uncertain 1 1 0 0

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 66

Page 7: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

“Store or Memory” Function

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 77

Q = 1 or 0

Q = 0 or 1

S = 0

R = 0

Loop is activated; behavior is sequential.

Page 8: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

“Set” Function

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 88

Q = 1

Q = 0

S = 1→ 0

R = 0 → 0

Behavior is combinational.

Loop is broken

Page 9: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

“Reset” Function

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 99

Q = 0

Q = 1

S = 0 → 0

R = 1 → 0

Behavior is combinational.

Loop is broken

Page 10: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

“Uncertain” Function

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 1010

Q = 0

Q = 0

S = 1

R = 1

Loop is broken in two places and inconsistent values inserted.

Page 11: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

“Uncertain” Function

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 1111

Q = 0 → 1 → 0 → 1 → . . .

Q = 0 → 1 → 0 → 1 → . . .

S = 1 → 0

R = 1 → 0

Output oscillates with a period of loop delay. For unequal gatedelays, faster gate will settle to 1 and slower gate to 0. This isknown as RACE CONDITION.

Assume two gates have equal delays.

Page 12: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Excitation Table of SR LatchExcitation inputs

Present state

Next stateFunctionalName of

StateS R Q Q*

0 0 0 0 Store (Memory)0 0 1 1

0 1 0 0Reset

0 1 1 0

1 0 0 1Set

1 0 1 1

1 1 0 Uncertain Race condition1 1 1 Uncertain

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 1212

Page 13: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Characteristic Equation for SR Latch

Next-state function:Treat illegal states as don’t care

Minimize using Karnaugh map

Characteristic equation, Q* = S +RQ

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 1313

1

1 1Q

S

R

Page 14: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

State Diagram of SR Latch

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 1414

Q = 0 Q = 1

SR = 10

SR = 01

SR = 0X SR = X0

Page 15: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Clocked SR Latch

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 1515

S

CK

R

Q

Q

SR-latch

Page 16: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Clocked Delay Latch or D-Latch

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 1616

D

CK

Q

Q

SR-latch

Page 17: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Setup and Hold Times of LatchSignals are synchronized with respect to clock (CK).

Operation is level-sensitive:

CK = 1 allows data (D) to pass through

CK = 0 holds the value of Q, ignores data (D)

Setup time is the interval before the clock transition during which data (D) should be stable (not change). This will avoid any possible race condition.

Hold time is the interval after the clock transition during which data should not change. This will avoid data from latching incorrectly.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 1717

Page 18: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Master-Slave D-Flip-Flop

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 1818

D

CK

Q

Q

Master latch Slave latch

Page 19: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Master-Slave D-Flip-Flop

Uses two clocked D-latches.

Transfers data (D) with one clock period delay.

Operation is edge-triggered:Negative edge-triggered, CK = 1→0, Q = D (previous slide)

Positive edge-triggered, CK = 0→1, Q = D

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 1919

Page 20: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Negative-Edge Triggered D-Flip-Flop

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 2020

Clock period, T

Master openSlave closed

Slave openMaster closedCK

D

Data can change Data can changeDatastable

Time

Setup time Hold timeTriggering clock edge

Page 21: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Symbols for Latch and D-Flip-Flops

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . 2121

CK

D

Q (LATCH)Level sensitive

Q (DFF)Pos. Edge Triggered

Q (DFF)Neg. Edge Triggered

DCK

Q

D

CK

Q

D

CK

Q

ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7

Page 22: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Register (3-Bit Example)Stores parallel data

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 2222

CLRD Q

CK

CLRD Q

CK

CLRD Q

CK

CLR

CK

Q0 Q1 Q2

Parallel output

Parallel inputD0 D1 D2

Page 23: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Shift Register (3-Bit Example)Stores serial data (parallel output)

Delays data (serial output)

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 2323

CLRD Q

CK

CLRD Q

CK

CLRD Q

CK

CLR

DSerialinput

CK

Q0 Q1 Q2

Parallel output

Serialoutput

Page 24: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Two Types of Digital Circuits1. Output depends uniquely on inputs:

Contains only logic gates, AND, OR, . . . No feedback interconnects

2. Output depends on inputs and memory: Contains logic gates, latches and flip-flops May have feedback interconnects Contents of flip-flops define internal state; N flip-flops

provide 2N states; finite memory means finite states, hence the name “finite state machine (FSM)”.

Clocked memory – synchronous FSM No clock – asynchronous FSM

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 2424

Page 25: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Textbook Organization

Chapter 6: Sequential devices – latches, flip-flops.

Chapter 7: Modular sequential logic – registers, shift registers, counters.

Chapter 8: Specification and analysis of FSM.

Chapter 9: Synchronous (clocked) FSM design.

Chapter 10: Asynchronous (pulse mode) FSM design.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 2525

Page 26: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Mealy and Moore FSMMealy machine: Output is a function of input and the state.

Moore machine: Output is a function of the state alone.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 2626

S0 S1

1/0

1/1

0/1 0/0

Mealy machine

S0/1 S1/0

1/1

0/0

0/1 1/0

Moore machine

G. H. Mealy, “A Method for Synthesizing Sequential Circuits,” BellSystems Tech. J., vol. 34, pp. 1045-1079, September 1955.E. F. Moore, “Gedanken-Experiments on Sequential Machines,” Annals ofMathematical Studies, no. 34, pp. 129-153 ,1956, Princeton Univ. Press, NJ.

Page 27: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Example 8.17: Robot Control

A robot moves in a straight line, encounters an obstacle and turns right or left until path is clear; on successive obstacles right and left turn strategies are used.

Define input: One bitX = 0, no obstacle

X = 1, an obstacle encountered

Define outputs: Two bits to represent three possible actions.Z1, Z2 = 00 no turn

Z1, Z2 = 01 turn right by a predetermined angle

Z1, Z2 = 10 turn left by a predetermined angle

Z1, Z2 = 11 output not used

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 2727

Page 28: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Example 8.17: Robot Control (Continued . . . 2)

Because turning strategy depends on the action for the previous obstacle, the robot must remember the past.

Therefore, we define internal memory states:State A = no obstacle detected, last turn was left

State B = obstacle detected, turning right

State C = no obstacle detected, last turn was right

State D = obstacle detected, turning left

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 2828

Page 29: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Example 8.17: Robot Control (Continued . . . 3)

Construct state diagram.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 2929

A

D C

B

A: no obstacle, last turn was leftB: obstacle, turn rightC: no obstacle, last turn was rightD: obstacle, turn left

Input: X = 0, no obstacleX = 1, obstacle

Outputs:Z1, Z2 = 00, no turnZ1, Z2 = 01, right turnZ1, Z2 = 10, left turn

0/001/01

0/000/00

0/00

1/01

1/101/10

X Z1 Z2

Page 30: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Example 8.17: Robot Control (Continued . . . 4)

Construct state table.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 3030

A

D C

B

0/001/01

0/000/00

0/00

1/01

1/101/10

X Z1 Z2

A/00

C/00

C/00

A/00

B/01

B/01

D/10

D/10

XPresent 0 1state

A

B

C

D

Nextstate

OutputsZ1, Z2

Page 31: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

XY1 Y2 0 1

00

01

11

10

Example 8.17: Robot Control (Continued . . . 5)

State assignment: Each state is assigned a unique binary code. Need log24 = 2 binary state variables to represent 4 states.

Let memory variables be Y1,Y2:

A: {Y1,Y2} = 00; B: {Y1,Y2} = 01; C: {Y1,Y2} = 11, D: {Y1,Y2} = 10

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 3131

A/00

C/00

C/00

A/00

B/01

B/01

D/10

D/10

XPresent 0 1state

A

B

C

D

00/00

11/00

11/00

00/00

01/01

01/01

10/10

10/10

Page 32: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Realization of FSMPrimary input: X

Primary outputs: Z1, Z2

Present state variables: Y1, Y2

Next state variables: Y1*, Y2*

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 3232

Combinational logic

Flip-flop

Z1

Z2X

Y1

Y2 Y1*

Y2*

Clock

Clear Flip-flop

Page 33: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

XY1 Y2 0 1

00

01

11

10

Example 8.17: Robot Control (Continued . . . 6)

Construct truth tables for outputs, Z1 and Z2, and next state variables, Y1* and Y2*.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 3333

00/00

11/00

11/00

00/00

01/01

01/01

10/10

10/10

NextState, Y1*, Y2*

OutputsZ1, Z2

InputPresent

state Outputs Next state

X Y1 Y2 Z1 Z2 Y1* Y2*

0 0 0 0 0 0 0

0 0 1 0 0 1 1

0 1 0 0 0 0 0

0 1 1 0 0 1 1

1 0 0 0 1 0 1

1 0 1 0 1 0 1

1 1 0 1 0 1 0

1 1 1 1 0 1 0

Page 34: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Example 8.17: Robot Control (Continued . . . 7)

Synthesize logic functions, Z1, Z2, Y1*, Y2*.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 3434

InputPresent

state Outputs Next state

X Y1 Y2 Z1 Z2 Y1* Y2*

0 0 0 0 0 0 0

0 0 1 0 0 1 1

0 1 0 0 0 0 0

0 1 1 0 0 1 1

1 0 0 0 1 0 1

1 0 1 0 1 0 1

1 1 0 1 0 1 0

1 1 1 1 0 1 0

Z1 = XY1Y2 + XY1 Y2 = XY1

Z2 = XY1Y2 + XY1 Y2 = XY1

Y1* = XY1 Y2 + . . .

Y2* = XY1 Y2 + . . .

Page 35: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Example 8.17: Robot Control (Continued . . . 8)

Synthesize logic functions, Z1, Z2, Y1*, Y2*.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 3535

1

1 1 1Y2

X

Y1

1

1 1 1Y2

Y1

1

1Y2

X

Y1

1

1Y2

X

Y1

X

Z1

Z2

Y1*

Y2*

Page 36: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Example 8.17: Robot Control (Continued . . . 9)

Synthesize logic and connect memory elements (flip-flops).

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 3636

Y2

Y1

Y1

Y2

XZ1

Z2

Y1*

Y2*

CK

CLEAR

Combinational logic

Page 37: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Steps in FSM SynthesisExamine specified function to identify inputs, outputs and memory states.

Draw a state diagram.

Minimize states (see Section 9.1).

Assign binary codes to states (Section 9.4).

Derive truth tables for state variables and output functions.

Minimize multi-output logic circuit.

Connect flip-flops for state variables. Don’t forget to connect clock and clear signals.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 3737

Page 38: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Architecture of an FSMThe Huffman model, containing:

Flip-flops for storing the state.

Combinational logic to generate outputs and next state from inputs and present state.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 3838

Combinational logic

Flip-flops

OutputsInputs

Presentstate

Nextstate

ClockClear

D. A. Huffman, “The Synthesis of Sequential Switching Circuits,J. Franklin Inst., vol. 257, pp. 275-303, March-April 1954.

Page 39: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

State Minimization

An FSM contains flip-flops and combinational logic:

Number of flip-flops, Nff = log2 Ns , Ns = #states

Size of combinational logic may vary with state assignment.

Examples:

1.Ns = 16, Nff = log2 16 = 4

2.Ns = 17, Nff = log2 17 = 4.0875 = 5

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 3939

Ceiling operator

Page 40: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Equivalent StatesTwo states of an FSM are equivalent (or indistinguishable) if for each input they produce the same output and the same next state.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 4040

Si

Sj

Sm

Sn

1/0

1/0

0/0

0/0

Si,j

Sm

Sn

1/0

0/0

Si and Sj are equivalent andmerged into a single state.

Page 41: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Minimizing StatesExample: States A . . . I, Inputs I1, I2, Output, Z

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 4141

Present state

Next state / output (Z)

InputI1 I2

A D / 0 C / 1

B E / 1 A / 1

C H / 1 D / 1

D D / 0 C / 1

E B / 0 G / 1

F H / 1 D /1

G A / 0 F / 1

H C / 0 A / 1

I G / 1 H / 1

A and D are equivalent

A and E produce same outputQ: Can they be equivalent?A: Yes, if B and D were equivalent and C and G were equivalent.

Page 42: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Implication Table Method

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 4242

A B C D E F G H

B

C

D

E

F

G

H

I

√BDCG

ADCF

CDAC

EHAD

EHAD

EGAH

Present state

Next state, output (Z)

InputI1 I2

A D / 0 C / 1

B E / 1 A / 1

C H / 1 D / 1

D D / 0 C / 1

E B / 0 G / 1

F H / 1 D / 1

G A / 0 F /1

H C / 0 A / 1

I G / 1 H / 1

ADCF

CDAC

BCAG

BDCG

ACAF

GHDH

GHDH

ABFG

Page 43: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Implication Table Method (Cont.)

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 4343

A B C D E F G H

B

C

D

E

F

G

H

I

√BDCG

ADCF

CDAC

EHAD

EHAD

EGAH

ADCF

CDAC

BCAG

BDCG

ACAF

GHDH

GHDH

Equivalent states:

S1: A, D, G

S2: B, C, F

S3: E, H

S4: IABFG

Page 44: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Minimized State Table

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 4444

Present state

Next state, output (Z)

InputI1 I2

A D / 0 C / 1

B E / 1 A / 1

C H / 1 D / 1

D D / 0 C / 1

E B / 0 G / 1

F H / 1 D / 1

G A / 0 F / 1

H C / 0 A / 1

I G / 1 H / 1

Present state

Next state, output (Z)

InputI1 I2

S1 = (A, D, G) S1 / 0 S2 / 1

S2 = (B, C, F) S3 / 1 S1 / 1

S3 = (E, H) S2 / 0 S1 / 1

S4 = I S1 / 1 S3 / 1

Original Minimized

Number of flip-flops is reducedfrom 4 to 2.

Page 45: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

State AssignmentState assignment means assigning distinct binary patterns (codes) to states.

N flip-flops generate 2N codes.

While we are free to assign these codes to represent states in any way, the assignment affects the optimality of the combinational logic.

Rules based on heuristics are used to determine state assignment.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 4545

Page 46: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Criteria for State AssignmentOptimize:

Logic gates, or

Delay, or

Power consumption, or

Testability, or

Any combination of the above

Up to 4 or 5 flip-flops: can try all assignments and select the best.

More flip-flops: Use an existing heuristic (one discussed next) or invent a new heuristic.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 4646

Page 47: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

1 1 1

1 1 1

1 1 1

1 1

The Idea of AdjacencyInputs are A and B

State variables are Y1 and Y2

An output is F(A, B, Y1, Y2)

A next state function is G(A, B, Y1, Y2)

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 4747

A

B

Y1

Y2

Karnaugh map ofoutput function ornext state function

Larger clustersproduce smaller logic function.

Clustered mintermsdiffer in one variable.

Page 48: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Size of an ImplementationNumber of product terms determines number of gates.

Number of literals in a product term determines number of gate inputs, which is proportional to number of transistors.

Hardware α (total number of literals)

Examples of four minterm functions:F1 = ABCD +ABCD +ABCD +ABCD has 16 literals

F2 = ABC +ACD has 6 literals

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 4848

Page 49: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Rule 1States that have the same next state for some fixed input should be assigned logically adjacent codes.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 4949

Combinational logic

Flip-flops

OutputsFixedInputs

Presentstate

Nextstate

ClockClear

Si

Sj

Sk

Page 50: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Rule 2States that are the next states of the same state under logically adjacent inputs, should be assigned logically adjacent codes.

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 5050

Combinational logic

Flip-flops

OutputsAdjacentInputs

Fixedpresent

state

Nextstate

ClockClear

SkSm

Si

I1I2

Page 51: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Example of State Assignment

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 5151

Present state

Next state, output (Z)

Input, X0 1

A C, 0 D, 0

B C, 0 A, 0

C B, 0 D, 0

D A, 1 B, 1

D B

A

C

0/0

0/0

0/0

1/01/0

1/0

1/1

0/1

A adj B(Rule 1)

A adj C(Rule 1)

B adj D(Rule 2)

Figure 9.19 of textbook C adj D(Rule 2)

A B

C D

0 1

0

1

Verify that BC andAD are not adjacent.

Page 52: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

A = 00, B = 01, C = 10, D = 11

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 5252

Present state

Y1, Y2

Next state, outputY1*Y2*, Z

Input, X0 1

A = 00 10 / 0 11 / 0

B = 01 10 / 0 00 / 0

C = 10 01 / 0 11 / 0

D = 11 00 / 1 01 / 1

InputPresent

state Output Next state

X Y1 Y2 Z Y1* Y2*

0 0 0 0 1 0

0 0 1 0 1 0

0 1 0 0 0 1

0 1 1 1 0 0

1 0 0 0 1 1

1 0 1 0 0 0

1 1 0 0 1 1

1 1 1 1 1 0

Page 53: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Logic Minimization for Optimum State Assignment

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 5353

1 1 1

1 1Y2

X

Y1

1 1 1

Y2

Y1

1 1Y2

X

Y1X

Z Y1*

Y2*

Result: 5 products, 10 literals.

Page 54: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Circuit with Optimum State Assignment

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 5454

Y2

Y1

Y1

Y2

X

Z

Y2*

Y1*

CK

CLEAR

Combinational logic

32 transistors

Page 55: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Using an Arbitrary State Assignment: A = 00, B = 01, C = 11, D = 10

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 5555

Present state

Y1, Y2

Next state, outputY1*Y2*, Z

Input, X0 1

A = 00 11 / 0 10 / 0

B = 01 11 / 0 00 / 0

C = 11 01 / 0 10 / 0

D = 10 00 / 1 01 / 1

InputPresent

state Output Next state

X Y1 Y2 Z Y1* Y2*

0 0 0 0 1 1

0 0 1 0 1 1

0 1 0 1 0 0

0 1 1 0 0 1

1 0 0 0 1 0

1 0 1 0 0 0

1 1 0 1 0 1

1 1 1 0 1 0

Page 56: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Logic Minimization for Arbitrary State Assignment

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 5656

Result: 6 products, 14 literals.

1 1

1 1Y2

X

1 1

Y2

XZ Y1*

1 1

1 1Y2

Y1

XY2*

Y1 Y1

Page 57: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Circuit for Arbitrary State Assignment

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 5757

Y2

Y1

Y1

Y2

X

Z

Y2*

Y1*

CK

CLEAR

Comb.logic

42 transistors

Page 58: ELEC 2200-002 Digital Logic Circuits Fall 2015 Sequential Circuits (Chapter 6) Finite State Machines (Ch. 7-10) Vishwani D. Agrawal James J. Danaher Professor

Find Out More About FSMState minimization through partioning (Section 9.2.2).

Incompletely specified sequential circuits (Section 9.3).

Further rules for state assignment and use of implication graphs (Section 9.4).

Asynchronous or fundamental-mode sequential circuits (Chapter 10).

Fall 2015, Nov 13 . . .Fall 2015, Nov 13 . . . ELEC2200-002 Lecture 7ELEC2200-002 Lecture 7 5858