📚 Introduction to State Machines
State machines are a cornerstone of sequential logic design, especially in embedded systems and digital electronics. They model systems that transition between discrete states based on inputs and internal conditions, making them ideal for controlling processes like traffic lights, vending machines, and conveyor belts.
1️⃣ Mealy vs. Moore Models: Core Concepts
Mealy State Machine (Class A in the notes)
- Inputs affect both state transitions and outputs.
- Outputs are generated from a combination of current state and current inputs.
- Advantages:
- Can minimize the number of Flip-Flops.
- Often more compact in terms of states.
- Challenges:
- Requires more complex combinational logic.
- Susceptible to glitches if inputs change asynchronously.
The notes describe this as a system where inputs create Flip-Flop excitations and also contribute to output generation. This dual dependency can reduce hardware but increases design complexity.
Moore State Machine (Class B and Class C)
- Outputs depend only on the current state.
- Inputs influence state transitions but not outputs directly.
Class B Moore:
- Outputs are derived from Flip-Flop outputs using additional combinational logic.
- Requires logic before and after Flip-Flops.
Class C Moore:
- Outputs are taken directly from Flip-Flops.
- No combinational logic after Flip-Flops.
- Advantages:
- Eliminates race conditions and transients.
- More robust and predictable behavior.
The conveyor belt example uses a Class C Moore design, where the motor output (M) is directly tied to the state of Flip-Flop B. This simplifies output logic and enhances reliability—especially important in safety-critical systems.
2️⃣ Design Flow
- Block Diagram: Define inputs, outputs, and feedback paths.
- State Diagram: Map states, transitions, and outputs.
- Truth Tables: Determine next-state logic.
- Boolean Expressions: Derive logic for Flip-Flop excitations.
- Output Logic: Decide how outputs are driven.
- Circuit Implementation: Build and test the design using synchronous clocking.
This structured approach ensures clarity and correctness, especially when transitioning to FPGA-based implementations later in your course.
🧪 Summary Table
| Model Type | Output Depends On | Output Timing | Complexity | Example Use |
|---|---|---|---|---|
| Mealy | State + Input | Immediate | Higher | Real-time control systems |
| Moore B | State (via logic) | On clock edge | Moderate | Traffic lights with logic |
| Moore C | State (direct from FFs) | On clock edge | Lower | Conveyor belt motor control |
🧪 Real-World Analogy
Imagine a vending machine:
- A Mealy machine might dispense a product immediately when the correct coin is inserted (input affects output instantly).
- A Moore machine might wait until the next clock cycle to verify the coin and then dispense the product (output depends only on the verified state).