Mealy v/s. Moore
What is the difference between Mealy & Moore type of finite state mac开发者_运维知识库hines?
In a Moore machine the output produced is associated to the current state of the machine and on it only. In a Mealy machine, instead, it is associated to both a state and a specific input.
From a practical point of view you have that output is placed on states in a Moore machine (so every state has its ouput), while on the latter you have outputs on transitions (so an ouput is decided from the current state AND the outgoing transition)
Moore machine output is a function only of the state of the machine, Mealy machine output is a function of the state of the machine and its inputs.
Explanation by Example / Anecdote.
This is perhaps best illustrated with an example and an anecdote: I hate airports, and getting to them, but I love being on the plane:
State: In Taxi
(Event: pay the fare, and then transition to the next state:)
State: In Lounge
(Event: wait 2 hours, and transition to the next state: )
State: In Plane
But what is the outcome?
In a Mealy machine, the preceding state makes a difference - how you get there is very important.
In a Moore machine, how you get to a particular state makes no difference.
Let's add an outcome to the above to create a Moore representation of a state machine:
Example of a Moore Representation of a State Machine:
State: In Taxi
(Event: pay fare and then transition to the next state). (Outcome: unhappy).
State: In Lounge
(Event: wait 2 hours, and then transition to the next state) (outcome: unhappy)
State: In Plane (outcome: happy).
With a Moore representation the outcome is attached directly to the state. With a Mealy representation - the particular outcome/output depends on where you have come from. For example, if I can get to the plane without having to catch a taxi and wait in the lounge, then I would be happy. Inputs make a difference. The where you come from is important. A Mealy representation state machine allows for this to be shown in the diagram. In other words, the output/outcome is shown OUTSIDE the state, during the transition.
Moore machines are discrete dynamical systems which can be expressed using TLA+ syntax as follows:
/\ x[k + 1] = f[x[k], u[k]]
/\ y[k] = g[x[k]]
where x
the state, u
the input, y
the output, f
describes the transition relation (discrete dynamics) and g
the output map (here a state labeling) and k
denotes time (index in the sequence).
A Mealy machine is of a slightly more general form:
/\ x[k + 1] = f[x[k], u[k]]
/\ y[k] = g[x[k], u[k]]
Note that now g
is not a state labeling any more, it is an edge labeling.
They are not equivalent, in particular Moore machines are strictly causal, whereas Mealy machines are not.
For more details, refer to Lee and Seshia, Introduction to Embedded Systems, LeeSeshia.org, page 58.
Moore changes only after active clock pulse and Melay changes after every clock edges ("if external input changes ")
Mealy machine output depend on both upon current state and current input whereas Moore output depend only the current state.
Generally Mealy machine has fever state than Moore machine.
Mealy Output changes at the clock edged but Moore output change as soon as logic is done.
Mealy react faster to input whereas Moore login is needed to decode the output since it has more circuits delays.
精彩评论