top of page

How to Implement a Sequence Detector Using Mealy Finite State Machine in Digital Electronics

Sequence Detector for 1001 Sequence (Mealy FSM - Continued): -

Here's the completed state transition and output table for the 1001 sequence detector Mealy FSM:

Current State

Input (0)

Next State

Output

S0


S1

X

S1


S2

X

S2


S3

X

S3


S0

Detect

S0

1

S0

X

S1

1

S0

X

S2

1

S0

X

S3

1

S3

Detect


Explanation:

  • This Mealy FSM operates similarly to the previous example.

  • Transitions happen based on the current input (0 or 1).

  • The output "Detect" is generated only in state S3 and when the current input is 0.

  • Any other input (1) at any state or a 0 at S3 resets the FSM to S0.


Vending Machine FSM Design


Vending machine FSM design
Fig. Vending machine FSM design

Here's a basic FSM design for a vending machine:

States:

  • S0: Idle (no money inserted)

  • S1: Coin inserted (waiting for selection)

  • S2: Product selected (waiting for payment completion)

  • S3: Dispense product (dispense and return change if needed)

  • S4: Out of stock (display message and return money)

Inputs:

  • Coin inserted

  • Product button pressed

  • Change returned (internal signal)

  • Out of stock signal

Outputs:

  • Display message (idle, select product, out of stock)

  • Dispense product

  • Return coin/change


State Transition and Output Table:

Current State

Input

Next State

Output

S0

Coin inserted

S1

Display: Select product

S1

Product button

S2

Display: Confirm (show price)

S2

Coin inserted

S2 (check)

Check if enough money, display message

S2 (check)

Enough coins

S3

Dispense product, return change if needed

S2 (check)

Not enough

S1

Display: Insert more coins

S3

Change returned

S0

Display: Idle

S*

Out of stock

S4

Display: Out of stock, return money

Note: This is a simplified example. A real vending machine FSM would be more complex with additional states and outputs to handle various scenarios.


Odd Parity Detector FSM Design (Specification)


Odd Parity Detector FSM Design
Fig. Odd Parity Detector FSM Design

An odd parity detector FSM receives a stream of data bits and determines whether the total number of 1s (including the parity bit) is odd. This is used for error detection in data transmission.

States:

  • S0: Even parity (initial state) - expects an odd number of 1s in the data bits

  • S1: Odd parity - expects an even number of 1s in the data bits

Inputs:

  • Data bit (0 or 1)

Outputs:

  • Error (if received data parity doesn't match expected parity)


State Transition and Output Table:

Current State

Input (0)

Next State

Output

S0


S1

X

S1


S0

X

S*

1

(Depends)

Error (if S0)

S*

0

(Depends)

Error (if S1)

Explanation:

  • The FSM starts in S0 (even parity expected).

  • For each data bit received:

  • If the current state is S0 (even parity expected) and the data bit is 0, it stays in S0.

  • If the current state is S0 (even parity expected) and the data bit is 1, it transitions to S1 (odd parity expected).

  • Similar logic applies for S1 with opposite expected data bit values.

  • An error is only generated if the received data bit doesn't match the expected parity for the current state.

 

0 views0 comments
bottom of page