# CS 140 Lecture 6 - University of California, San Diego CS 140L Lecture 7 Transformation between Mealy and Moore Machines Professor CK Cheng CSE Dept. UC San Diego Outlines Framework Procedure Example: Transform Example: State Diagram Example: Output Sequence Transform from Mealy to Moore Machine Mealy Machine: Moore Machine: y(t) = f(x(t), s(t)) y(t) = f(s(t)) s(t+1) = g(x(t), s(t)) x(t) C1 C2

CLK Mealy Machine y(t) x(t) C1 C2 y(t) CLK s(t) s(t) Moore Machine 3 Transform from Mealy to Moore Machine Algorithm Input: State Table of Mealy machine 1) For each NS, z = Si,yj create a state Si(j) 2) For each new state Si(j), repeat the row PS = Si 3) Replace NS, z = Si,yj with state Si(j). Set output z = yj for row PS = Si(j) Example Mealy Machine: PS A

B 00 A,0 A,1 01 10 (x,y) A,1 B,0 B,0 B,0 (NS, z) Moore Machine: PS A0 A1 B 00 A0 A0 A1 01 A1 A1 B 10 (x,y) B B B z 0

1 0 State Diagram 00/0, 01/1 10/0, 01/0 Mealy Machine A 10/0 B 00/1 00 Moore Machine 10 A0/0 B/0 10 01 00 A1/1

01 10 01 00 Timing Diagrams Time step 0 1 2 3 4 5 x y 0 0 0 1 1

0 0 0 0 1 0 1 Mealy S z A 0 A 1 A 0 B 1 A 1 A 1

A Moore S z A0 A0 0 0 A1 1 B 0 A1 1 A1 1 A1 1 The output shifts by one clock from Mealy to Moore machine