COMPLEX ENGINEERING PROBLEM - CEP
DIGITAL LOGIC DESIGNS – DLD
REPORT
SUBMITTED BY:
USMAN KHALID
SAAD JAVED MALIK
BEE - 60 A
DEPARTMRNT OF ELECTRICAL ENGINEERING
MILITARY COLLEGE OF SIGNALS
NATIONAL UNIVERSITY OF SCIENCES AND TECHNOLOGY
SUBMITTED TO:
LT. COL DR YASIR AWAIS BUTT
DATED
01 JAN 2025
COMPLEX ENGINEERING AND DESIGN PROBLEM – REPORT
DIGITAL LOGIC DESING – DLD
Design Problem Description:
Design a state machine-based control system for an advanced vending machine using JK Flip-Flops. The
vending machine accepts two types of coins: $0.25 (quarter) and $1.00 (dollar bill). The machine
dispenses a snack item costing $1.25. It must keep track of the total amount inserted and appropriately
dispense the item or return change based on the inserted amount.
Design Requirements
1. Inputs:
o Q: Signal representing a quarter ($0.25) is inserted (logic 1 when true).
o D: Signal representing a dollar bill ($1.00) is inserted (logic 1 when true).
o Cancel: Signal to cancel the transaction and return inserted money.
o Reset: Resets the machine to the initial state.
2. Outputs:
o Dispense: Dispenses the snack (logic 1 when dispensing).
o Change: Dispenses change (logic 1 when returning change).
o Refund: Returns the total inserted amount if Cancel is activated.
3. Design Constraints:
o Implement the state machine using JK Flip-Flops only.
o Optimize the flip-flop inputs using Karnaugh maps (K-maps) for minimal logic.
o Use a clock signal to synchronize state transitions.
o Include a Reset input to bring the system back to the initial state (S0).
4. Deliverables:
o State Diagram: Clearly illustrate the states and transitions.
o State Table: List the present states, inputs, next states, and outputs.
o Flip-Flop Input Equations: Derive the J and K inputs for each flip-flop.
o Logic Diagram: A circuit diagram implementing the state machine.
o Timing Diagram: Show typical input/output waveforms to demonstrate the system’s
behaviour.
Design Explanation:
The designed vending machine consists of 6 possible states:
1. S0 000
2. S1 001
3. S2 010
4. S3 011
5. S4 100
6. S5 101
The remaining states are don’t care conditions for the state machine. The machine accepts three inputs from
the user:
1. $1 bill with the input named “D”
2. $0.25 with the input named “Q”
3. The cancel input named “F” to cancel the input and wants his/her inserted money returned.
Three JK flip flops are used to construct the machine. Upon the inputs given by the user, the machine gives
and output or returns the inserted money.
The inserted money by the user can be returned in 4 possible ways:
1. 1Q $0.25
2. 2Q $0.50
3. 3Q $0.75
4. 1D $1.00
State Table:
PRESENT STATES INPUTS NEXT STATES JK FLIP FLOP INPUTS RETURN
DECIMAL OUTPUT
A B C D Q CANCEL A B C Ja Ka Jb Kb Jc Kc D Q 2Q 3Q
0 0 0 0 0 0 0 0 0 0 0 X 0 X 0 X 0 0 0 0 0
1 0 0 0 0 0 1 0 0 0 0 X 0 X 0 X 0 0 0 0 0
2 0 0 0 0 1 0 0 0 1 0 X 0 X 1 X 0 0 0 0 0
3 0 0 0 0 1 1 0 0 0 0 X 0 X 0 X 0 0 1 0 0
5 0 0 0 1 0 0 1 0 0 1 X 0 X 0 X 0 0 0 0 0
5 0 0 0 1 0 1 0 0 0 0 X 0 X 0 X 0 1 0 0 0
6 0 0 0 1 1 0 0 0 0 0 X 0 X 0 X 1 0 0 0 0
7 0 0 0 1 1 1 0 0 0 0 X 0 X 0 X 0 1 1 0 0
8 0 0 1 0 0 0 0 0 1 0 X 0 X X 0 0 0 0 0 0
9 0 0 1 0 0 1 0 0 0 0 X 0 X X 1 0 0 1 0 0
10 0 0 1 0 1 0 0 1 0 0 X 1 X X 1 0 0 0 0 0
11 0 0 1 0 1 1 0 0 0 0 X 0 X X 1 0 0 0 1 0
12 0 0 1 1 0 0 0 0 0 0 X 0 X X 1 1 0 0 0 0
13 0 0 1 1 0 1 0 0 0 0 X 0 X X 1 0 1 1 0 0
14 0 0 1 1 1 0 0 0 0 0 X 0 X X 1 1 0 1 0 0
15 0 0 1 1 1 1 0 0 0 0 X 0 X X 1 0 1 0 1 0
16 0 1 0 0 0 0 0 1 0 0 X X 0 0 X 0 0 0 0 0
17 0 1 0 0 0 1 0 0 0 0 X X 1 0 X 0 0 0 1 0
18 0 1 0 0 1 0 0 1 1 0 X X 0 1 X 0 0 0 0 0
19 0 1 0 0 1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1 0 1 1 0 0 0 0 0 X 1 0 X X 0 1 1 0 0 0
45 1 0 1 1 0 1 0 0 0 X 1 0 X X 0 0 1 0 1 1
46 1 0 1 1 1 0 0 0 0 X 1 0 X X 0 1 1 1 0 0
47 1 0 1 1 1 1 0 0 0 X 1 0 X X 0 0 1 1 1 1
State Diagram:
Logic Diagram:
D
1
U5
NOT
E
1
U4
U1
NOT
F
U3
1 AND_5
U6 U2
OR
NOT
AND_5
U7
A
OR_4
J Q
CLK
K Q
JKFF
U8
AND_5
U9
B
J Q
U10
CLK
OR_3
K Q
JKFF
AND
U11
U13
AND_5
U12
OR
AND_4
C
U14 J Q
CLK
K Q
AND JKFF
U15 U17
AND OR_3
U16
AND
U18
AND_3
U19 U24
AND_3 OR_3
U20
U26
AND_3
0
U21
OR
AND_3
U22 U25
AND_3 OR_3
U23
AND_3
U27
AND_4
U28
AND_4
U29 U37
AND_5 OR_5
U30
AND_5
U31
U39
AND_5
1
U32
OR
AND_5
U33
AND_5
U34 U38
AND_5 OR_5
U35
AND_5
U36
AND_5
U40
AND_4
U41 U46
AND_4 OR_3
U42
U48
AND_4
0
U43
OR
AND_4
U44 U47
AND_5 OR_3
U45
AND_5
U49
AND_3
U50
AND_4
U51 U54
0
AND_4 OR_5
U52
AND_4
U53
AND_4
U55
AND
U56
AND
U57 U60
1
AND_3 OR_5
U58
AND_3
U59
AND_4
JK Flip Flop Inputs:
1. Ja = 𝐵𝐶̅ 𝐷𝑄 𝐹 + 𝐵𝐶𝐷 𝑄𝐹
2. Ka = 𝐹 + 𝑄 + 𝐷 + 𝐶
3. Jb = 𝐴̅𝐶𝐷𝑄𝐹
4. Kb = 𝐹 + 𝐷 + 𝐶𝑄
5. Jc = 𝐵𝐷 𝑄 𝐹 + 𝐴̅𝐵 𝐷𝑄𝐹
6. Kc = 𝐴̅𝐹 + 𝐴̅𝐸 + 𝐴̅𝐷