Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab 7 : Overview State Machine : Moore Model Concept in designing a Vending Machine.

Similar presentations


Presentation on theme: "Lab 7 : Overview State Machine : Moore Model Concept in designing a Vending Machine."— Presentation transcript:

1 Lab 7 : Overview State Machine : Moore Model Concept in designing a Vending Machine

2 State Machines ► State Machine must have  Input  State  Output ► State Machine are always clocked. ► 2 Common Types of State Machines : ► Moore Model :  Output DO NOT depend on the input condition but the output is per state basis ► Mealy Model :  Output does depend on the input and state conditions.

3 Comparison of Mealy and Moore Machine ► Mealy machines tend to have less states ► Moore machines are safer to use  Outputs change at clock edge (always one cycle later)  In Mealy machines, input change can cause output change as soon as logic is done – a big problem when two machines are interconnected – asynchronous feedback may occur if one isn’t careful ► Mealy machines react faster to inputs  React in same cycle – don’t need to wait for clock  In Moore machines, more logic may be necessary to decode state into outputs-more gate delays after clock edge

4 Moore Model Circuits ► Output depends only on the state of the flip-flop.  The output is included under a slash below the state in a circle.

5 State Diagram – Fig. 6-19 (b) XY State Output

6 Example of Moore Machines StateOutput A (00) 0 B (01) 1 C (10) 0 A/0 C/0 B/1 X = 1 X = 0 X = 1 X = 0 X = 1 INPUT STATE NAME OUTPUT Present State Input X Next State A (00) 0 C (10) 1 B (01) 0 1 C (10) 0 B (01) 1 A (00)

7 Example 2 : Moore Machines ► Output is high when input is twice (2) high in a row. 11 in a row = o/p high Present State Input X Next State S0 (00) 0 1 S1 (01) 0 S0 (00) 1 S2 (00) S2 (10) 0 S0 (00) 1 S2 (10) S0/0 S2/1 S1/0 X=0 X=1 X=0 X=1 X=0StateOutput S0 (00) 0 S1 (01) 0 S2 (10) 1

8 Mealy Model Circuits ► The directed lines are labeled by two binary numbers separated by a slash, e.g. 0/1 refers to input =0 and output=1 of the present state. ► Output depends on the state of the flip-flop and input.

9 State Diagram – Fig. 6-19 (a) Input Output State

10 Example of Mealy Machines A C B X = 1/1 X = 0/0 X = 1/0 X = 0/1 X = 0/0 X = 1/0 INPUT STATE NAME OUTPUT Present State Input X Next State Output A (00) 0 C (10) 0 1 B (01) 1 0 0 1 C (10) 0 C (01) 0 B (01) 1 1 A (00) 0

11 Example 2 : Mealy Machines ► Output is high when input is twice (2) high in a row. 11 in a row = o/p high S0S1 X=1/0 X=0/0 X=1/1 Present State Input X Next State Output S0 (00) 0 0 1 S1 (01) 0 0 S0 (00) 0 1 S1 (01) 1

12 Lab 7 : Task ► Design Vending Machine (VM) using Moore Model ► VM deliver canned drink = 30 cent ► VM accept 10 cent & 20 cent only ► VM has only one coin slot, meaning it can only receive coins one at a time. (2 or more coins insert at same time is impossible to happen) ► Excessive coin values will release the correct change apart from releasing the can drink ► Include a RESET to manually reset the VM to its origin, meaning if coins has been inserted but RESET is activated, the coins should be released and VM is back to its original state with no value inserted.

13 Lab 7 : Requirements & Hints ► Input = coins (10c or 20c), whereby : X = 10c, Y= 20c ► Determine the number of states to achieve 30c:  10c+10c+10c, balance = none  10c+20c, balance = none  10c+10c+20c, balance = 10c  20c+10c, balance = none  20c+20c, balance = 10c ► Output should be 3-bit:  Tin out, 20c bal, 10c bal X (20c) Y (10c) Action XY No coins inserted XY 10c inserted XY 20c inserted XY Invalid action INPUT

14 Lab 7 : Moore State Machine ► Start Drawing your state machine with the info that u have in hand. ► Next is to build-up your present state and next state table use D Flip- flop in your design. ► Notice that you have 5 variables. So how do you do your K-Map?....use 5 variable method. Present State XY Next State Q2Q1Q0 A (000) 00 01 10 11....................................

15 K-Map with 5 variables ► Split into 2 K-Map of 4x4 ► 1 st K-Map with the 5 th variable = 0 ► 2 nd K-Map with the 5 th variable = 1 00011110 00 01 11 100001111000 01 11 10 Q1 Q0 X Y Q1 Q0 Q2 = 0Q2 = 1 D0 = Q1Q0 D0 = Q2(Q1Q0) D0 = Q1Q0X + Q2Y D0 = Q2(Q1Q0X + Q2Y) D0 (total) = Q2(Q1Q0) + Q2(Q1Q0 + Q2Y)

16 K-Map with 5 variables ► Example 2 00011110 00 01 11 100001111000 01 11 10 Q1 Q0 X Y Q1 Q0 Q2 = 0Q2 = 1 D0 = Q1Q0 D0 = Q2(Q1Q0) D0 = Q1Q0 D0 = Q2(Q1Q0) D0 (total) = Q2(Q1Q0) + Q2(Q1Q0) = Q1Q0 (Q2 + Q2) = Q1Q0

17 K-Map with 5 variables ► Example 3 00011110 00 01 11 100001111000XXXX 01XXXX 11XXXX 10XXXX Q1 Q0 X Y Q1 Q0 Q2 = 0Q2 = 1 D0 = XD0 = Q1Q0 D0 (total) = Q1Q0

18 Lab 7 : Moore Machine ► After getting the boolean expression for each D Flip-Flop ► Start designing your VM ► Don’t forget to include your STATE and OUTPUT table. ► Don’t forget your RESET

19 Lab 7 : Moore Machine Input from Boolean Expression D FF Q0 n x m Decoder 10c 20c Clock Reset D FF Q1 D FF Q2 n is output from D FF And m =2 n is decoder output (Hints : same numbering as your STATE) Bal 10c Bal 20c Tin Out Basic Comb. Logic Gates Basic Logic Gates is needed for Reset Control and output enable Do your own connections

20 GOOD LUCK! THANK YOU


Download ppt "Lab 7 : Overview State Machine : Moore Model Concept in designing a Vending Machine."

Similar presentations


Ads by Google