eecs150 - digital design lecture 9 - finite state machines 1

16
Spring 2002 EECS150 - Lec0-intro Page 1 EECS150 - Digital Design Lecture 9 - Finite State Machines 1 February 19, 2002 John Wawrzynek

Upload: caldwell-humphrey

Post on 31-Dec-2015

31 views

Category:

Documents


0 download

DESCRIPTION

EECS150 - Digital Design Lecture 9 - Finite State Machines 1. February 19, 2002 John Wawrzynek. Parity Checker Example. A string of bits has “even parity” if the number of 1’s in the string is even. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 1

EECS150 - Digital DesignLecture 9 - Finite State Machines 1

February 19, 2002

John Wawrzynek

Page 2: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 2

Parity Checker ExampleA string of bits has “even parity” if the number of 1’s in the string is even.

• Design a circuit that accepts a bit-serial stream of bits and outputs a 0 if the parity thus far is even and outputs a 1 if odd:

• Can you guess a circuit that performs this function?

Page 3: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 3

Formal Design Process

• “State Transition Diagram”– circuit is in one of two states.– transition on each cycle with each

new input over exactly one arc (edge).

– Output depends on which state the circuit is in.

Page 4: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 4

Formal Design Process• State Transition Table:

• Invent a code to represent states:Let 0 = EVEN state, 1 = ODD state

present nextstate OUT IN state

EVEN 0 0 EVEN EVEN 0 1 ODD ODD 1 0 ODD ODD 1 1 EVEN

present state (ps) OUT IN next state (ns) 0 0 0 0 0 0 1 1 1 1 0 1 1 1 1 0

Derive logic equations from table (how?):OUT = PS

NS = PS xor IN

Page 5: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 5

Formal Design Process

• Circuit Diagram:

– xor gate for ns calculation– DFF to hold present state– no logic needed for output

Logic equations from table:OUT = PS

NS = PS xor IN

nsps

• Review of Design Steps:

1. Circuit functional specification

2. State Transition Diagram

3. Symbolic State Transition Table

4. Encoded State Transition Table

5. Derive Logic Equations

6. Circuit Diagram

FFs for state

CL for NS and OUT

Page 6: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 6

Finite State Machines (FSMs)• Type of sequential circuit:

– output depends on present and past inputs

• effect of past inputs is represented by the current state

• Behavior is represented by State Transition Diagram:– traverse one edge per cycle.

Page 7: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 7

FSM Implementation

• FFs form state register• number of FFs at most log2(number of states)• CL implements calculates next state and output

Page 8: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 8

Combination Lock Example

• Used to allow entry to a locked room:2-bit serial combination. Example 01,11:

1. Set switches to 01, press ENTER

2. Set switches to 11, press ENTER

3. OPEN is asserted (OPEN=1).

If wrong code, ERROR is asserted (after second combo word entry).

Press Reset at anytime to try again.

Page 9: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 9

Announcements

• Exam Friday– 5-8pm, lectures 1-8, closed book/notes

• Review Session Tonight– 8pm, Woz Lounge, Soda Hall

• Interesting Seminar Tomorrow– "The Sight & Sound of Information - Defining the Future Beyond the

PC" Brian Halla, CEO, National Semiconductor Corporation

Page 10: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 10

Combinational Lock STD

Page 11: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 11

Symbolic State Transition TableRESET ENTER COM1 COM2 Preset State Next State OPEN ERROR0 0 * * START START 0 00 1 0 * START BAD1 0 00 1 1 * START OK1 0 00 0 * * OK1 OK1 0 00 1 * 0 OK1 BAD2 0 00 1 * 1 OK1 OK2 0 00 * * * OK2 OK2 1 00 0 * * BAD1 BAD1 0 00 1 * * BAD1 BAD2 0 00 * * * BAD2 BAD2 0 11 * * * * START 0 0

Decoder logic for checkingcombination (01,11):

Page 12: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 12

Encoded ST Table

0 0 0 0 0 0 0 0 00 0 1 0 0 0 0 0 00 1 0 0 0 0 0 0 00 1 1 0 0 0 0 0 01 0 0 0 0 0 1 0 01 0 1 0 0 0 1 0 01 1 0 0 0 0 0 0 11 1 1 0 0 0 0 0 10 0 0 0 0 1 0 0 10 0 1 0 0 1 0 0 10 1 0 0 0 1 0 0 10 1 1 0 0 1 0 0 11 0 0 0 0 1 1 0 11 1 0 0 0 1 1 0 11 0 1 0 0 1 0 1 11 1 1 0 0 1 0 1 10 0 0 0 1 1 0 1 10 0 1 0 1 1 0 1 10 1 0 0 1 1 0 1 10 1 1 0 1 1 0 1 11 0 0 0 1 1 0 1 11 0 1 0 1 1 0 1 11 1 0 0 1 1 0 1 11 1 1 0 1 1 0 1 10 0 0 1 0 0 1 0 00 0 1 1 0 0 1 0 00 1 0 1 0 0 1 0 00 1 1 1 0 0 1 0 01 0 0 1 0 0 1 0 11 0 1 1 0 0 1 0 11 1 0 1 0 0 1 0 11 1 1 1 0 0 1 0 10 0 0 1 0 1 1 0 10 0 1 1 0 1 1 0 10 1 0 1 0 1 1 0 10 1 1 1 0 1 1 0 11 0 0 1 0 1 1 0 11 0 1 1 0 1 1 0 11 1 0 1 0 1 1 0 11 1 1 1 0 1 1 0 1

• Assign states:START=000, OK1=001, OK2=011BAD1=100, BAD2=101

• Omit reset. Assume that primitive flip-flops has reset input.

• Rows not shown have don’t cares in output. Correspond to invalid PS values.

00 01 11 1000

10

1110

cdef

ab = 10

00 01 11 1000

10

1110

ab = 11

00 01 11 1000

10

1110

ab = 01

00 01 11 1000

10

1110

ab = 00

00 01 11 1000

10

1110

cdef

ab = 10

00 01 11 1000

10

1110

ab = 11

00 01 11 1000

10

1110

ab = 01

00 01 11 1000

10

1110

ab = 00

00 01 11 1000

10

1110

cdef

ab = 10

00 01 11 1000

10

1110

ab = 11

00 01 11 1000

10

1110

ab = 01

00 01 11 1000

10

1110

ab = 00

NS2 NS1 NS0

Page 13: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 13

FSM Implementation Notes• General FSM form:

• All examples so far generate output based only on the present state:

• Commonly name Moore Machine

Page 14: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 14

State Encoding

• In general:

# of possible state = 2# of FFs

• However, often more than log2(# of states) FFs are used, to simplify logic at the cost of more FFs.

• Extreme example is one-hot state encoding.

• One-hot encoding of states.

• One FF per state.

• Simple design procedure.

• Circuit matches state transition diagram.

• Can be costly for FSMs with large number of states

Page 15: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 15

One-hot encoded FSM• Even Parity Checker Circuit:

• In General: • FFs must be initialized for correct operation (only one 1)

Page 16: EECS150 - Digital Design Lecture 9 - Finite State Machines 1

Spring 2002 EECS150 - Lec0-intro Page 16

One-hot encoded combination lock