Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Week 2/3 1.System interconnections (block diagrams) 2.Finite State Machines (Chapter 3)"— Presentation transcript:

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

2 Recall

3 A system S is a function : InputSignals  OutputSignals with InputSignals = [D  R], OutputSignals = [D’  R’] S x  InputSignals y = S(x)  OutputSignals

4 10Evans: [Ints +  {enter, leave}]  [Ints +  Integers + ] 10Evans u = (e,l,l,e,e,… ) y = (6,5,4,5,6,… ) initial number in room 5 InputSignals OutputSignals

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

6 How do you ‘give’ S? S u  Speeds y=S(u)  Positions Speeds = [[0,5]  Reals], Positions = [[0,5]  Reals] y(0) initial position

7 Other examples: TopicNotes/Systems/DTMFTopicNotes/Systems/DTMF KeypadSequences Sounds DTMF DTMF: [Nats  KeypadSymbols]  [Time  Pressure]

8 Interconnecting Systems: Block Diagrams

9 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] v 1 = Microphone (u) s = AGC (v 1, v 2 ) v 2 = VolumeSensor(s) y = v 2 MicOutput AGCSound Microphone AGC Volume Sensor Voice uv1v1 s v2v2 Output y 4 equations 4 unknowns

10 Finite State Machines

11 Recognizer x = (x(0), x(1), x(2), …) y = (y(0), y(1), y(2), …) x  InputSignals = [Nats 0  {0,1}] y  OutputSignals = [Nats 0  {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, …)

12 init a b 0/f 0/t 1/f x  InputSignals y  OutputSignals 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,…

13 init a b {0}/f {0}/t {1,2}/f x  [Nats 0  {0,1,2}] y  [Nats 0  {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

14 What does this machine with 4 states do? ‘1,2’ ‘0’ ’00’ {0}/f {0}/t {1,2}/f y  [Nats 0  {t,f}] init {0}/f {1,2}/f x  [Nats 0  {0,1,2}] It also implements Recognizer Can a machine with 2 states implement Recognizer?

15 Formal definition of state machine 1.Sets and functions 2.Bubble and arcs 3.Tabular

16 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

17 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: current state current input next state current output (s(n+1), y(n)) = update(s(n), x(n))

18 It is useful sometimes to express the update function as two functions: update = (nextState, output), nextState: States x Inputs  States output: States x Inputs  Outputs so that update(s(n), x(n)) = (s(n+1), y(n)) nextState(s(n), x(n)) = s(n+1) output(s(n), x(n)) = y(n)

19 Operation of state machine Given S = (States, Inputs, Outputs, update, initialState) InputSignals = [Nats 0  Inputs] OutputSignals = [Nats 0  Outputs] An input signal x = (x(0), x(1), …, x(n), …) determines the state response s: Nats 0  States and the output signal y: Nats 0  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

20 For Recognizer InputSignals = [Nats 0  {0,1}] OutputSignals = [Nats 0  {t,f}] The input-output function (system) is F:  x  InputSignals,  n  Nats 0 y(n) = F(x)(n) = t, if (x(n-2), x(n-1)), x(0)) = (0,0,0) = f, else

21 Stuttering

22 It is useful to introduce a stuttering symbol absent We insist that absent  Inputs and absent  Outputs We require that for all states s  States update(s, absent) = (s, absent)

23 A modified Recognizer init a b 0/abs 0/t 1/abs x  InputSignals y  OutputSignals 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, …)

24 Bubbles and arcs

25 Shorthand: the ‘else’ loop init a b {0}/abs else x  [Nats 0  {0,1,2, absent}] y  [Nats 0  {t,absent}] else 0/t

26 Shorthand: the implicit ‘else’ self loop init a b {0}/abs else x  [Nats 0  {0,1,2, absent}] y  [Nats 0  {t,absent}] else 0/t

27 Shorthand: the implicit ‘absent’ init a b {0}/ else x  [Nats 0  {0,1,2, absent}] y  [Nats 0  {t,absent}] else 0/t abs

28 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}

29 Tabular Representation

30 All information about a state machine is given its update function. If States and Inputs are finite, update can be given as a table (next state, output) if input is current state init a b 01absent (a, f) (b, f) (b, t) (init, f) (init, abs) (a, abs) (b, abs)

31 System requirements in English System specification as F: InputSignals  OutputSignals System implementation as state machine Described by set-and-functions 5-tuple, transition diagram, or table State machine design process

32 60-min Parking meter {tick, coin5, coin25, absent} {safe, expired, absent} Parking meter topics/state/parking meter

33 Answering machine topics/state/answering machine table


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

Similar presentations


Ads by Google