ECED2200 Digital Circuits Finite State Machines 31/07/2012 Colin - - PowerPoint PPT Presentation

eced2200 digital circuits
SMART_READER_LITE
LIVE PREVIEW

ECED2200 Digital Circuits Finite State Machines 31/07/2012 Colin - - PowerPoint PPT Presentation

ECED2200 Digital Circuits Finite State Machines 31/07/2012 Colin OFlynn - CC BY-SA 1 General Notes See updates to these slides: www.newae.com/teaching These slides licensed under Creative Commons Attribution-ShareAlike 3.0


slide-1
SLIDE 1

ECED2200 – Digital Circuits

Finite State Machines

31/07/2012 Colin O’Flynn - CC BY-SA 1

slide-2
SLIDE 2

General Notes

  • See updates to these slides: www.newae.com/teaching
  • These slides licensed under ‘Creative Commons Attribution-ShareAlike 3.0

Unported License’

  • These slides are not the complete course – they are extended in-class
  • You will find the following references useful, see

www.newae.com/teaching for more information/links:

– The book “Bebop to the Boolean Boogie” which is available to Dalhousie Students – Course notes (covers almost everything we will discuss in class) – Various websites such as e.g.: www.play-hookey.com – The book “Contemporary Logic Design”, which was used in previous iterations of the class and you may have already

31/07/2012 Colin O’Flynn - CC BY-SA 2

slide-3
SLIDE 3

Finite State Machine (FSM)

  • Step 1: Understand the Problem
  • Step 2: Draw Initial State Diagram
  • Step 3: Minimize State Diagram (if possible)
  • Step 4: Perform State Assignment, draw state

transition table

  • Step 5: Choose Flip-Flops / Technology
  • Step 6: Implement FSM

31/07/2012 Colin O’Flynn - CC BY-SA 3

slide-4
SLIDE 4

Step 1: Understand the Problem

e.g.: Design a vending machine which takes 25₵

  • r $1 coins, and releases candy when $1.25 has

been deposited. No changes is given, assuming you have ‘Q’ and ‘L’ (Quarter & Loonie) inputs.

31/07/2012 Colin O’Flynn - CC BY-SA 4

slide-5
SLIDE 5

Step 1: Understand the Problem

31/07/2012 Colin O’Flynn - CC BY-SA 5

slide-6
SLIDE 6

Step 1: Understand the Problem

31/07/2012 Colin O’Flynn - CC BY-SA 6

slide-7
SLIDE 7

Step 2: Draw Initial Diagram

31/07/2012 Colin O’Flynn - CC BY-SA 7

Start S1 S2 S2 S3 S4 S5 S6 S7 S8

slide-8
SLIDE 8

Step 3: Draw Minimized State Diagram

31/07/2012 Colin O’Flynn - CC BY-SA 8

Start 0.25 0.50 0.75 1.00 1.25

slide-9
SLIDE 9

Step 3: Symbolic State Table

31/07/2012 Colin O’Flynn - CC BY-SA 9

State Quarter Loonie Next State Release 0.00 0.00 0.00 1 1.00 0.00 1 0.25 0.00 1 1 ? 0.25 0.25 0.25 1 1.25 0.25 1 0.50 0.25 1 1 ? 0.50 0.50 0.50 1 1.25 0.50 1 0.75 0.50 1 1 ? 0.75 0.75 0.75 1 1.25 0.75 1 1.00 0.75 ? 1.00 1.00 1.00 1 1.25 1.00 1 1.25 1.00 1 1 ? 1.25 ? ? 0.00 1

slide-10
SLIDE 10

Step 4: Perform State Assignment

000 = 0.00 001 = 0.25 010 = 0.50 011 = 0.75 100 = 1.00 101 = 1.25

31/07/2012 Colin O’Flynn - CC BY-SA 10

slide-11
SLIDE 11

Step 4: State Transition Table + Outputs

31/07/2012 Colin O’Flynn - CC BY-SA 11

Present State Quarter Loonie Next State Release 000 000 000 1 100 000 1 001 000 1 1 ? 001 001 001 1 101 001 1 010 001 1 1 ? 010 010 010 1 101 010 1 011 010 1 1 ? 011 011 011 1 101 011 1 100 011 ? 100 100 100 1 101 100 1 101 100 1 1 ? 101 ? ? 000 1

slide-12
SLIDE 12

Step 5: Choose Flip-Flops

  • D flip-flops simplify design
  • JK flip-flops simplify logic

31/07/2012 Colin O’Flynn - CC BY-SA 12

slide-13
SLIDE 13

D Flip-Flops (Partial Example)

31/07/2012 Colin O’Flynn - CC BY-SA 13

