Designing a combinational circuit for a vending machine

2.4k views Asked by At

I want to design a combinational circuit for a vending machine, that delivers 2 items, tea( 2$) and water(1$). The machine accepts up to 3 dollars.

# I draw the truth table with 3 inputs(dollars) and 2 outputs(tea & water).

d1 d2 d3  : t  w
-----------------
0  0  0   : 0  0
0  0  1   : 0  1
0  1  0   : 0  1
0  1  1   : 1  0
1  0  0   : 0  1
1  0  1   : 1  0 
1  1  0   : 1  0
1  1  1   : 1  1

Is there a better way to draw the truth table?

1

There are 1 answers

1
kjhughes On BEST ANSWER

Your initial truth table does not represent the vending machine fully. Consider, for example, that a customer depositing $2 should be allowed to buy one tea or two waters. Consider also that the machine should be forgiving of over depositing for a given purchasing request.

Definitions:

Inputs

  • d1-d2: binary encoding of money deposited.
  • t: tea requested.
  • w1-w2: binary encoding of number of waters requested.

Outputs

  • A: Accept amount deposited and provide requested tea and water.
  • D1-D2: binary encoding of change to return to buyer.

Truth Table

The following truth table captures

  • multiple possible selections for a given deposit.
  • change to be given if selection is less expensive than money deposited.
  I N P U T S    ||  O U T P U T S
Depos | Request  || Accept  | Change
d2 d1 | t  w2 w1 || A       | D2 D1
-----------------------------------
0  0  | 0  0  0  || 0       | 0  0
0  0  | 0  0  1  || 0       | 0  0
0  0  | 0  1  0  || 0       | 0  0
0  0  | 0  1  1  || 0       | 0  0
0  0  | 1  0  0  || 0       | 0  0
0  0  | 1  0  1  || 0       | 0  0
0  0  | 1  1  0  || 0       | 0  0
0  0  | 1  1  1  || 0       | 0  0
0  1  | 0  0  0  || 0       | 0  0
0  1  | 0  0  1  || 1       | 0  0
0  1  | 0  1  0  || 0       | 0  0
0  1  | 0  1  1  || 0       | 0  0
0  1  | 1  0  0  || 0       | 0  0
0  1  | 1  0  1  || 0       | 0  0
0  1  | 1  1  0  || 0       | 0  0
0  1  | 1  1  1  || 0       | 0  0
1  0  | 0  0  0  || 0       | 0  0
1  0  | 0  0  1  || 1       | 0  1
1  0  | 0  1  0  || 1       | 0  0
1  0  | 0  1  1  || 0       | 0  0
1  0  | 1  0  0  || 1       | 0  0
1  0  | 1  0  1  || 0       | 0  0
1  0  | 1  1  0  || 0       | 0  0
1  0  | 1  1  1  || 0       | 0  0
1  1  | 0  0  0  || 0       | 0  0
1  1  | 0  0  1  || 1       | 1  0
1  1  | 0  1  0  || 1       | 0  1
1  1  | 0  1  1  || 1       | 0  0
1  1  | 1  0  0  || 1       | 0  1
1  1  | 1  0  1  || 1       | 0  0
1  1  | 1  1  0  || 0       | 0  0
1  1  | 1  1  1  || 0       | 0  0