Lecture 22: Finite State Machines with Output Moore Machine Moore Machine - A Moore machine is a 6-tuple (Q, S, W, d, q0, F) where, (1) Q is a finite set of states. (2) S is a finite set of symbols called the input alphabet. (3) W is a finite set of symbols called the output alphabet. (4) d: Q x S -> Q is the transition function (5) q0 is an element of Q called the start state, and (6) F: Q -> W is the output function mapping the current state to the output. Example Moore Machine Each of the six elements of this example Moore machine are given below, Q = {1, 2, 3} d = ([1,X]->2, [1,Y]->3, [1,Z]->1, [2,X] ->3, [2,Y]->1, [2,Z]->2, [3,X]->1, [3,Y]->3, [3,Z]->3) S = { X, Y, Z} q0 = 1 W = {A, B} F = (1->A, 2->B, 3->A) Mealy Machine Mealy Machine - A Mealy machine is a 6-tuple (Q, S, W, d, q0, T) where, (1) Q is a finite set of states. (2) S is a finite set of symbols called the input alphabet. (3) W is a finite set of symbols called the output alphabet. (4) d: Q x S -> Q is the transition function (5) q0 is an element of Q called the start state, and (6) T: Q x S -> W is the output function mapping the current transition to the output. Moore Machine Substring Recognizer Now let's look at how we build an FSM to find all occurrences of a particular substring in an input binary string. The first issue we need to resolve is whether we wish to allow overlap in the substrings. We can use the substring 1101 to illustrate substring overlap. Permitting overlap means that one or more bits can be part of more than one instance of a substring. Consider the input string, 1101101101101101101 If we permit overlap, we find that the string contains six instances of the substring 1101. However, if we do not permit overlap, this string contains only three instances of the substring. Moore Machine: Recognizer for '1101' with Overlap Mealy Machine: Recognizer for "1101" with Overlap As a final example of bit string recognizers, we will build a Mealy machine to find the substring 1101 with overlap. Recall that a Mealy machine generates its output on the transition rather than upon entering a state. This may seem like a trivial difference, but it can sometimes permit us to reduce the number of states required. Upon reading the final bit in the substring sequence, this machine outputs a 1, otherwise it outputs a 0 each time it reads an input bit. This Mealy machine has one less state than the Moore machine designed to solve the same problem. Mealy machines will always require the same or fewer states to solve the same problem as Moore machines.