State Quarter Loonie Next State D Flip-Flop Entries Da Db Dc 000 000 000 1 100 1 000 1 001 1 000 1 1 ? ? ? ? 001 001 1 001 1 101 1 1 001 1 010 1 001 1 1 ? ? ? ? 010 010 1 010 1 101 1 1 010 1 011 1 1 010 1 1 ? ? ? ? 011 011 1 1 011 1 101 1 1 011 1 100 1 011 ? ? ? ? 100 100 1 100 1 101 1 1 100 1 101 1 1 100 1 1 ? ? ? ? 101 ? ? 000

slide-14
SLIDE 14

D Flip-Flops (Partial Example)

31/07/2012 Colin O’Flynn - CC BY-SA 14

State Quarter Loonie Next State D Flip-Flop Entries Da Db Dc 000 000 000 1 100 000 1 001 000 1 1 ? 001 001 001 1 101

Q Q+ D

1 1 1 1 1 1

slide-15
SLIDE 15

JK Flip-Flops (Partial Example)

31/07/2012 Colin O’Flynn - CC BY-SA 15

State Quarter Loonie Next State JK Flip-Flop Entries Ja Ka Jb Kb Jc Kc 000 000 000 1 100 000 1 001 000 1 1 ? 001 001 001 1 101

Q Q+ J K

? 1 1 ? 1 ? 1 1 1 ?

slide-16
SLIDE 16

Step 6: Implement FSM

  • Use K-maps for inputs to FF & for outputs

31/07/2012 Colin O’Flynn - CC BY-SA 16

slide-17
SLIDE 17

Choice of States + FF

Should be apparent there are many ways to encode state, and many choice of FF to use. We are unlikely to ‘happen’ to choose best implementation, so will use design tools in real life…

31/07/2012 Colin O’Flynn - CC BY-SA 17

slide-18
SLIDE 18

FINITE STATE MACHINE – DESIGN EXAMPLE #1

31/07/2012 Colin O’Flynn - CC BY-SA 18

slide-19
SLIDE 19

Specifications

Design a simple stoplight. Assume one pair of lights is North-South (NS), one is East-West (EW). Pattern is:

  • Green 10 seconds
  • Yellow 1 second
  • Red 1 second

In each direction – that is to say 1s overlap where both sets red. Assume you have 1 Hz clock available.

31/07/2012 Colin O’Flynn - CC BY-SA 19

slide-20
SLIDE 20

Step 1: Understand Problem

31/07/2012 Colin O’Flynn - CC BY-SA 20

slide-21
SLIDE 21

Step 2: Initial State Diagram

31/07/2012 Colin O’Flynn - CC BY-SA 21

slide-22
SLIDE 22

Step 3: Minimized State Diagram

31/07/2012 Colin O’Flynn - CC BY-SA 22

slide-23
SLIDE 23

Step 4: State Transition Table

31/07/2012 Colin O’Flynn - CC BY-SA 23

A B C CNT=10 (D) A+ B+ C+ Note X 1 Red - Reset 1 1 Green NS 1 1 1 Green NS 1 X 1 1 Yellow NS 1 1 X 1 1 Red - Reset 1 1 1 1 Green EW 1 1 1 1 1 Green EW 1 1 X Yellow EW

slide-24
SLIDE 24

Step 5: Choose Flip-Flop

We will use D flip-flops for design convience

31/07/2012 Colin O’Flynn - CC BY-SA 24

slide-25
SLIDE 25

Step 6: Implement

Following shows K-maps of state transition +

  • utputs

31/07/2012 Colin O’Flynn - CC BY-SA 25

slide-26
SLIDE 26

K-Mapping: A State

31/07/2012 Colin O’Flynn - CC BY-SA 26

1 1 1 1

slide-27
SLIDE 27

Note: Here both 1’s and 0’s are drawn on K-Map. This is because the given State Transition Table didn’t include the don’t care states. We can fill in 1’s and 0’s from given, and any blank are don’t cares.

31/07/2012 Colin O’Flynn - CC BY-SA 27

slide-28
SLIDE 28

K-Mapping: A State

31/07/2012 Colin O’Flynn - CC BY-SA 28

1 1 1 1 ? ? ? ?

slide-29
SLIDE 29

K-Mapping: A State

31/07/2012 Colin O’Flynn - CC BY-SA 29

1 1 1 1 ? ? ? ?

+

A =B•C + A•C

slide-30
SLIDE 30

K-Mapping: B State

31/07/2012 Colin O’Flynn - CC BY-SA 30

1 1 1 1

slide-31
SLIDE 31

K-Mapping: B State

31/07/2012 Colin O’Flynn - CC BY-SA 31

1 1 1 1

+

B =A•B•C B•C•D +

slide-32
SLIDE 32

K-Mapping: C State

31/07/2012 Colin O’Flynn - CC BY-SA 32

1 1 1 1 1 1 1 1

slide-33
SLIDE 33

K-Mapping: C State

