Output and Actions � Actions can be generated either at state entrance, exit or at trigger level slide 8 Use of Variables LampOff on()/ctr = ctr+1; off() lampOn Page 4 LampOff on()/print("on"); off() lampOn Mealy automaton Integer ctr; (C) Ludovic Apvrille <strong>UML</strong> <strong>for</strong> <strong>Embedded</strong> <strong>Systems</strong> - Fall 2012
slide 9 slide 10 Mealy Machines � Mealy machines • Hopcroft and Ullman (1979, 42), Salomaa (1973, 31) • Finite-state machines - Take a string on an input alphabet - Producing a string of equal length on an output alphabet. � Formally, a Mealy machine is a six-tuple M = (Q, Σ, Γ, δ, λ, q 1) • where - Q = (q 1, q 2, …, q |Q|) is a finite set of states; - Σ = (σ 1, σ 2, …, σ |Σ|) is a finite input alphabet; - Γ = (γ 1, γ 2, …, γ |Γ|) is a finite output alphabet; - δ : Q x Σ → Q is the next-state function, such that a machine in state q j, after reading symbol σ k, moves to state δ(q j, σ k) ∈ Q - λ : Q x Σ → Γ is the output function, such that a machine in state q j, after reading symbol σ k, writes symbol λ(q j, σ k) ∈ Γ ; and - q 1 ∈ Q is the initial state in which the machine is found be<strong>for</strong>e the first symbol of a string is processed (C) Ludovic Apvrille <strong>UML</strong> <strong>for</strong> <strong>Embedded</strong> <strong>Systems</strong> - Fall 2012 Example � Let M = (Q, Σ, Γ, δ, λ, q1) with • Q = {q1, q2} • Σ = {sig1, sig2} • Γ = {out1, out2} • δ(q1, sig1) = q1; δ(q1, sig2) = q2; • δ(q2, sig1) = q2; δ(q2, sig2) = q1; • λ(q1, sig1) = out1; λ(q1, sig2) = out2; • λ(q2, sig1) = out2; λ(q2, sig2) = out1; � Propose a graphical representation of this machine (C) Ludovic Apvrille <strong>UML</strong> <strong>for</strong> <strong>Embedded</strong> <strong>Systems</strong> - Fall 2012 Page 5