Finite-State-Machine-based digital design

digital-logicstate-machines

How do I implement a specific digital design using mealy model and then implement the same design again using Moore model ? Can anyone provide detailed steps ? Thanks.

Update:

In the digital logic class we learned what is the difference between Mealy and Moore machines theoretically and on analysis, but I don't know the difference between them in the design process.

The steps we learned for sequential circuit design:

  1. Making a state table that shows present state, input, next state and output combinations.
  2. Coding the binary state in the table and determining the number of flip flops.
  3. Use the excitation table for determining the values of the flip flops needed to generate the next state from the present state.
  4. Find the Boolean expression for the flip flop input and outputs.
  5. Build the circuit.

From these steps I just don't know how to specify the design to be based on Mealy or Moore.

Best Answer

At its simplest, for every state machine you have three variables:

  1. Inputs - Driven to the state machine. Not directly controlled by the FSM design.
  2. State - Internal information about the current state the machine is in.
  3. Outputs - Driven out of the state machine.

The state machine design about how it defines State and Outputs based on a series of Inputs over time. The State is registered, so on every cycle, you are trying to figure out the next State. The output is combinatorial, so you need to figure out the current output.

For both Mealy and Moore, the next State is determined by some combination of the inputs, current state, and current output. So it's a bunch of things like:

if (current_state == 5) 
    next_state = 6;
else if (current_state == 4 && input[3] == 1) 
    next_state = 5;
etc...

The output is typically not sequential, but rather combinatorial. And what is used to calculate this output defines whether it is Mealy or Moore.

The more general case is the Mealy FSM which calculates the output with some combination (i.e. AND/OR/NOT, comparators, etc.) of Input and (current) State.

So again, things like:

if (current_state == 5) 
    output = 1;
else if (current_state == 4)
    if (input[3] == 1) 
        output = 2;
    else
        output = 3;
etc..

But if we restrict ourselves to only calculating based on State, it is a Moore FSM. In this case, it would look like:

if (current_state == 5) 
    output = 1;
else if (current_state == 4)
    output = 2;
else if (current_state == 2 || current_state == 3)
    output = 3;
etc..

That really is it. Nothing else. And to top it off, you can convert one form to an equivalent form of the other.

One question that is often unasked is "Why do we separate them into two classes and give them names? Why is it so important?"

The answer is because as you try to create FSMs in real practical circuits, you will find that you are generally able to get better performance from a Moore machine. (They usually can run at higher frequencies). However, for many people intuition leads them to think about state machine problems more closely to the Mealy model.

By classifying them, we can teach ourselves to think about state machines problems in both models. This allows you to pick the correct model for the problem you are trying to solve. The details about why Moore runs faster and the tradeoffs between when to choose the two designs comes with experience and knowledge about digital design.