31/07/2012 Colin O’Flynn - CC BY-SA 33

1 1 1 1 1 1 1 1

+

C =A•C B•C•D A•B + +

slide-34
SLIDE 34

D Flip-Flop Implementation

31/07/2012 Colin O’Flynn - CC BY-SA 34

+

B =A•B•C B•C•D +

+

A =B•C + A•C

+

C =A•C B•C•D A•B + +

slide-35
SLIDE 35

Outputs

31/07/2012 Colin O’Flynn - CC BY-SA 35

A B C Red Yellow Green Red Yellow Green Reset Note 0 0 0 1 1 1 Red - Reset 0 0 1 0 1 1 Green NS 0 1 0 0 1 1 Yellow NS 0 1 1 1 1 1 Red - Reset 1 0 0 1 1 ???? 1 0 1 1 1 Green EW 1 1 0 1 1 Yellow EW 1 1 1 1 1 ????

slide-36
SLIDE 36

Output K-Maps

31/07/2012 Colin O’Flynn - CC BY-SA 36

NS Red NS Yellow NS Green 1 1 1 1 1 1 1 1

NS NS NS

R =A + B C + B C Y =A B C G =A B C

slide-37
SLIDE 37

Output K-Maps

31/07/2012 Colin O’Flynn - CC BY-SA 37

EW Red EW Yellow EW Green 1 1 1 1 1 1 1 1

EW EW EW

R =A + B C + B C Y =A B C G =A B C

slide-38
SLIDE 38

Output K-Maps

31/07/2012 Colin O’Flynn - CC BY-SA 38

Reset 1 1

Reset=A B C + A B C

slide-39
SLIDE 39

31/07/2012 Colin O’Flynn - CC BY-SA 39

slide-40
SLIDE 40

Simulation Results

31/07/2012 Colin O’Flynn - CC BY-SA 40

slide-41
SLIDE 41

Sidenote on Schematic Notation

31/07/2012 Colin O’Flynn - CC BY-SA 41

slide-42
SLIDE 42

Creating with ISE: Step 1 Place Part

31/07/2012 Colin O’Flynn - CC BY-SA 42

slide-43
SLIDE 43

Creating with ISE: Step 2 Place SHORT wires

31/07/2012 Colin O’Flynn - CC BY-SA 43

slide-44
SLIDE 44

Creating with ISE: Step 3A: Rename Net

31/07/2012 Colin O’Flynn - CC BY-SA 44

Right-click on net (must be careful not to select part or open port), you should get Rename Selected Net

slide-45
SLIDE 45

Creating with ISE: Step 3B: Rename Net

31/07/2012 Colin O’Flynn - CC BY-SA 45

Put name in. Select ‘Rename Branch’ to change only this small section attached to the chip, which is what you want. Rename the Branch’s net changes the name across ENTIRE schematic

slide-46
SLIDE 46

Creating with ISE: Step 3C: Rename Net

31/07/2012 Colin O’Flynn - CC BY-SA 46

This is telling you that your pin is going to be connected

  • elsewhere. This is ok, hit Yes.
slide-47
SLIDE 47

Creating with ISE: Step 4 - Done

31/07/2012 Colin O’Flynn - CC BY-SA 47

Always use net names for larger schematics. It more easily allows you to change which input connects to a gate, since you can just rename that branch (Be SURE that ‘Rename Branch’ is selected or you change across entire schematic)

slide-48
SLIDE 48

TYPES OF STATE MACHINE

31/07/2012 Colin O’Flynn - CC BY-SA 48

slide-49
SLIDE 49

31/07/2012 Colin O’Flynn - CC BY-SA 49

State Quarter Loonie Next State Release 0.00 0.00 0.00 1 1.00 0.00 1 0.25 0.00 1 1 ? 0.25 0.25 0.25 1 1.25 0.25 1 0.50 0.25 1 1 ? 0.50 0.50 0.50 1 1.25 0.50 1 0.75 0.50 1 1 ? 0.75 0.75 0.75 1 1.25 0.75 1 1.00 0.75 ? 1.00 1.00 1.00 1 1.25 1.00 1 1.25 1.00 1 1 ? 1.25 ? ? 0.00 1

slide-50
SLIDE 50

31/07/2012 Colin O’Flynn - CC BY-SA 50

State Quarter Loonie Next State Release 0.00 0.00 0.00 1 1.00 0.00 1 0.25 0.00 1 1 ? 0.25 0.25 0.25 1 0.00 1 0.25 1 0.50 0.25 1 1 ? 0.50 0.50 0.50 1 0.00 1 0.50 1 0.75 0.50 1 1 ? 0.75 0.75 0.75 1 0.00 1 0.75 1 1.00 0.75 ? 1.00 1.00 1.00 1 0.00 1 1.00 1 0.00 1 1.00 1 1 ?

slide-51
SLIDE 51

