16
by Dr. Michael P. Frank, University of Florida Modified by Longin Jan Latecki, Temple University §13.2 – Finite State Machines with Output

by Dr. Michael P. Frank, University of Florida Modified by Longin Jan Latecki, Temple University

  • Upload
    khoi

  • View
    32

  • Download
    0

Embed Size (px)

DESCRIPTION

§13.2 – Finite State Machines with Output. by Dr. Michael P. Frank, University of Florida Modified by Longin Jan Latecki, Temple University. Remember the general picture of a computer as being a transition function T : S × I →S × O ? - PowerPoint PPT Presentation

Citation preview

Page 1: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

by Dr. Michael P. Frank, University of Florida

Modified by Longin Jan Latecki, Temple University

§13.2 – Finite State Machines with Output

Page 2: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

• Remember the general picture of a computer as Remember the general picture of a computer as being a transition function being a transition function TT::SS××II→S→S××OO??– If the state set If the state set SS is finite (not infinite), we call this is finite (not infinite), we call this

system a system a finite state machinefinite state machine..

• If the domain If the domain SS××II is reasonably small, then we can is reasonably small, then we can specify specify TT explicitly by writing out its complete explicitly by writing out its complete graph.graph.– However, this is practical only for machines that have a However, this is practical only for machines that have a

very small information capacity.very small information capacity.

Page 3: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

Size of FSMs• The information capacity of an FSM is The information capacity of an FSM is

CC = log | = log |SS||..– Thus, if we represent a machine having an information Thus, if we represent a machine having an information

capacity of capacity of CC bits as an FSM, then its state transition graph bits as an FSM, then its state transition graph will have will have ||SS| = 2| = 2CC nodes. nodes.

• EE..gg. suppose your desktop computer has a 512MB . suppose your desktop computer has a 512MB memory, and 60GB hard drive.memory, and 60GB hard drive.– Its information capacity, including the hard drive and memory Its information capacity, including the hard drive and memory

(and ignoring the CPU’s internal state), is then roughly (and ignoring the CPU’s internal state), is then roughly ~512×2~512×22323 + 60×2 + 60×23333 = = 519,691,042,816 519,691,042,816 bb..

– How many states would be needed to write out the machine’s How many states would be needed to write out the machine’s entire transition function graph?entire transition function graph?

2519,691,042,816 = A number having >1.7 trillion decimal digits!

Page 4: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

One Problem with FSMs as Models

• The FSM diagram of a reasonably-sized computer The FSM diagram of a reasonably-sized computer is more than astronomically huge.is more than astronomically huge.– Yet, we are able to design and build these computers Yet, we are able to design and build these computers

using only a modest amount of industrial resources.using only a modest amount of industrial resources.• Why is this possible?Why is this possible?

• Answer: Answer: A real computer has A real computer has regularitiesregularities in its in its transition function that are transition function that are not capturednot captured if we just if we just write out its FSM transition function explicitly.write out its FSM transition function explicitly.– I.e.I.e., a transition function can have a small, simple, , a transition function can have a small, simple,

regular description, even if its domain is enormous.regular description, even if its domain is enormous.

Page 5: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

Other Problems with FSM Model

• It ignores many important physical realities:It ignores many important physical realities:– How is the transition function’s structure to be encoded How is the transition function’s structure to be encoded

in physical hardware?in physical hardware?• How much hardware complexity is required to do this?How much hardware complexity is required to do this?

– How close in physical space is one bit’s worth of the How close in physical space is one bit’s worth of the machine’s information capacity to another?machine’s information capacity to another?

• How long does it take to communicate information from one How long does it take to communicate information from one part of the machine to another?part of the machine to another?

– How much energy gets dissipated to heat when the How much energy gets dissipated to heat when the machine updates its state?machine updates its state?

• How fast can the heat be removed, and how much does this How fast can the heat be removed, and how much does this impact the machine’s performance?impact the machine’s performance?

Page 6: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

Vending Machine Example

• Suppose a certain vending machine Suppose a certain vending machine accepts nickels, dimes, and quarters.accepts nickels, dimes, and quarters.– If >30If >30¢ is deposited, change is¢ is deposited, change is

immediately returned.immediately returned.

• If the “coke” button is pressed,If the “coke” button is pressed,the machine drops a coke.the machine drops a coke.– It can then accept a new payment.It can then accept a new payment.

