Docsity

Finite State Machines in Digital Design: Moore and Mealy Machines - Prof. Gabriel Loh, Study notes of Computer Science

Partial preview of the text

Download Finite State Machines in Digital Design: Moore and Mealy Machines - Prof. Gabriel Loh and more Study notes Computer Science in PDF only on Docsity!

CS3220: Processor DesignCS3220:

Processor Design

September

Finite State Machines

• As

we

said

last

time,

FSM’s

consist

of:

State

State

transition

function

and

Output

function

– State,

State

transition

function,

and

Output

function

• Formally,

a

finite

state

machine

is

a

digital

device

having:

– A

finite

set

of

states

S

1

S

2

S

k

(where

k

is

the

number

of

A

finite

set

of

states

S

1

S

2

S

k

(where

k

is

the

number

of

states).

Optionally,

one

of

these

(S

I

is

distinguished

as

the

initial

state

of

the

FSM.

A

finite

number

of

binary

inputs

I

I

I

– A

finite

number

of

binary

inputs

I

1

I

2

I

m

– A

finite

number

of

binary

output

O

1

O

2

O

n

– A

set

of

state

transition

rules

specifying,

for

each

choice

of

current

state

Ss

and

input

values

I

1

I

2

I

m

a

next

state

S

s’

– A

set

of

output

rules

specifying,

for

each

choice

of

current

state

Ss

and

input

values

I

I

I

the

binary

value

at

each

output

Ss

and

input

values

I

1

I

2

I

m

the

binary

value

at

each

output.

Example: Vending Machine

p

g

Output

Logic

Dispense

Coke

Coin

Return

State

Next

Logic

Dime

Quarter

p

Return

Change

StateLogic

State Transition Diagram

g

Q

D

D

D

D

Dispense

Coke

40

D

D

change

CR

Return

Coins

Write

out

state

transition

table

Write

out

output

function

table

Implement

design

State Transition Diagram (again)

g

( g

Q

D

D

D

D

D

CR

Return

Change

Dispense

Coke

Note:

Outputs

are

now

associated

with

the

transitions/edges

How to Choose State Assignments?

g

• Can

be

arbitrary

change=

change=

change=

• Does

it

matter?

depends

More

on

this

in

later

lecture

Does

it

matter?

depends

o

State

encoding

can

make

transition

function

simpler

or

more

complex

o

Can also

impact

complexity

of

output

function

LED Counter Example

p

bit

timer,

bit

counter

(for

LEDs)

from

last

week

24’h000000, 8’h

24’h000001, 8’h

24’h000002, 8’h

24’h000003, 8’h

24’hFFFFFF, 8’h

24’h000000, 8’h

24’h000001, 8’h

24’h000002, 8’h

24’h000003, 8’h

24’hFFFFFF, 8’h

24’h000000, 8’h

24’h000001, 8’h

24’h000002, 8’h

24’h000003, 8’h

24’hFFFFFF, 8’h

32

states

(over

billion)

pretty hard

to

think

about

24’h000000, 8’hFE 24’h000000, 8’hFF

24’h000001, 8’hFE

24’h000002, 8’hFE

24’h000003, 8’hFE

24’hFFFFFF, 8’hFE

24’h000001, 8’hFF

24’h000002, 8’hFF

24’h000003, 8’hFF

24’hFFFFFF, 8’hFF

Plus

four

bits

of

input

(not

counting reset),

which

means

state

transition

table

needs

36

entries!

000000, 8

,

,

,

, 8

Functional Partitioning of FSMs

g

We

know

that

the

“horizontal”

transitions

in

the

previous

figure

are

independent

and

basically

just

perform

the

actions

figure

are

independent

and

basically

just

perform

the

actions

of

a

counter

Decompose

the

FSM

into

smaller

components

timer+counter states

Massive

Combinatorial

L

i

speed

direction

LED

output

Logic

speed,

direction

LED

output

XOR

counter_go

LED

output

timer

state

+n

counter

state

p

Much

easier

and

intuitive

to

think

about!

speed

direction,

counter_go