Mealy Machine

Outputs dependant on state AND inputs

31/07/2012 Colin O’Flynn - CC BY-SA 51 Image source: http://commons.wikimedia.org/wiki/File:Mealy.png

slide-52
SLIDE 52

Moore Machine

Outputs dependant only on state

31/07/2012 Colin O’Flynn - CC BY-SA 52 Image derived from: http://commons.wikimedia.org/wiki/File:Mealy.png

1

slide-53
SLIDE 53

DESIGN EXAMPLE: MEALY MACHINE VS. MOORE MACHINE

31/07/2012 Colin O’Flynn - CC BY-SA 53

slide-54
SLIDE 54

Description of Problem

I need a controller for a lamp with ON & OFF

  • pushbuttons. The buttons are momentary only,

so the controller needs state. A buzzer should beep whenever the state changes.

31/07/2012 Colin O’Flynn - CC BY-SA 54

slide-55
SLIDE 55

Step 1: Understand the Problem

31/07/2012 Colin O’Flynn - CC BY-SA 55

slide-56
SLIDE 56

Step 2: State Transition

31/07/2012 Colin O’Flynn - CC BY-SA 56

slide-57
SLIDE 57

Step 3: State Transition Diagram (Mealy)

31/07/2012 Colin O’Flynn - CC BY-SA 57

slide-58
SLIDE 58

Step 3: State Transition Diagram (Moore)

31/07/2012 Colin O’Flynn - CC BY-SA 58

slide-59
SLIDE 59

Step 4: State Transition Table (Mealy)

31/07/2012 Colin O’Flynn - CC BY-SA 59

Initial State On Off Next State Lamp Buzzer 1 1 1 1 1 1 1 1 1 1 1 1

slide-60
SLIDE 60

Step 4: State Transition Table (Mealy)

31/07/2012 Colin O’Flynn - CC BY-SA 60

Initial State On Off Next State Lamp Buzzer 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

slide-61
SLIDE 61

Step 4: State Transition Table (Moore)

31/07/2012 Colin O’Flynn - CC BY-SA 61

Initial State On Off Next State Lamp Buzzer

00 00 1 00 1 00 1 1 01 ? ? 10 10 1 10 1 10 1 1 11 ? ?

slide-62
SLIDE 62

Step 4: State Transition Table (Moore)

31/07/2012 Colin O’Flynn - CC BY-SA 62

Initial State On Off Next State Lamp Buzzer

00 00 00 1 00 00 1 01 00 1 1 00 01 ? ? 10 1 10 10 1 10 1 11 1 10 1 10 1 10 1 1 10 1 11 ? ? 00 1 1

slide-63
SLIDE 63

Note on Moore Machine

31/07/2012 Colin O’Flynn - CC BY-SA 63

(Ignore the function of this, since it’s nonsense!)

slide-64
SLIDE 64

Note on Mealy Machine

31/07/2012 Colin O’Flynn - CC BY-SA 64

Asynchronous Output

slide-65
SLIDE 65

Note on Mealy Machine

31/07/2012 Colin O’Flynn - CC BY-SA 65

Synchronous Output

slide-66
SLIDE 66

CHOICE OF STATE ENCODING

31/07/2012 Colin O’Flynn - CC BY-SA 66

slide-67
SLIDE 67

Binary Encoding

31/07/2012 Colin O’Flynn - CC BY-SA 67

Initial State On Off Next State

00 00 00 1 00 00 1 01 00 1 1 00 01 ? ? 10 10 10 10 1 11 10 1 10 10 1 1 10 11 ? ? 00

slide-68
SLIDE 68

Why Binary Encoding?

31/07/2012 Colin O’Flynn - CC BY-SA 68

slide-69
SLIDE 69

One-Hot Encoding

31/07/2012 Colin O’Flynn - CC BY-SA 69

Initial State On Off Next State

0001 0001 0001 1 0001 0001 1 0010 0001 1 1 0001 0010 ? ? 0100 0100 0100 0100 1 1000 0100 1 0100 0100 1 1 0100 1000 ? ? 0001

slide-70
SLIDE 70

Why One-Hot Encoding?

31/07/2012 Colin O’Flynn - CC BY-SA 70

slide-71
SLIDE 71

Gray Coding

31/07/2012 Colin O’Flynn - CC BY-SA 71

Initial State On Off Next State

00 00 00 1 00 00 1 01 00 1 1 00 01 ? ? 11 11 11 11 1 10 11 1 11 11 1 1 11 10 ? ? 00

slide-72
SLIDE 72

Why Gray Coding?

31/07/2012 Colin O’Flynn - CC BY-SA 72

slide-73
SLIDE 73

Section Summary

  • See ECED2200 Notes
  • Bebop to the Boolean Boogie Chapter 12

31/07/2012 Colin O’Flynn - CC BY-SA 73