engr 303 introduction to logic design lecture 13 · • moore is a finite-state machine whose...

23
ENGR 303 – Introduction to Logic Design Lecture 13 Dr. Chuck Brown Engineering and Computer Information Science Folsom Lake College

Upload: others

Post on 20-Jul-2020

7 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

ENGR 303 – Introduction to Logic Design Lecture 13

Dr. Chuck BrownEngineering and Computer Information Science

Folsom Lake College

Page 2: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<2>

• Moore & Mealy State Machines

• Factoring

Outline for Todays Lecture

ENGR 303

Page 3: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<3> ENGR 303

Examples of Finite State Machines

• Vending Machine

• Combination Lock

• Elevator Controller

• Light Controller

• Alarm System

• Pattern Recognition

• Network Controller

• Interface Controller

• and more

Page 4: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<4>

• Moore is a finite-state machine whose output values are

determined solely by its current state.

• Moore machines are safer to use: Outputs change at clock edge (always

one cycle later)

• Additional logic may be necessary to decode state into outputs—more

gate delays after clock edge

• Some sequential circuits can only be implemented as Moore machines

Moore State Machines

ENGR 303

This system takes in a stream of zeros and ones and outputs a 1 any time it gets the input sequence 011

State Name

Output

Input

Page 5: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<5>

• Mealy1 machine is a finite-state machine whose output values

are determined both by its current state and the current inputs

• Mealy machines tend to have fewer states

• React faster to inputs in same cycle—don't need to wait for clock

• Input change can cause output change as soon as logic is done—a big

problem when two machines are interconnected

• Not all sequential circuits can be implemented using the Mealy model

Mealy State Machines

ENGR 303

1 named after George H. Mealy, who presented the concept in a 1955 paper, “A Method for Synthesizing Sequential Circuits”.

This system takes in a stream of zeros and ones and outputs a 1 any time it gets the input sequence 011

State Name

Output

Input

Page 6: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<6>

1. Identify inputs and outputs

2. Sketch state transition diagram

3. Write state transition table

4. Select state encodings

5. For Moore machine:

1. Rewrite state transition table with state encodings

2. Write output table

6. For a Mealy machine:

1. Rewrite combined state transition and output table with state

encodings

7. Write Boolean equations for next state and output logic

8. Sketch the circuit schematic

FSM Design Procedure

ENGR 303

Page 7: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<7>

• Design a Mealy and Moore FSM of a sequence detector that

takes a serial data input stream of zeros and ones and outputs

a one any time the input sequence ends in 01

• Inputs: CLK, Reset, A

• Outputs: Y

Moore & Mealy FSM Examples

ENGR 303

01 Sequence Detector

CLK

Reset

A Y

Page 8: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<8>

Moore FSM: arcs indicate input and state indicates output

Mealy FSM: arcs indicate input/output

State Transition DiagramsMoore FSM

Reset

S0

0

S1

0

S2

10

0 1

1 0

1

Reset

S0 S1

1/1

0/0

1/0 0/0

Mealy FSM

ENGR 303

This system takes in a stream of zeros and ones and outputs a 1 any time it gets the input sequence 01

Page 9: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<9>

• Binary encoding:

– i.e., for four states, 00, 01, 10, 11

• One-hot encoding

– One state bit per state

– Only one state bit HIGH at once

– i.e., for 4 states, 0001, 0010, 0100, 1000

– Requires more flip-flops

– Often next state and output logic is simpler

Recap - FSM State Encoding

ENGR 303

Page 10: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<10>

Current

State Inputs Next State

S1 S0 A S'1 S'0

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

State Encoding

S0 00

S1 01

S2 10

Moore FSM State Transition Table

ENGR 303

Page 11: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<11>

Current

State Inputs Next State

S1 S0 A S'1 S'0

0 0 0 0 1

0 0 1 0 0

0 1 0 0 1

0 1 1 1 0

1 0 0 0 1

1 0 1 0 0

State Encoding

S0 00

S1 01

S2 10

Moore FSM State Transition Table

S1’ = S0A

S0’ = A

ENGR 303

Page 12: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<12>

Current State Output

S1 S0 Y

0 0

0 1

1 0

Moore FSM Output Table

ENGR 303

Page 13: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<13>

Current State Output

S1 S0 Y

0 0 0

0 1 0

1 0 1

Y = S1

Moore FSM Output Table

ENGR 303

Page 14: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<14>

Moore FSM Schematic

Y

CLK

Reset

A

r

S'0

S0

S'1

S1

ENGR 303

Page 15: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<15>

Current

State Input

Next

State Output

S0 A S'0 Y

0 0

0 1

1 0

1 1

State Encoding

S0 00

S1 01

Mealy FSM State Transition & Output Table

ENGR 303

Page 16: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<16>

Current

State Input

Next

State Output

S0 A S'0 Y

0 0 1 0

0 1 0 0

1 0 1 0

1 1 0 1

State Encoding

S0 00

S1 01

Mealy FSM State Transition & Output Table

ENGR 303

S’0 = A

Y = S0A

Page 17: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<17>

Mealy FSM Schematic

S'0 Y

CLK

Reset

A

r

S0

ENGR 303

Page 18: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<18>

Moore & Mealy Timing Diagram

Mealy Machine

Moore Machine

CLK

Reset

A

S

Y

S

Y

Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10

S0 S2?? S2 S2S0 S1

1 0 1 1 0 1 1 10

S1

S0 S0?? S0 S1 S0S1

S1 S0

S1

Cycle 11

ENGR 303

Page 19: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<19>

• Break complex FSMs into smaller interacting FSMs

• Example: Modify traffic light controller to have Parade Mode.

– Two more inputs: P, R

– When P = 1, enter Parade Mode & Bravado Blvd light stays green

– When R = 1, leave Parade Mode

Factoring State Machines

ENGR 303

Page 20: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<20>

Unfactored FSM

Factored FSM

Controller

FSMTA

TB

LA

LB

PR

Mode

FSM

Lights

FSM

P

M

Controller

FSM

TA

TB

LA

LB

R

Traffic Light FSM Parade Mode

ENGR 303

Page 21: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<21>

S0

LA: green

LB: red

S1

LA: yellow

LB: red

S3

LA: red

LB: yellow

S2

LA: red

LB: green

TA

TA

TB

TB

Reset

S4

LA: green

LB: red

S5

LA: yellow

LB: red

S7

LA: red

LB: yellow

S6

LA: red

LB: green

TA

TA

P

PP

P

P

P

R

R

R

R

R

P

RP

TA

P

TA

P

P

TA

R

TA

R

R

TB

RT

BR

Unfactored FSM

ENGR 303

Page 22: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<22>

S0

LA: green

LB: red

S1

LA: yellow

LB: red

S3

LA: red

LB: yellow

S2

LA: red

LB: green

TA

TA

M + TB

MTB

Reset

Lights FSM

S0

M: 0

S1

M: 1

PReset

P

Mode FSM

R

R

Factored FSM

ENGR 303

Page 23: ENGR 303 Introduction to Logic Design Lecture 13 · • Moore is a finite-state machine whose output values are determined solely by its current state. • Moore machines are safer

<23>

1. Identify inputs and outputs

2. Sketch state transition diagram

3. Write state transition table

4. Select state encodings

5. For Moore machine:

1. Rewrite state transition table with state encodings

2. Write output table

6. For a Mealy machine:

1. Rewrite combined state transition and output table with state

encodings

7. Write Boolean equations for next state and output logic

8. Sketch the circuit schematic

Recap - FSM Design Procedure

ENGR 303