Docsity

Finite State Machines, Exercises of Computer science

Partial preview of the text

Download Finite State Machines and more Exercises Computer science in PDF only on Docsity!

Fundamentals of Computer Systems

Finite State Machines

Stephen A. Edwards

Columbia University

Fall 2012

Finite State Machine Components

C

L

C

L

CLOCK

Next State Current State

Current State

Inputs

Next State

Current State

Inputs?

Outputs

Moore and Mealy Machines

Next State Logic

Output Logic

CLK

Next State

Current State Inputs Outputs

The Mealy Form:

Outputs may be a function of both the current state and the inputs.

A mnemonic: Moore machines often have more states.

Mealy Machines are the Most General

C

Current L

State

Next State

Inputs Outputs

CLK

Another, equivalent way of drawing Mealy Machines

This is exactly the synchronous digital logic paradigm

State Transition Diagrams: Looking for โ€œ1101โ€

S 0

Moore Machine: States indicate output

State Transition Diagrams: Looking for โ€œ1101โ€

S 0

S 0

Moore Machine: States indicate output

State Transition Diagrams: Looking for โ€œ1101โ€

S 0

S 0

S 0

S 0

S 1

Moore Machine: States indicate output

State Transition Diagrams: Looking for โ€œ1101โ€

S 0

S 0

S 0

S 0

S 1

Moore Machine: States indicate output

S

Mealy Machine: Arcs indicate input/output (^) 6 / 1

State Transition Diagrams: Looking for โ€œ1101โ€

S 0

S 0

S 0

S 0

S 1

Moore Machine: States indicate output

S0 S1 S2 S

State Transition Diagrams: Looking for โ€œ1101โ€

S 0

S 0

S 0

S 0

S 1

Moore Machine: States indicate output

S0 S1 S2 S

Moore Machine

Next State S A Sโ€™ 000 0 000 000 1 001 001 0 000 001 1 010 010 0 011 010 1 010 011 0 000 011 1 100 100 0 000 100 1 010

Output S Y 000 0 001 0 010 0 011 0 100 1

CLK

CLK

CLK

S โ€ฒ 0

S โ€ฒ 1

S โ€ฒ 2

A

S 0

S 1

S (^2) Y

Mealy Machine

  • S0 0 S0 S A Sโ€™ Y
  • S0 1 S1
  • S1 0 S0
  • S1 1 S2
  • S2 0 S3
  • S2 1 S2
  • S3 0 S0
  • S3 1 S1

More Intuitive Solutions using Shift Registers

A

Y

CLK

Mealy Form: Output Depends on Input Immediately

A

Y

CLK

Moore Form: Output Depends Only on State

FSM Example: A Traffic Light Controller

C

C

This controls a traffic light at the intersection of a busy highway and a farm road. Normally, the highway light is green but if a sensor detects a car on the farm road, the highway light turns yellow then red. The farm road light then turns green until there are no cars or after a long timeout. Then, the farm road light turns yellow then red, and the highway light returns to green. The inputs to the machine are the car sensor, a short timeout signal, and a long timeout signal. The outputs are a timer start signal and the colors of the highway and farm road lights. Source: Mead and Conway, Introduction to VLSI Systems , 1980, p. 85.