1. Construct a finite-state machine with output that models a candy machine that accepts only pennies. Cando costs 3 cents and the machine always keeps the money for any amount greater than 3 cents. The customer can bush buttons to receive candy or to return pennies. Represent the machine with a state table.
2. Construct a finite-state machine with output that delays input by two bits using 11 for the delay. Represent the machine with a state diagram.
1. Since 1 penny = 1 cent
So machine will output candy when 3 cents i.e. 3 pennies is received. Hence we can model this as state machine with 4 states with state 0 represent 0 pennies received. State 1 represent 1 penny received , state 2 represent 2 pennies received and from state 2 when one more penny is received then output is 1 which means candy will be released.
Below is the state transition with input 0 means no penny inserted and input 1 means 1 penny inserted.
Present state | Input | Next state | Output |
0 | 0 | 0 | 0 |
0 | 1 | 1 | 0 |
1 | 0 | 1 | 0 |
1 | 1 | 2 | 0 |
2 | 0 | 2 | 0 |
2 | 1 | 3 | 1 |
3 | 0 | 0 | 0 |
2. Here we will remember past 2 inputs through states number and then transition will be done accordingly. So from initial state there is transition to state 0 on input 0 and transition to 1 on input 1 and output will be 1 since we have to use 11 output for delay. Then from state 0, on input 0 move to state 00, on input 1 move to 01, from state 1 on input 0, move to state 10, and on input 1 move to 11. Now from these state the transition will be such that next state will be according to past input and present input.
Below is the machine state diagram.
Please comment for any clarification.
1. Construct a finite-state machine with output that models a candy machine that accepts only pennies. Cando costs 3 cents and the machine always keeps the money for any amount greater than 3 cents. T...