Design of A Vending Machine Using Verilog HDL and
Design of A Vending Machine Using Verilog HDL and
RESEARCH ARTICLE
ABSTRACT
This paper proposes the design, implementation, and verification of a Submitted: November 21, 2023
vending machine using the Finite State Machine (FSM) methodology Published: December 29, 2023
in Verilog HDL. The FSM is used to manage the multiple states of the
vending machine, including “idle,” “accepting coins,” “dispensing item,” 10.24018/ejece.2023.7.6.595
and “returning change.” The implementation of the vending machine is
done in Verilog HDL, and the FSM is implemented as a state diagram. The 1 Department
design is then synthesized using the Genus synthesis tool and implemented of Electrical & Electronic
Engineering, Ahsanullah University of Sci-
using the Encounter implementation tool. The Genus tool uses advanced ence & Technology, Bangladesh.
optimization techniques, such as timing-driven placement and clock tree 2 Daffodil International University,
synthesis, to improve the design’s performance and area. The Encounter Bangladesh.
tool performs physical design, including placement and routing, to meet
the design’s timing, power, and area constraints. To validate the design’s *Corresponding Author:
correctness and functionality, a test bench is created to simulate the e-mail: [email protected]
behavior of the vending machine. The simulation results are then used to
verify that the design meets the required specifications and that the FSM
behaves as expected. The proposed design is then can be implemented on a
Field Programmable Gate Array (FPGA) to demonstrate its effectiveness
in a real-world scenario. The results of the implementation are presented
and analyzed to validate the design’s performance, power consumption,
and area. Overall, the vending machine using FSM in Verilog HDL,
implemented in Genus and Encounter, provides a reliable and efficient
solution for users to purchase items from the machine. The proposed
design and implementation demonstrate the feasibility and effectiveness
of this approach, and the results show that the design meets the required
specifications and performs well in a real-world scenario.
Copyright: © 2023 Fuad et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and
reproduction in any medium, provided the original source is cited.
2. State Table
2.1. State Diagram
This is the state diagram for the 10TK state where two
states are present (Fig. 1). Where S0 represents the 0-taka
state & S1 represents the 10-taka state. Now if no coin/taka
is inserted then the machine will remain in the S0 state, and
no product will be dispensed. Now in another clock cycle if
the consumer inserts 10-taka, then the machine will remain
in the S0 state, but the purchase pin will be high, but the
money return pin will remain low in those two cases. Now
if the consumer inserts 20-taka in the vending machine for Fig. 3. State diagram for 20-taka product.
the product of 10-taka, then the purchase pin will be high,
and the money return pin also will be high and immediately
return 10-taka to the consumer. But in the first step if the money change. Tables I and II show the state table and
consumer inserts more than 5-taka for the product of 10- state transition table for three different states in terms of
taka then the machine will go to the S1 state but as the 15-taka product purchase issue. Where, S0, S1 & S2 are the
product is for 10-taka, but consumer inserts only 5-taka three different states.
as results in the purchase pin & money return pin will be Here, Tables III–VII show us the Kmap diagram for Y1,
working as an active low pin. Now if the consumer again Y2, C1, C2 & Z respectively. As a result, we can easily
inserts 5-taka then the total taka will be inserted is 10 now optimize the logic gates numbers which will simplify our
the purchase pin will be high & similarly if the consumer synthesis process and require a small area for the physical
inserts 20-taka then the purchase pin & money return pin design purposes.
both will be high [6], [7].
Figs. 2 and 3 respectively show us the state diagram for
the 15-taka product and 20-taka product. There are three 4. Simulation Results & Discussion
states are present for the 15-taka products and four states Table VIII shows the Synopsys design constraints and
for the 20-taka products. Where S0 denotes there is no taka Table IX shows the Design constraints for the design.
inserted or 0-taka state, S1 denotes 5-taka state, and S2- Table X shows the Result after the physical design.
denote the 10-taka state for the 15-taka product. But for Fig. 4 shows the synthesized circuit according to the
the 20-taka product, there is one more state that is required state diagram and Fig. 5 shows the Floor plan for the
that’s denoted as S3 state in the 20-taka state. synthesized circuit.
Fig. 6 shows the full power plan for the chip using VDD
& VSS. Fig. 7 shows the I/O pin placement for the chip.
3. State Table & Kmap
Fig. 8 shows the optimized version of the area after pin
Here the state table from the FSM is given where Z placement. The filler cell added to the rest of the space of
denotes the purchase and C1C2 denotes the amount of the chip is shown in Fig. 9. After routing Fig. 10 shows the
state Y2 Y1 Z C2 C1
state Y2 Y1 Z C2 C1
Y2 Y1 00 01 11 10 Y2 Y1 00 01 11 10
00 0 1 0 0 00 0 0 0 0
01 0 0 0 0 01 0 0 1 0
11 D D D D 11 D D D D
10 0 0 0 0 10 1 0 1 1
Note: Expression of Y1 = W2 ’ W1 Y2 ’Y1 . Note: Expression of C2 = W2 ’ W1 ’ Y2 ’ + W2 W1 Y2 + W2 W1 Y1 .
TABLE X: Result
Parameter Value
Initial density (%) 85.944
Final density (%) 95.183
Total placed cells 33
Dynamic power (nW) 44527.045
Leakage power (nW) 5.860
Total power (nW) 44532.905 Fig. 5. Floor plan.
Initial DRV violations (max_cap,max_tran,max_fan
,max_length) = 0
Remaining DRV violations 0
Initial timing violation 0
Final timing violation (Hold WNS = −0.416 ns,
mode before optimized) TNS = −2.646 ns
Final timing violation (Hold WNS = −0.385 ns,
mode after optimized) TNS = −2.469 ns
Total number DRC violations 8
Total number geometry 8
violations
Total number ProcessAntena 0
violations
Total number connectivity 10
violations
Total number Aclmit violations 0
Total number PG_SHORT 8 Fig. 6. Power plan.
violations
Total number power_via 0
violations
Fig. 12. Final design after STA, physical verification, and power
analysis.
Fig. 13. Pre-CTS time design summary (DRV and setup violations).
Machine (FSM) methodology in Verilog HDL, imple- [5] Prasad V, Ramya G, Sandeep G, Laxmareddy K. A research
mented in Genus and Encounter. The proposed design and on the design of FSM based vending machine. Int J Innovat
Technol Explor Eng. Dec 2019;8(12S2):356–60. doi: 10.35940/iji-
implementation provide a reliable and efficient solution tee.l1068.10812s219.
for users to purchase items from the vending machine. [6] Mehta D, Shah S. Vending machine using finite state machine in
The FSM model is used to manage the multiple states of verilog HDL. Int J Eng Adv Technol. 2019;8(5):1391–5.
[7] Elhossiny M, Elawady AS. Design and implementation of vend-
the vending machine, including “idle,” “accepting coins,” ing machine based on FPGA using verilog HDL. J Electr Sys.
“dispensing item,” and “returning change.” The FSM is 2016;12(3):418–27.
implemented as a state diagram in Verilog HDL, which [8] Monga A. Finite state machine based vending machine controller
with auto-billing features. Int JV LSI Design & Com Sys. Apr.
provides a high-level abstraction of the hardware and 2012;3(2):19–28. doi: 10.5121/vlsic.2012.3202.
makes it easy to simulate, synthesize, and implement the [9] Guo J, Liu Y. The design and implementation of a vending machine
design. The implementation of the vending machine is based on state machine, FPGA and microcontroller. 2021 IEEE
International Conference on Electrical Engineering and Mechatron-
done using the Genus synthesis tool and the Encounter ics Technology (ICEEMT), pp. 525–8, Qingdao, China, 2021, doi:
implementation tool. The Genus tool optimizes the design 10.1109/ICEEMT52412.2021.9601812.
for timing, area, and power, while the Encounter tool per- [10] Suthar M. A novel implementation of FPGA based smart
vending machine. 2021 IEEE International Conference
forms physical design, including placement and routing, on Technology, Research, and Innovation for Betterment
to meet the design’s timing, power, and area constraints. of Society (TRIBES), pp. 1–6, Raipur, India, 2021, doi:
The proposed design is validated using a testbench, which 10.1109/TRIBES52498.2021.9751636.
[11] Daiyan KM, Abi SB, Mustakim A. Design and implementation
simulates the behavior of the vending machine. of finite state vending machine in Bangladeshi currency. 2022 13th
The simulation results are used to verify that the design International Conference on Computing Communication and Net-
meets the required specifications, and that the FSM working Technologies (ICCCNT), pp. 1–7, Kharagpur, India, 2022,
doi: 10.1109/ICCCNT54827.2022.9984390.
behaves as expected. The proposed design is also can be [12] Sati R, Mishra V, Verma G. Simulation of vending machine design
implemented on an FPGA to demonstrate its effectiveness using verilog HDL. 2022 2nd Asian Conference on Innovation
in a real-world scenario. The results of the implementation in Technology (ASIANCON), pp. 1–5, Ravet, India, 2022, doi:
10.1109/ASIANCON55314.2022.9909003.
show that the proposed design meets the required speci- [13] Hristov V, Zhilevski M. Approach for implementation of vending
fications and performs well in a real-world scenario. The machine through verilog HDL. 2022 International Congress
design’s performance, power consumption, and area are on Human-Computer Interaction, Optimization and Robotic
Applications (HORA). Ankara, Turkey, pp. 1–4, 2022, doi:
analyzed, and the results show that the design is efficient 10.1109/HORA55278.2022.9799884.
and reliable. In conclusion, the proposed vending machine [14] Thakur JJ, Kulkarni SV, Kamat RK. Implementation of a vending
design using FSM in Verilog HDL and implemented in machine using verilog HDL. Int J Adv Res Comput Com Eng.
February 2015;4(2):321–7.
Genus and Encounter provides a reliable and efficient solu- [15] Kumar N, Kumar M, Garg MK. Design and implementation of a
tion for users to purchase items from the vending machine. vending machine using verilog HDL. Int J Comput App. October
The proposed design and implementation demonstrate the 2015;125(1):29–34.
[16] Zhang WL, Zhang XL. Design and implementation of automatic
feasibility and effectiveness of using FSM in Verilog HDL vending machine based on the short massage payment. 2010 6th
and implementing the design in Genus and Encounter for International Conference on Wireless Communications Networking
vending machine applications. The proposed design can be and Mobile Computing (WiCOM), pp. 1–4, Chengdu, China, 2010,
doi: 10.1109/WICOM.2010.5600192.
further extended and optimized for more complex vending
machines, and it can also be used as a basis for other digital
systems that require FSM-based designs.
Conflict of Interest
Authors declare that they do not have any conflict of
interest.
References
[1] Alrehily A, Fallatah R, Thayananthan V. Design of vend-
ing machine using finite state machine and visual automata
simulator. Int J Comput Appl. Apr 2015;115(18):37–42. doi:
10.5120/20254-2623.
[2] Chidananda Datta P, Vinay Kumar C, Singh R, Mumma-
neni K. Optimized RTL design of a vending machine through
FSM using verilog HDL. In Micro and Nanoelectronics Devices,
Circuits and Systems. Lecture Notes in Electrical Engineering.
Lenka TR, Misra D, Fu L. 904. Singapore: Springer, 2023, doi:
10.1007/978-981-19-2308-1_32.
[3] Luthra A, Jain A, Mishra P, Gupta V and Aggarwal S. Design
and implementation of vending machine using verilog HDL on
FPGA. International Journal of Innovative Research in Science,
Engineering and Technology (An ISO, 2015;4(II):11610–4. doi:
10.15680/IJIRSET.2015.0411137 2015.
[4] Carrad AM, Louie JCY, Milosavljevic M, Kelly B and Flood VM.
Consumer support for healthy food and drink vending machines
in public places. Aust Nz J Publ Heal. 2015;39(4):355–7. doi:
10.1111/1753-6405.12386.