week 2/3 1.system interconnections (block diagrams) 2.finite state machines (chapter 3)

33
Week 2/3 1. System interconnections (block diagrams) 2. Finite State Machines (Chapter 3)

Post on 19-Dec-2015

215 views

Category:

Documents


2 download

TRANSCRIPT

Week 2/3

1. System interconnections (block diagrams)2. Finite State Machines (Chapter 3)

Recall

A system S is a function : InputSignals OutputSignalswith

InputSignals = [D R],OutputSignals = [D’ R’]

Sx InputSignals y = S(x) OutputSignals

10Evans: [Ints+ {enter, leave}] [Ints+ Integers+ ]

10Evansu = (e,l,l,e,e,… ) y = (6,5,4,5,6,… )

initial number in room

5

InputSignals OutputSignals

The system 10Evans can be specified as follows: y = 10Evans (u), and for all n Ints+ , y(n) is given by

where

How do you ‘give’ S?

Su Speeds y=S(u) Positions

Speeds = [[0,5] Reals], Positions = [[0,5] Reals]

y(0)

initial position

Other examples: TopicNotes/Systems/DTMF

KeypadSequences

Sounds

DTMF

DTMF: [Nats KeypadSymbols] [Time Pressure]

Interconnecting Systems:Block Diagrams

Voice [Time Pressure]; MicOutput [Time Volts]

Microphone: [Time Pressure] [Time Volts]; AGCSound [Time Pressure]; Volume [Time Volts]

VolumeSensor: [Time Pressure] [Time Volts];

Output [Time Volts]

AGC: [Time Volts] x [Time Volts] [Time Pressure]

v1 = Microphone (u)s = AGC (v1, v2)v2 = VolumeSensor(s)y = v2

MicOutputAGCSound

Microphone AGC

Volume

VolumeSensor

Voice

u v1 s

v2

Output

y

4 equations4 unknowns

Finite State Machines

Recognizerx = (x(0), x(1), x(2), …) y = (y(0), y(1), y(2), …)

x InputSignals = [Nats0 {0,1}]y OutputSignals = [Nats0 {t,f}]

x InputSignals y OutputSignals

Recognizer(x)(n) = t, if (x(n-2),x(n-1),x(n)) = (0,0,0) = f, else

Recognizer((0,1,0,0,0,0,1,1, …)) = (f,f,f,f,t,t,f,f, …)

init

a

b

0/f 0/f

0/t

1/f

1/f 1/f

x InputSignals yOutputSignals

x = (0, 1, 0, 0, 0, 0, 1, 1, …)s = (init, a, init, a, b, b, b, init, …)y = (f, f, f, f, t, t, f, f, …)

s(0) = init(s(n+1), y(n)) = update (s(n), x(n)), n = 0,1,…

init

a

b

{0}/f {0}/f

{0}/t

{1,2}/f

{1,2}/f {1,2}/f

x[Nats0 {0,1,2}] y[Nats0 {t,f}]

x = (0, 2, 0, 0, 0, 0, 1, 2, …)s = (init, a, init, a, b, b, b, init, …)y = (f, f, f, f, f, t, t, f, …)

s(0) = init(s(n+1), y(n)) = update (s(n), x(n)), n = 0,1,…

guard

What does this machine with 4 states do?

‘1,2’

‘0’

’00’

{0}/f {0}/f

{0}/t

{1,2}/f

{1,2}/f {1,2}/f

y[Nats0 {t,f}]

init{0}/f

{1,2}/f

x[Nats0 {0,1,2}]

It also implements Recognizer

Can a machine with 2 states implement Recognizer?

Formal definition of state machine

1. Sets and functions2. Bubble and arcs3. Tabular

A state machine is a 5-tuple

StateMachine = (States, Inputs, Outputs, update, initialState)States is the state space

Inputs is the input alphabet

Outputs is the output alphabet

initialState States is the initial state

update: States x Inputs States x Outputs is the update function

