Electronic – is the drawn diagram right for detecting a sequence of three or more 1’s

digital-logic

i saw this diagram in my textbook for the problem :

Suppose we wish to design a circuit that detects a sequence of three or more consecutive 1’s in a string of bits coming through an input line (i.e., the input is a serial bit
stream)

this is the diagram the book suggests .

enter image description here

si means we have read i consecutive 1's from the input (s3 means 3 or more consecutive 1's) and s0 is the start state.

my problem is when we are in state s2 and we read a 1 in input the output is still 0 while it should change to 1.

and also when we are in state s3 and we read a 0 the output is still 1 while it should change to 0.

my mealy implementation (excluding some arcs) is

enter image description here

here we do not have the above problems .

i know the first one is a Moore implementation while the second one is a Mealy implementation .

BUT shouldn't they do the same thing .

Best Answer

Yes, they are the same. In a Moore machine, the outputs are associated with the states, while in a Mealy machine, they are associated with the edges.

This means that a Mealy machine can often have fewer states than the corresponding Moore machine. In this specific example, your states s2 and s3 could be combined, since they have the same set of output edges — you would see this if you were to include the missing edges.

That's not to say that the Mealy machine has fewer flip-flops! In addition to the flip-flops that hold the internal state, each output needs a flip-flop, too. In this example, the Moore machine requires two flip-flops, but the Mealy machine requires a total of three.