lab 7 : overview state machine : moore model concept in designing a vending machine
TRANSCRIPT
Lab 7 : OverviewLab 7 : Overview
State Machine : Moore ModelState Machine : Moore Model
Concept in designing a Concept in designing a Vending MachineVending Machine
State MachinesState Machines
► State Machine must haveState Machine must have InputInput State State OutputOutput
► State Machine are always clocked.State Machine are always clocked.► 2 Common Types of State Machines : 2 Common Types of State Machines : ►Moore Model :Moore Model :
Output Output DO NOT dependDO NOT depend on the input condition on the input condition but the output is per state basisbut the output is per state basis
►Mealy Model :Mealy Model : Output Output does dependdoes depend on the input and state on the input and state
conditions.conditions.
Comparison of Mealy and Moore Comparison of Mealy and Moore MachineMachine
►Mealy machines tend to have less statesMealy machines tend to have less states►Moore machines are safer to useMoore machines are safer to use
Outputs change at clock edge (always one cycle Outputs change at clock edge (always one cycle later)later)
In Mealy machines, input change can cause output In Mealy machines, input change can cause output change as soon as logic is done – a big problem change as soon as logic is done – a big problem when two machines are interconnected – when two machines are interconnected – asynchronous feedback may occur if one isn’t asynchronous feedback may occur if one isn’t carefulcareful
►Mealy machines react faster to inputsMealy machines react faster to inputs React in same cycle – don’t need to wait for clockReact in same cycle – don’t need to wait for clock In Moore machines, more logic may be necessary In Moore machines, more logic may be necessary
to decode state into outputs-more gate delays to decode state into outputs-more gate delays after clock edgeafter clock edge
Moore Model CircuitsMoore Model Circuits
►Output depends only on the state of Output depends only on the state of the flip-flop.the flip-flop.
The output is included under a slash The output is included under a slash below the state in a circle.below the state in a circle.
State Diagram – Fig. 6-19 (b)State Diagram – Fig. 6-19 (b)
XY
State Output
Example of Moore MachinesExample of Moore Machines
StateState OutputOutput
A (00)A (00) 00
B (01)B (01) 11
C (10)C (10) 00
A/0
C/0
B/1X = 1
X = 0
X = 1
X = 0X = 0
X = 1
INPUT
STATE
STATENAME
OUTPUT
Present Present StateState
Input XInput X Next Next StateState
A (00)A (00) 00 C (10)C (10)
11 B (01)B (01)
B (01)B (01) 00 B (01)B (01)
11 C (10)C (10)
C (10)C (10) 00 B (01)B (01)
11 A (00)A (00)
Example 2 : Moore MachinesExample 2 : Moore Machines► Output is high when input is Output is high when input is
twice (2) high in a row. 11 in twice (2) high in a row. 11 in a row = o/p higha row = o/p high
Present Present StateState
Input XInput X Next Next StateState
S0 (00)S0 (00) 00 S0 (00)S0 (00)
11 S1 (01)S1 (01)
S1 (01)S1 (01) 00 S0 (00)S0 (00)
11 S2 (00)S2 (00)
S2 (10)S2 (10) 00 S0 (00)S0 (00)
11 S2 (10)S2 (10)
S0/0
S2/1
S1/0
X=0
X=1
X=1X=0
X=1
X=0
StateState OutputOutput
S0 (00)S0 (00) 00
S1 (01)S1 (01) 00
S2 (10)S2 (10) 11
Mealy Model CircuitsMealy Model Circuits
►The directed lines are labeled by two The directed lines are labeled by two binary numbers separated by a slash, binary numbers separated by a slash, e.g.e.g.
0/1 refers to input =0 and output=1 of 0/1 refers to input =0 and output=1 of the the present state.present state.
►Output depends on the state of the Output depends on the state of the flip-flop and input.flip-flop and input.
State Diagram – Fig. 6-19 State Diagram – Fig. 6-19 (a)(a)
Input Output
State
Example of Mealy MachinesExample of Mealy Machines
A
C
BX = 1/1
X = 0/0
X = 1/0X = 0/1
X = 0/0
X = 1/0
INPUT
STATE
STATENAME
OUTPUT
PresenPresent Statet State
Input Input XX
Next Next StateState
OutpuOutputt
A (00)A (00) 00 C (10)C (10) 00
11 B (01)B (01) 11
B (01)B (01) 00 B (01)B (01) 00
11 C (10)C (10) 00
C (01)C (01) 00 B (01)B (01) 11
11 A (00)A (00) 00
Example 2 : Mealy MachinesExample 2 : Mealy Machines► Output is high when input is twice (2) high in a row. Output is high when input is twice (2) high in a row.
11 in a row = o/p high11 in a row = o/p high
S0 S1
X=1/0
X=0/0X=0/0 X=1/1
Present Present StateState
Input XInput X Next Next StateState
OutputOutput
S0 (00)S0 (00) 00 S0 (00)S0 (00) 00
11 S1 (01)S1 (01) 00
S1 (01)S1 (01) 00 S0 (00)S0 (00) 00
11 S1 (01)S1 (01) 11
Lab 7 : TaskLab 7 : Task
► Design Vending Machine (VM) using Moore ModelDesign Vending Machine (VM) using Moore Model► VM deliver canned drink = 30 centVM deliver canned drink = 30 cent► VM accept 10 cent & 20 cent onlyVM accept 10 cent & 20 cent only► VM has only one coin slot, meaning it can only VM has only one coin slot, meaning it can only
receive coins one at a time. (2 or more coins insert at receive coins one at a time. (2 or more coins insert at same time is impossible to happen)same time is impossible to happen)
► Excessive coin values will release the correct change Excessive coin values will release the correct change apart from releasing the can drinkapart from releasing the can drink
► Include a RESET to manually reset the VM to its Include a RESET to manually reset the VM to its origin, meaning if coins has been inserted but RESET origin, meaning if coins has been inserted but RESET is activated, the coins should be released and VM is is activated, the coins should be released and VM is back to its original state with no value inserted.back to its original state with no value inserted.
Lab 7 : Requirements & HintsLab 7 : Requirements & Hints
► Input = coins (10c or Input = coins (10c or 20c), whereby : X = 10c, 20c), whereby : X = 10c, Y= 20cY= 20c
► Determine the number of Determine the number of states to achieve 30c:states to achieve 30c: 10c+10c+10c, balance = 10c+10c+10c, balance =
nonenone 10c+20c, balance = none10c+20c, balance = none 10c+10c+20c, balance = 10c+10c+20c, balance =
10c10c 20c+10c, balance = none20c+10c, balance = none 20c+20c, balance = 10c20c+20c, balance = 10c
► Output should be 3-bit:Output should be 3-bit: Tin out, 20c bal, 10c balTin out, 20c bal, 10c bal
X X (20c)(20c)
Y Y (10c)(10c)
ActionAction
XX YYNo coins No coins insertedinserted
XX YY 10c inserted10c inserted
XX YY 20c inserted20c inserted
XX YY Invalid actionInvalid action
INPUT
Lab 7 : Moore State MachineLab 7 : Moore State Machine► Start Drawing your state machine with the info that u have in Start Drawing your state machine with the info that u have in
hand.hand.► Next is to build-up your present state and next state table Next is to build-up your present state and next state table
use D Flip-flop in your design.use D Flip-flop in your design.
► Notice that you have 5 variables. So how do you do your K-Notice that you have 5 variables. So how do you do your K-Map? ....use 5 variable method.Map? ....use 5 variable method.
Present Present StateState XX YY
Next StateNext State
Q2Q2 Q1Q1 Q0Q0
A (000)A (000)
00 00
00 11
11 00
11 11...
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
K-Map with 5 variablesK-Map with 5 variables► Split into 2 K-Map of 4x4Split into 2 K-Map of 4x4► 11stst K-Map with the 5 K-Map with the 5thth variable = 0 variable = 0► 22ndnd K-Map with the 5 K-Map with the 5thth variable = 1 variable = 1
0000 0101 1111 1010
0000
0101
1111
1010
0000 0101 1111 1010
0000
0101
1111
1010
Q1 Q0
X Y X YQ1 Q0
Q2 = 0 Q2 = 1
D0 = Q1Q0
D0 = Q2(Q1Q0)
D0 = Q1Q0X + Q2Y
D0 = Q2(Q1Q0X + Q2Y)
D0 (total) = Q2(Q1Q0) + Q2(Q1Q0 + Q2Y)
K-Map with 5 variablesK-Map with 5 variables► Example 2 Example 2
0000 0101 1111 1010
0000
0101
1111
1010
0000 0101 1111 1010
0000
0101
1111
1010
Q1 Q0
X Y X YQ1 Q0
Q2 = 0 Q2 = 1
D0 = Q1Q0
D0 = Q2(Q1Q0)
D0 = Q1Q0
D0 = Q2(Q1Q0)
D0 (total) = Q2(Q1Q0) + Q2(Q1Q0)
= Q1Q0 (Q2 + Q2)
= Q1Q0
K-Map with 5 variablesK-Map with 5 variables► Example 3 Example 3
0000 0101 1111 1010
0000
0101
1111
1010
0000 0101 1111 1010
0000 XX XX XX XX
0101 XX XX XX XX
1111 XX XX XX XX
1010 XX XX XX XX
Q1 Q0
X Y X YQ1 Q0
Q2 = 0 Q2 = 1
D0 = XD0 = Q1Q0
D0 (total) = Q1Q0
Lab 7 : Moore MachineLab 7 : Moore Machine
►After getting the boolean expression After getting the boolean expression for each D Flip-Flopfor each D Flip-Flop
►Start designing your VMStart designing your VM►Don’t forget to include your STATE and Don’t forget to include your STATE and
OUTPUT table.OUTPUT table.►Don’t forget your RESETDon’t forget your RESET
Lab 7 : Moore MachineLab 7 : Moore Machine
Input fromBooleanExpression
D FF Q0 n x m Decoder
10c
20c
Clock
Reset D FF Q1
D FF Q2n is output from D FFAnd m =2n is decoder output (Hints : same numbering as your STATE)
Bal10c
Bal20c
TinOut
BasicComb.LogicGates
Basic Logic Gates is needed for Reset Control and output enable
Do your own
connections
GOOD LUCK!GOOD LUCK!
THANK YOUTHANK YOU