Sets and function

For Recognizer

States = {init, a, b}Inputs = {0,1}Outputs = {t, f}initialState = init

update(init, 0) = (0, f)update(init, 1) = (init, f)…

update: States x Inputs States x Outputs is given by:

currentstate

currentinput

nextstate

currentoutput

(s(n+1), y(n)) = update(s(n), x(n))

It is useful sometimes to express the update function astwo functions:

update = (nextState, output),nextState: States x Inputs States output: States x Inputs Outputs

so thatupdate(s(n), x(n)) = (s(n+1), y(n))nextState(s(n), x(n)) = s(n+1)output(s(n), x(n)) = y(n)

Operation of state machine

Given S = (States, Inputs, Outputs, update, initialState)

InputSignals = [Nats0 Inputs]

OutputSignals = [Nats0 Outputs]

An input signal x = (x(0), x(1), … , x(n), …) determines thestate response s: Nats0 States and theoutput signal y: Nats0 Outputs

by the recursion, s(0) = initState, and n 0,(s(n+1), y(n)) = update (s(n), x(n))

Thus S determines an input-output function (system)F: InputSignals OutputSignals

For Recognizer

InputSignals = [Nats0 {0,1}]OutputSignals = [Nats0 {t,f}]

The input-output function (system) is F:

x InputSignals, n Nats0

y(n) = F(x)(n) = t, if (x(n-2), x(n-1)), x(0)) = (0,0,0) = f, else

Stuttering

It is useful to introduce a stuttering symbolabsent

We insist that absent Inputs and absent Outputs

We require that for all states s Statesupdate(s, absent) = (s, absent)

A modified Recognizer

init

a

b

0/abs 0/abs

0/t

1/abs

1/abs 1/abs

x InputSignals yOutputSignals

x = (0, 1, 0, 0, 0, 0, 1, 1, …)s = (init, a, init, a, b, b, b, init, …)y = (abs, abs, abs, abs, t, t, abs, abs, …)

Bubbles and arcs

Shorthand: the ‘else’ loop

init

a

b

{0}/abs {0}/abs

else

else

x[Nats0

{0,1,2, absent}]

y[Nats0

{t,absent}]

else 0/t

Shorthand: the implicit ‘else’ self loop

init

a

b

{0}/abs {0}/abs

else

else

x[Nats0

{0,1,2, absent}]

y[Nats0

{t,absent}]

else 0/t

Shorthand: the implicit ‘absent’

init

a

b

{0}/ {0}/

else

else

x[Nats0

{0,1,2, absent}]

y[Nats0

{t,absent}]

else 0/t

absabs

The guards are subsets of Inputs

• guards on different arcs from same state are disjoint (determinism)• union of all guards (from same state) = Inputs; (reactive system)• guard on ‘else’ is complement of remaining guards• guards may be defined using convenient notation, eg. if Inputs = {a, b, c}, a = {b,c}

Tabular Representation

All information about a state machine is given itsupdate function. If States and Inputs are finite,update can be given as a table

(next state, output) if input iscurrentstate

init

a

b

0 1 absent

(a, f)

(b, f)

(b, t)

(init, f)

(init, f)

(init, f)

(init, abs)

(a, abs)

(b, abs)

System requirements in English

System specification as

F: InputSignals OutputSignals

System implementation as state machineDescribed by set-and-functions 5-tuple,transition diagram, or table

State machine design process

0 1

{coin5}/safe

{tick}/expired

5

{tick}/expired

{tick}/safe

...

{coin5}/safe

... 25

{tick}/safe

{coin25}/safe {coin25}/safe

60

{tick}/safe

...

{coin5,coin25}/safe

{coin5}/safe

{coin25}/safe

{coin5}/safe

60-min Parking meter

{tick, coin5,coin25, absent}

{safe, expired,absent}

Parking meter

topics/state/parking meter

Answering machine

topics/state/answering machine

table