CS 55111 Project Vending Machine VIRDI SABEGH SINGH Fall 2003 Project Report December 5, 2003 Contents: 1. ABSTRACT. 2. INTRODUCTION. 3. SYSTEM REQUIREMENT. 4. PROJECT INPUT/OUTPUT. 5. ASIC REQUIREMENT. 6. ALTERA IMPLEMENTATION. 7. RESULTS. 8. CONCLUSION. ABSTRACT: The project involved the design, simulation, realization and demonstration of a vending machine system using a Field Programmable Gate Array (FPGA). The behavior of a system was described using a hardware description language (AHDL AND VHDL). Introduction: This project involved the design of a microelectronic system to meet the requirements of a specific application. The system consists of input/output devices coupled with digital logic circuitry, implemented in a single application-specific integrated circuit (ASIC). The design is specified, as shown in Figure 1, at various levels of abstraction including the system, behavioral, structural, and physical levels. The design process involves mapping the requirements of the application into lower- level specifications that describe not only the internal functions, but also the interactions among the components and the external world. For this project, a hardware description language, VHDL, was used to specify portions of the design. This representation was synthesized and mapped into a chosen technology. The resulting structural (logic) description was combined with other components using a schematic editor. The design was then simulated for functionality. Once verified, the structural representation was translated into a physical representation that was placed and routed automatically. The design was then re-simulated to verify proper operation and timing. System requirement Architectural Specifications Behavioral Structural Description Description Design synthesis Simulation Figure 1: Process for Design of a Microelectronic System System Requirements: 1) Coins insertion simulation Push button PB1 is pushed a number of times to indicate the amount of coins deposited. The system accumulates the amount of coins inserted and displays current amount with the 7-segment display. Limitation is up to 0.95 cents, after which all the deposited money is returned indicating zero-zero on the 7-segment displays. Only 5 cent coins can be inserted at a time. 2) Item selection When one of the 7 dipswitches is selected and PB2 is pushed, the system checks current total deposited coins with the price of specific items selected by the dipswitch. If the deposited coins are equal or greater than the price of candy, the system lights up the specific LED representing the selected candy to indicate that the item was vended and the 7-segment displays show the amount of coins returned. When the dipswitch is returned to the initial condition, the coin return will be initiated and then all registers reset. If more than one switch is selected and PB2 is pushed, the system shows an error, and will return the deposited coins and reset. If the total deposited coins are insufficient, the system displays "LL" on the 7-segment displays until the dipswitch returns to the initial position. 3) Availability of item After the price of item is compared with the deposited coins and the, the system will check the availability of the candy. If the specific item is unavailable, the LED will not light but the 7-segment will display EE until the dipswitch is reset. The deposited money is returned. 4) Coin return mode If no dipswitch is selected and PB2 is pushed, the system goes into coin return mode. Project Input / Output: The designed candy machine has two push buttons and 7 dipswitches as inputs. Two 7-segment LED’s and seven independent LED’s are used as outputs for the candy machine. The layout for the inputs and outputs of the system are shown in Figure 2. The push button, PB1, is used to simulate coin insertion. Each press of PB1 indicates that a 5-cent coin is deposited into the candy machine. The second push button, PB2, have two functions. If none of the dipswitch (DP) is in active high, PB2 functions as a coin return button. However, if any of the DP is active high, PB2 work together with the active DP to select the specific item. Two 7-segment LED’s keep track of deposited coins. They are use to display error as well as amount of coin return. 7 Segment LCD Display PB1 FPGA PB2 DIP Switches Figure 2: System-level Block Diagram ASIC Requirements The design consists of several modules, each performing a particular task. Figure 3 shows the internal components and the I/O requirements of the ASIC. Altera Implementation The system was coded in IEEE-compliant VHDL and compiled and simulated using Mentor Graphics. This provided an opportunity to detect and correct errors early in the design process. It also allowed each module to be individually simulated to verify correct operation before the entire system was tested. After verification of the simulation for the complete system, the project file was downloaded to an Altera evaluation board containing a FLEX10K20RC240-4. This is a 240-pin FPGA which is required to be used to store the logic functions for this project. 7 pins on the chip were wired to the 7 LEDs using jumper wires. No other wiring was needed as the pushbuttons, dipswitches and 7-segment LEDs were already connected to the board. The pin numbers for each device were available in the documentation for the board, and were manually assigned in the Altera software prior to downloading. Results After successfully downloading the project to the Altera evaluation board, the project was tested according to the project specifications. The project worked satisfactorily . The error detection that was coded into the main module worked accordingly. Conclusion The objective of this project was to design and implement a candy machine using an FPGA device. The project was designed and implemented successfully. There are various improvements that could be made to the project to increase it's functionality Enable more than one type of coin to be deposited (nickels, dimes, and quarters. Keep track of item sales, including number of items sold and amount of cash received. Keep track of change available.