Ignore any otherbuttons, bills,out of change,etc.

Page 7: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

Modeling the Machine

• Input symbol set: Input symbol set: II = { = {nnickel, ickel, ddime, ime, qquarter, uarter, bbutton}utton}– We could add “nothing” or We could add “nothing” or as an additional input as an additional input

symbol if we want.symbol if we want.• Representing “no input at a given time.”Representing “no input at a given time.”

• Output symbol set:Output symbol set: OO = { = {, 5¢, 10¢, 15¢, 20¢, 25¢, coke}, 5¢, 10¢, 15¢, 20¢, 25¢, coke}..

• State set:State set: SS = {0, 5, 10, 15, 20, 25, 30} = {0, 5, 10, 15, 20, 25, 30}..– Representing how much money has been taken. Representing how much money has been taken.

Page 8: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

Transition Function Table

Old Old statestate InputInput

New New statestate OutputOutput

00 nn 55

00 dd 1010

00 qq 2525

00 bb 00

55 nn 1010

55 dd 1515

55 qq 3030

55 bb 55

Old Old statestate InputInput

New New statestate OutputOutput

1010 nn 1515

1010 dd 2020

1010 qq 3030 55¢ ¢

1010 bb 1010

1515 nn 2020

1515 dd 2525

1515 qq 3030 1010¢ ¢

1515 bb 55

Page 9: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

Transition Function Table cont.

Old Old statestate InputInput

New New statestate OutputOutput

2020 nn 2525

2020 dd 3030

2020 qq 3030 1515¢ ¢

2020 bb 2020

2525 nn 3030

2525 dd 3030 5¢ 5¢

2525 qq 3030 20¢ 20¢

2525 bb 2525

Old Old statestate InputInput

New New statestate OutputOutput

3030 nn 3030 55¢¢

3030 dd 3030 1010¢ ¢

3030 qq 3030 2525¢ ¢

3030 bb 00 cokecoke

Page 10: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

Another Format: State Table

Old Old statestate

Input SymbolInput Symbol

nn dd qq bb

00 5,5, 10,10, 25,25, 0,0,

55 10,10, 15,15, 30,30, 5,5,

1010 15,15, 20,20, 30,530,5¢¢ 10,10,

1515 20,20, 25,25, 30,1030,10¢¢ 15,15,

2020 25,25, 30,30, 30,1530,15¢¢ 20,20,

2525 30,30, 30,530,5¢¢ 30,2030,20¢¢ 25,25,

3030 30,530,5¢¢ 30,1030,10¢¢ 30,2530,25¢¢ 0,coke0,coke

Each pair showsnew state,output symbol

Page 11: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

Directed-Graph State Diagram

• As you can see, these can get kind of busy.As you can see, these can get kind of busy.

0 5 10 15 20 25 30

q,5¢

n n ndq d

q

b b b b b b

n n n

q,25¢d,10¢n,5¢

d

d,5¢

q,20¢

q,15¢

q,10¢b,coke

Page 12: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

Formalizing FSMs

• Just like the general transition-function definition from Just like the general transition-function definition from earlier, but with the output function separated from the earlier, but with the output function separated from the transition function, and with the various sets added in, transition function, and with the various sets added in, along with an initial state.along with an initial state.

• A A finite-state machinefinite-state machine MM=(=(SS, , II, , OO, , ff, , gg, , ss00))– SS is the state set. is the state set.– II is the alphabet (vocabulary) of input symbols is the alphabet (vocabulary) of input symbols– OO is the alphabet (vocabulary) of output symbolsis the alphabet (vocabulary) of output symbols– ff is the state transition function is the state transition function– gg is the output function is the output function– ss00 is the initial state. is the initial state.

• Our transition function from before is Our transition function from before is TT = ( = (ff,,gg))..

Page 13: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

Construct a state table for the finite-state machine in Fig. 3.

Find the output string for the input 101011

Page 14: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University

Language recognizer:Construct a finite-state machine that outputs 1 iffthe input string read so far ends with 111.

A unit-delay machine: Construct a finite-state machine that delays an input string by one unit of time:Input: x1x2 … xk-1xk Output: 0x1x2 … xk-1

Page 15: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University
Page 16: by  Dr. Michael P. Frank, University of Florida  Modified by Longin Jan Latecki, Temple University