Skip to content

This project implements a Verilog-based Vending Machine Controller with support for APB configuration, item dispensing, and currency validation. It features FSM control, clock domain synchronization, and is fully synthesizable for FPGA applications.

Notifications You must be signed in to change notification settings

Krishnasa1/vending_machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

vending_machine

🧾 Vending Machine Controller – Verilog HDL

This project implements a Vending Machine Controller using Verilog HDL, designed to operate in both configuration and operational modes. The controller supports up to 1024 items and accepts currency denominations up to β‚Ή100, making it scalable and suitable for real-world embedded vending applications.

image

This image explains the block diagram of vending machine

πŸ”§ Features

  • βœ… FSM-Based Control: Finite State Machine manages reset, configuration, and operation modes.
  • πŸ› οΈ APB Interface: Supports configuration via APB protocol (using a 10 MHz clock).
  • πŸ•’ Clock Domain Crossing (CDC): Safely handles asynchronous currency inputs across clock domains.
  • πŸ’΅ Smart Currency Logic: Validates currency and dispenses items or returns appropriate change.
  • πŸ“Š Register Mapping: Each item stores price, available stock, and number of items dispensed.
  • πŸ“ˆ Scalable Design: Parametrized for up to 1024 items and β‚Ή100 denominations.
  • πŸ” Synthesizable RTL: Fully synthesizable and simulation-ready in Vivado or ModelSim.

🧱 Modules

  • vending_machine.v: Main controller integrating FSM, APB interface, and operation logic.
  • testbench.v: Verification module for simulating different scenarios.
  • Optional helper modules (e.g., FSM, currency_decoder) can be added as needed.

πŸ§ͺ Simulated Using

  • Vivado – for synthesis and behavioral simulation

image

The vending machine controller was rigorously validated through 7 test cases covering normal operation and error scenarios. Simulation waveforms confirm correct functionality. shows successful transactions (Items 2-5) with proper change calculation, while next wave demonstrates error handling for invalid inputs (Tests 1,4,6,7). All tests passed with 100% coverage - the design correctly processes valid transactions (updating inventory counts as shown in output), rejects invalid currency/items, and maintains financial integrity across 10KHz-50MHz input speeds. Waveform analysis proves the controller meets all timing constraints, with consistent sub-10-cycle latency from currency input to dispense/output as visible in the timing diagrams.

TEST CASES

Test Plan

πŸ“¦ Use Case

This design can be used for:

  • FPGA-based vending systems
  • Educational labs on digital design and embedded systems
  • RTL-level prototyping of real-time controllers

πŸ“š Project Highlights

  • Designed with industry-level structure
  • Implements real-time event handling and change-return mechanism
  • Ensures glitch-free operation across different clock domains

Conclusion

The vending machine controller project was successfully implemented. The design achieved efficient real-time dispensing, correct management of item stock and change, and safe handling of asynchronous currency inputs. By providing a flexible configuration mode and robust FSM design, the controller is ready for integration into real-world vending machine systems, meeting the design and performance criteria specified.

About

This project implements a Verilog-based Vending Machine Controller with support for APB configuration, item dispensing, and currency validation. It features FSM control, clock domain synchronization, and is fully synthesizable for FPGA applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published