You are on page 1of 13

FSM AND ASM

CSEN605: Digital System Design

FSM

Mealy:
Output

depends on both the input and current state. depends only on the current state.

Moore:
Output

Vending Machine Example


Any item from the Vending Machine is 25 cents Machine accepts nickels (5 cents) or Dimes (10 cents) 2 models for machine:
1.

2.

Item is dispensed when 25 cents are reached. If there is change it isnt returned. Returns change when dispensing the item.

Would you choose mealy or moore for each of the designs?

Vending Machine: Model 1

Item is dispensed when 25 cents are reached. If there is change it isnt returned.

Output in this example denotes whether the item can be dispensed or not, in that case, output depends only on reaching a state where the 25 cents are paid. It is better to design the FSM as a moore machine.

Vending Machine: Model 1

0/0

5/0
5

10

15/0
5

10

25 /1
5,10

10

10/0

10

20/0

Cycle indicates that at a clock positive edge where there is no input, the state remains the same

Vending Machine: Model 2

Item is dispensed when 25 cents is reached and the change is returned when dispensing the item.

Output in this example is denotes by 2 variables


D:

whether the item is dispensed or not. C: the amount of change.

The C output depends on both the current state and the value of the input to this state thus it is better to design it using a mealy machine.

Vending Machine: Model 2

5/

C=0 D=0

5
5/

10/
C=0 D=0

15
5/

10/
C=0 D=0

25

10/
C=0 D=0

C=0 D=0

5/

C=0 D=0

C=0 D=0

10/
C=5 D=1

5/

10

10/
C=0 D=0

C=0 D=1

20

Elements used in ASM charts (1)


State name Output signals or actions (Moore type)

0 (False)

Condition expression

1 (True)

(a) State box

(b) Decision box

Conditional outputs or actions (Mealy type)

(c) Conditional output box

ASM Design Example 1

Two Flip-Flops (E,F) and one 4-bit counter A. The system is initiated by a start Signal S, by clearing the counter A And flip-flop F. The counter is then Incremented by one starting for the next clock and continues to increment Until the operations stop. Bits A3 and A4 Determine the sequence of operations: 1. If A3=0, E is cleared to 0 and the count continues. 2. If A3=1, E is set to 1; then if A4=0, the count continues, but if A4=1, F is set to 1 on the next clock pulse and the system stops counting. 3. Then if S=0, the system remains in the initial state, but if S=1, the operation cycle repeats.

ASM Design Example 1: Solution

This ASM describes a counter A that counts to 1100. Signal E denotes that A8 Signal F denotes that A is 12.

ASM Example 2

Draw the ASM diagram that counts the number of people in a room.
People

enter the room through a door with a sensor that x that changes from 1 to 0 when interrupted. People exit through a second door with a similar sensor y that changes from 1 to 0 when interrupted. The circuit consists of an up/down counter and a display that shows the number of people in the room.

ASM Example 2: Discussion

x goes from 101 to indicate someone has entered. y goes from 101 to indicate someone has exited. We handle three states:
Someone

coming in Someone going out Or if there is someone coming in and the same instant when someone is going out.

ASM Example 2: Solution


Ctr 0 Waiting

In/Out

Coming in

Going Out

=11

xy

11

Ctr Ctr +1

Ctr Ctr -1