Take the task “raise y when the input has been 1 for two consecutive cycles”. In the two implementations below, at just-before-rising-edge observations, Mealy raises y in the cycle the second 1 arrives and Moore reports it at the following observation.
A Mealy machine sees the input together with the state that records one earlier 1, so it detects the second 1 at once. A Moore machine sees only the state, so it enters its “two ones seen” state at the next clock edge.
The two y rows show the same detections one cycle apart.
`clk`: marks sampling just before each rising edge.
`x`: carries isolated and paired 1s that form the detections.
`y` (Mealy): rises in the same cycle as each second 1.
`y` (Moore): repeats each detection one cycle later.
The table describes these detectors. The Mealy decision is visible earlier because it uses a combinational path, which does not by itself allow a faster clock.
Moore | Mealy | |
|---|---|---|
Response to an input change | After the next clock edge | Immediately (combinational path from input to output) |
Output stability inside a cycle | Stable once state/decode settle; register the output if glitch freedom is required | Can glitch or change mid-cycle if inputs change |
Number of states for the same job | Usually equal or one more | Usually fewer |
Output timing path | Register → output logic → port (clock-to-out) | Input port → logic → output port (input-to-output) |
The two machines are equivalent in function: the same input stream always produces the same sequence of detections. They differ only in when, relative to the clock, the output is visible.
The input stays at 1 through cycles 5, 6 and 7. Overlapping pairs (5,6) and (6,7) are both detected. The Moore machine sits in its “two ones seen” state for cycles 7 and 8, one cycle behind the Mealy detections.
The one-observation gap holds for these state meanings and output expressions. It is not a universal latency law.