1 / 12

CS 448 Foundation of Computing

CS 448 Foundation of Computing. Soundararajan Ezekiel Department of Computer Science Ohio Northern University ADA, Ohio 45810 e-mail: s-ezekiel@onu.edu http://www.onu.edu/user/FS/sezekiel. Mealy Machines. A Mealy machine produces output on a transition instead of on entry into a state.

Télécharger la présentation

CS 448 Foundation of Computing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 448 Foundation of Computing Soundararajan Ezekiel Department of Computer Science Ohio Northern University ADA, Ohio 45810 e-mail: s-ezekiel@onu.edu http://www.onu.edu/user/FS/sezekiel

  2. Mealy Machines • A Mealy machine produces output on a transition instead of on entry into a state. • Transitions are labeled i/o where i is a character in the input alphabet and o is a character in the output alphabet. • Mealy machine are complete in the sense that there is a transition for each character in the input alphabet leaving every state. • There are no accept states in a Mealy machine because it is not a language recognizer, it is an output producer. • Its output will be the same length as its input.

  3. Definition • A Mealy Machine is a collection of four things • 1. A finite set of states q0,q1, where q0 is designated as the start state • 2. An alphabet of letters for forming the input string ={a, b, c.. } • 3. An alphabet of possible output characters ={x,y,z….} • 4. A pictorial representation with states represented by small circles and directed edges indicating transitions between states. Each edge is labeled with a compound symbol of the form i/o where i in input letter and o is the output character. Every state must have exactly one outgoing edge for each possible input letter. The edge we travel is determine by the in put letter i. While traveling on the edge, we must print the output character o

  4. Example 1 aaabb===> 0-1-3-3-0-3====> 01110 1 b/1 a/0 a/1 0 2 b/0 a/0 b/1 b/1 3 a/1

  5. example 2 • The following Mealy machine takes the one's complement of its binary input. In other words, it flips each digit from a 0 to a 1 or from a 1 to a 0. a/x 0/1, 1/0 b/y Equal to the following 0 a/x, b/y

  6. Increment machine • The next Mealy machine from page 154 of the text increments its binary input. • The only rather disconcerting characteristic of the machine is that we must feed the input number backwards and the machine produces its output backwards. • It also does not work correctly if the input string consists completely of 1's. In that case the answer always comes out 0.

  7. Example • Here is an example of a Mealy machine that reports on the parity of each 4-bit substring in its input. For each of the first 3 bits of each 4-bit substring, the machine outputs a 0. If a 4-bit substring contains an even number of 1's then the machine outputs a 0 on the 4th bit of that 4-bit substring, otherwise it outputs a 1.

  8. 0/0, 1/1 Here is binary rep 59 0111011 feed backward we will get 0111100 which is equal to 60 0/1 0/1 1/0 1/0

  9. Example • Although Moore and Mealy machines do not accept or reject their input strings, they do yield information about their input through the output that they produce. Here is a Mealy machine to count the number of occurrences of aa or bb. It produces a 1 each time it finds that it has just seen a double letter.

  10. a/1 a/0 b/0 a/0 b/0 b/1 For example ababbaab becomes 00001010

  11. When we talk about equivalence of two Moore machines or two Mealy machines we mean that, given the same input, they produce the same output. • Since a Moore machine outputs the symbol associated with its start state before it begins processing its input, its output is always one longer than its input. • The output of a Mealy machine is always the same length as its input. • Therefore a Moore machine cannot be equivalent to a Mealy machine in the above sense. • We say that a Moore machine is equivalent to a Mealy machine if, given the same input, the output of the Moore machine after removing the first character is the same as the output of the Mealy machine.

  12. Using this definition of equivalence, our text proves that for every Moore machine there is an equivalent Mealy machine and vice versa. • It does this with two constructive algorithms: • one for converting a Moore machine to a Mealy machine and one for going the other direction. • We will not study these algorithms because we need to move on to other material, but they are interesting. Read about them in the text.

More Related