PR
Preven-K/Vending-Machine
Verilog-based vending machine controller IP core, supporting multi-clock domain operation, inventory management, and currency denominations. Built with the APB protocol for efficient configuration, it offers smart change calculation and robust error handling. Developed in the SURE ProEd internship training with experts.
PREVEN-K-G3-Integrated-VLSI
FPGA Vending Machine Controller
Domain: ๐ฅ๏ธ VLSI Design / ๐งฎ FPGA Development
Technology: ๐ Verilog
Compliance: ๐ APB Protocol
๐ Table of Contents
- ๐ Introduction
- โจ Key Features
- ๐ Visual Documentation
- ๐๏ธ System Architecture
- ๐ Interface Specifications
- โ๏ธ Configuration Protocol
- ๐ Results & Validation
- ๐ฎ Future Scope
๐ Introduction
This repository contains a production-grade ๐๏ธ Verilog implementation of a vending machine controller IP core with:
- โฑ๏ธ Multi-clock domain operation:
- ๐ฆ 1024-item inventory management
- ๐ฐ Six currency denomination support with smart change calculation
- ๐ Built-in error handling mechanisms
โจ Key Features
๐ฏ Core Specifications
| Feature | Specification | Notes |
|---|---|---|
| ๐ถ Max Items | 1024 | Parameterized via MAX_ITEMS |
| ๐ต Max Currency | 100 units | Configurable with MAX_CURRENCY |
| โก Transaction Latency | <10 clock cycles | Worst-case scenario |
| ๐ข Supported Denominations | 5, 10, 15, 20, 50, 100 | Hard-coded in FSM |
๐ก๏ธ Reliability Features
- ๐ง Metastability-protected inputs (2-stage synchronizers)
- ๐ Automatic inventory reconciliation
- ๐จ Immediate refund for:
- Invalid currency (non-standard denominations)
- Out-of-stock items
- Configuration errors
๐ Visual Documentation
๐๏ธ Block Diagram
โฑ๏ธ Timing Diagrams
๐๏ธ System Architecture
Finite State Machine
| State Code | Mode | Description |
|---|---|---|
| 00 | RESET | Initialization state, all registers cleared |
| 01 | CONFIG | APB interface active for inventory setup |
| 10 | OPERATION | Normal vending machine operation |
๐ Interface Specifications
๐๏ธ Control Ports
| Signal | Type | Width | Description |
|---|---|---|---|
clk |
Input | 1b | 100MHz ยฑ50ppm |
rstn |
Input | 1b | Async active-low reset |
cfg_mode |
Input | 1b | Config/operation mode select |
๐ฐ Currency Interface
| Signal | Direction | Timing | Description |
|---|---|---|---|
currency_valid |
Input | 10KHz-50MHz | Single-cycle pulse |
currency_value |
Input | 7b | Encoded denomination |
๐ Item Interface
| Signal | Direction | Condition | Description |
|---|---|---|---|
item_select |
Input | Operation mode | 10-bit encoded product ID |
item_select_valid |
Input | Operation mode | Selection validation pulse |
๐ APB Configuration
| Signal | Width | Direction | Description |
|---|---|---|---|
paddr |
15b | Input | Register address |
pwdata |
32b | Input | Write data |
prdata |
32b | Output | Read data |
pready |
1b | Output | Transfer ready |
โ๏ธ Configuration Protocol
Memory Map
| Address Range | Register | Access | Description |
|---|---|---|---|
| 0x4000_0000 | CFG_CTRL | RW | Global control |
| 0x4000_0004 | ITEM_0 | RW | First item config |
| ... | ... | ... | ... |
| 0x4000_0FFC | ITEM_1023 | RW | Last item config |
Register Format
| Bits | Field | Type | Description |
|---|---|---|---|
| 31-24 | DISPENSED | RO | Items sold count |
| 23-16 | AVAILABLE | RW | Current stock |
| 15-0 | PRICE | RW | Item value |
๐ Results & Validation
โ Test Cases
| Scenario | Input | Expected Output | Results |
|---|---|---|---|
| Exact Payment | Item5 (20) + 20 | Dispense5 + 0 | โ๏ธ |
| Overpayment | Item3 (15) + 20 | Dispense3 + 5 | โ๏ธ |
| Out-of-Stock | Item10 (0) + 50 | Empty(1023) + 50 | โ |
| Invalid Currency | Item2 + 13 | Empty(1023) + 13 | โ |
๐ Simulation Outputs
๐ฆ Test Plan
๐ฐ Results
๐ฎ Future Scope
- ๐ง NFC/RFID interface
- ๐ฑ Remote inventory monitoring
- ๐น Dynamic pricing engine






