31

Click here to load reader

HDL Implementation of Vending Machine Report with Verilog Code

Embed Size (px)

DESCRIPTION

A vending machine is a machine which dispenses items such as snacks, beverages, lottery tickets, consumer products to customers automatically, after the customer inserts currency or credit into the machine. Nowadays, Vending Machines are well known among Japan, Malaysia and Singapore. The quantity of machines in these countries is on the top worldwide. This is due to the modern lifestyles which require fast food processing with high quality. This paper describes the designing of Vending Machine with Auto-Billing Features. The objective here is to design Vending Machine Controller which accepts money inputs (i and j) in any sequence and delivers the products when the required amount has been deposited and gives back the change. Here an additional facility is provided to the user. It is possible to withdraw the deposited money in between if the customer wishes so by pressing a push button. The Verilog Code for the proposed Vending Machine model is developed and the Simulation results are successfully verified using Xilinx ISE 9.2i tool.

Citation preview

Page 1: HDL Implementation of Vending Machine Report with Verilog Code

Mini Project Report

Page 2: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

ABSTRACT

A vending machine is a machine which dispenses items such as snacks, beverages, lottery

tickets, consumer products to customers automatically, after the customer inserts

currency or credit into the machine. Nowadays, Vending Machines are well known among

Japan, Malaysia and Singapore. The quantity of machines in these countries is on the top

worldwide. This is due to the modern lifestyles which require fast food processing with high

quality. This paper describes the designing of Vending Machine with Auto-Billing Features.

The objective here is to design Vending Machine Controller which accepts money inputs (i

and j) in any sequence and delivers the products when the required amount has been

deposited and gives back the change. Here an additional facility is provided to the user. It is

possible to withdraw the deposited money in between if the customer wishes so by pressing a

push button. The Verilog Code for the proposed Vending Machine model is developed and

the Simulation results are successfully verified using Xilinx ISE 9.2i tool.

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 2

Page 3: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

TABLE OF CONTENTS

CHAPTER PAGE NO.

1. INTRODUCTION 04

2. VENDING MACHINE AND ITS HISTORY 05

3. DESIGN METHODOLOGY 08

4. IMPLEMENTATION METHODS 11

5. ADVANTAGES AND DISADVANTAGES 13

6. VERILOG CODE 15

7. SIMULATION AND RESULTS 18

8. CONCLUSION 22

9. REFERENCES 23

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 3

Page 4: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

CHAPTER 1

INTRODUCTION

Vending Machines are used to dispense various products like Coffee, Snacks, and Cold

Drink etc. when money is inserted into it. Vending Machines have been in existence since

1880s. The first commercial coin operated machine was introduced in London and England

used for selling post cards. The vending machines are more accessible and practical than the

convention purchasing method. Nowadays, these can be found everywhere like at railway

stations selling train tickets, in schools and offices vending drinks and snacks , in banks as

ATM machine and provides even diamonds and platinum jewelers to customers. Previous

CMOS and SED based machines are more time consuming than the FPGA based machines.

The FPGA based machine is also more flexible, programmable and can be re-programmed.

But in microcontroller based machine, if one wants to enhance the design, he has to change

the whole architecture again but in FPGA user can easily increase the number of products.

In this paper a new approach is proposed to design a Vending Machine with auto-billing

features. The machine also supports a cancel feature means that the person can withdraw the

request and the money will be returned back to the user. This machine can be used at various

places like Hotels, Restaurants and food streets. This reduces the time and cost.

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 4

Page 5: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

CHAPTER 2

VENDING MACHINE AND ITS HISTORY

A vending machine is a machine which dispenses items such as snacks, beverages, alcohol,

cigarettes, lottery tickets, cologne, consumer products and even gold and gems to customers

automatically, after the customer inserts currency or credit into the machine.

History

The earliest known reference to a vending machine is in the work

of Hero of Alexandria, a first-century engineer and mathematician.

His machine accepted a coin and then dispensed holy water. When

the coin was deposited, it fell upon a pan attached to a lever.

The lever opened a valve which let some water flow out. The pan

continued to tilt with the weight of the coin until it fell off, at which

point a counterweight snapped the lever up and turned off the valve.

Modern vending machines

The first modern coin-operated vending machines were introduced in London, England in the

early 1880s, dispensing post cards. The machine was invented by Percival Everitt in 1883

and soon became a widespread feature at railway stations and post offices,

dispensing envelopes, postcards and notepaper. The Sweetmeat Automatic Delivery

Company was founded in 1887 in England as the first company to deal primarily with the

installation and maintenance of vending machines.

The first vending machine in the U.S. was built in 1888 by the Thomas Adams Gum

Company, selling gum on New York City train platforms. The idea of adding games to these

machines as a further incentive to buy came in 1897 when the Pulver Manufacturing

Company added small figures, which would move around whenever somebody bought some

gum from their machines. This idea spawned a whole new type of mechanical device known

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 5

Page 6: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

as the "trade stimulators". The birth of slot machines and pinball is ultimately rooted in these

early devices.

In December 1970, Ussery Industries of Dallas, Texas at its Dallas convention displayed its

"talking" vending machine, the Venda Talker. With insertion of a coin, the machine said

"thank you" and added a one-liner voiced by comic Henny Youngman.

In the Western world, some vending machines dispense personal products, typically in public

toilet facilities. These are often found at toilets used by transient persons in high traffic

locations, such as bus stations, shopping centers, airports and service stations.

From the 1950s until well into the 1970s, vending machines were used at American airports

to sell life insurance policies covering death, in the event that the buyer's flight crashed. Such

policies were quite profitable, because the risk of a plane crash is low. However, this practice

gradually disappeared due to the tendency of American courts to strictly construe such

policies against their sellers, such as Mutual of Omaha.

Starting with 1994, vending machines approached successfully the basic food commerce

specialization and began to compete with the Fast-Moving Consumer Goods industry. Milk

dispensers and egg vending machines networks spreading in European towns accelerated

after 2000. The basic food vending machines are usually owned by farmers selling their

production directly to consumers, providing fresh food to urban population at low prices,

small operational costs and encouraging the distributism.

Another type of vending machine is a Chargebox which is used for charging small mobile

devices such as mobile phones and iPods. They are useful for when one runs out of power on

such devices in between locations like home and work.

From 2000-2010, specialization of vending machines became more common. Vending

extended increasingly into non-traditional areas like electronics, or even artwork. Machines

of this new category are generally called Automated Retail kiosks. The trend of

specialization and proliferation of vending machines is perhaps most apparent in Japan where

vending machines sell products from toilet paper to hot meals, and there is 1 vending

machine per 23 people.

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 6

Page 7: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

Liskom (Russia) and Xerox (Global) both have coin-operated or pay-per-copy vending

machines.

A full-line vending company may set up several types of vending machines that sell a wide

range of products. Products may include candy, cookies, chips, fresh fruit, milk, cold food,

coffee and other hot drinks, bottles, cans of soda, and even frozen products like ice cream.

These products can be sold from machines that include coffee, snack, cold food, 20-oz. bottle

machines, and glass-front bottle machines. 

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 7

Page 8: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

CHAPTER 3

DESIGN METHODOLOGY OF VENDING MACHINE

FINITE STATE MACHINE METHOD

A finite-state machine (FSM) or finite-state automaton (plural: automata), or simply a state

machine, is a mathematical model of computation used to design both computer

programs and sequential logic circuits. It is conceived as an abstract machine that can be in

one of a finite number of states. The machine is in only one state at a time; the state it is in at

any given time is called the current state. It can change from one state to another when

initiated by a triggering event or condition; this is called a transition. A particular FSM is

defined by a list of its states, and the triggering condition for each transition.

The behavior of state machines can be observed in many devices in modern society which

perform a predetermined sequence of actions depending on a sequence of events with which

they are presented. Simple examples are vending machines which dispense products when

the proper combination of coins is deposited, elevators which drop riders off at upper floors

before going down, traffic lights which change sequence when cars are waiting,

and combination locks which require the input of combination numbers in the proper order.

Finite-state machines can model a large number of problems, among which are electronic

design automation, communication protocol design, language parsing and other engineering

applications. In biology and artificial intelligence research, state machines or hierarchies of

state machines have been used to describe neurological systems and in linguistics—to

describe the grammars of natural languages.

Considered as an abstract model of computation, the finite state machine is weak; it has less

computational power than some other models of computation such as the Turing

machine. That is, there are tasks which no FSM can do, but some Turing machines can. This

is because the FSM has limited memory. The memory is limited by the number of states.

FSMs are studied in the more general field of automata theory.

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 8

Page 9: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

The automata theory is the basis behind the traditional model of computation and is used for

many purposes other than controller circuit design, including computer program compiler

construction, proofs of algorithm complexity, and the specification and classification of

computer programming languages. Because automata are mathematical models that produce

values dependent upon internal state and possibly some dependent input values, they are

referred to as state machines. A state machine may allow for a finite or an infinite set of

possible states and furthermore, they may have nondeterministic or deterministic behavior. A

deterministic state machine is one whose outputs are the same for a given internal state and

input values. A finite state machine (FSM) is one where all possible state values made a

finite set.

In a Finite State Machine the circuit’s output is defined in a different set of states i.e. each

output is a state. A State Register to hold the state of the machine and a next state logic to

decode the next state. An output register defines the output of the machine. In FSM based

machines the hardware gets reduced as in this the whole algorithm can be explained in one

process.

Two types of State machines are:

MEALY Machine: In this machine model, the output depends on the present state as

well as on the input. The MEALY machine model is shown in figure 1.

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 9

Page 10: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

MOORE Machine: In Moore machine model the output only depends on the present

state. The MOORE machine model is shown in figure 2.

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 10

Page 11: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

CHAPTER 4

IMPLEMENTATION METHODS

FPGA BASED DESIGN

A field-programmable gate array (FPGA) is an integrated circuit designed to be configured

by a customer or a designer after manufacturing—hence "field-programmable". The FPGA

configuration is generally specified using a hardware description language(HDL), similar to

that used for an application-specific integrated circuit (ASIC) (circuit diagrams were

previously used to specify the configuration, as they were for ASICs, but this is increasingly

rare).

Contemporary FPGAs have large resources of logic gates and RAM blocks to implement

complex digital computations. As FPGA designs employ very fast I/Os and bidirectional data

buses it becomes a challenge to verify correct timing of valid data within setup time and hold

time. Floor planning enables resources allocation within FPGA to meet these time

constraints. FPGAs can be used to implement any logical function that an ASIC could

perform. The ability to update the functionality after shipping, partial re-configuration of a

portion of the design and the low non-recurring engineering costs relative to an ASIC design

(notwithstanding the generally higher unit cost), offer advantages for many applications.

FPGAs contain programmable logic components called "logic blocks", and a hierarchy of

reconfigurable interconnects that allow the blocks to be "wired together"—somewhat like

many (changeable) logic gates that can be inter-wired in (many) different configurations.

Logic blocks can be configured to perform complex combinational functions, or merely

simple logic gates like AND and XOR. In most FPGAs, the logic blocks also include

memory elements, which may be simple flip-flops or more complete blocks of memory.

Some FPGAs have analog features in addition to digital functions. The most common analog

feature is programmable slew rate and drive strength on each output pin, allowing the

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 11

Page 12: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

engineer to set slow rates on lightly loaded pins that would otherwise ring unacceptably, and

to set stronger, faster rates on heavily loaded pins on high-speed channels that would

otherwise run too slowly. Another relatively common analog feature is differential

comparators on input pins designed to be connected to differential signaling channels. A few

"mixed signal FPGAs" have integrated peripheral analog-to-digital converters

(ADCs) and digital-to-analog converters (DACs) with analog signal conditioning blocks

allowing them to operate as a system-on-a-chip. Such devices blur the line between an

FPGA, which carries digital ones and zeros on its internal programmable interconnect fabric,

and field-programmable analog array (FPAA), which carries analog values on its internal

programmable interconnect fabric.

CMOS BASED DESIGN

"CMOS" refers to both a particular style of digital circuitry design and the family of

processes used to implement that circuitry on integrated circuits (chips). CMOS circuitry

dissipates less power than logic families with resistive loads. Since this advantage has

increased and grown more important, CMOS processes and variants have come to dominate,

thus the vast majority of modern integrated circuit manufacturing is on CMOS processes.  As

of 2010, CPUs with the best performance per watt each year have been CMOS static

logic since 1976.

CMOS circuits use a combination of p-channel and n-channel metal–oxide–semiconductor

field-effect transistors (MOSFETs) to implement logic gates. Although CMOS logic can be

implemented with discrete devices for demonstrations, commercial CMOS products are

integrated circuits composed of up to millions of transistors of both types on a rectangular

piece of silicon of between 10 and 400 mm2

.SINGLE ELECTRON DEVICE (SED) BASED DESIGN

Single Electron Devices (SED) are promising for future ULSI technology because of their

ultra low power consumption, higher density of integration and switching speed. Structure of

SED is based on the discrete nature of electrons tunneling through thin potential barriers. The

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 12

Page 13: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

ultimate goal of this work is to venture one possible way of using electron-tunneling devices

instead of conventional MOS transistors to design and simulate an automatic tea/coffee

vending system. The proposed vending machine will establish a good approximation for the

limits and challenges that ever-shrinking circuits will meet eventually, when the size of the

components become comparable to that of electrons.

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 13

Page 14: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

CHAPTER 5

ADVANTAGES AND DISADVANTAGES

Advantages:

1. Vending machines give the clients a free choice to purchase products at any time of

the day. One can shop for his or her intended product on a 24 hour, throughout the

year.

2. Diversity in terms of the products that a vending machine can handle is another

advantage that this technology in business has brought. A wide range of products can

be sold using the machine as fruits, beverages, drinks, and cigarettes among other

products. This concept is also applied to some service provision industries like air

drier, play stations and other public utility practices.

3. Reduction of overhead costs by not hiring of staff only increases the profit margin for

the owner making it a success bound venture.

4. The machine can always be moved to other areas if need arises and it will continue

delivering the services as usual.

Disadvantages:

1. The main disadvantage of vending machine is that it can cost you a lot of money.

2. Fraud cases are also common in this kind of business by customers who formulate

means of hacking into the system of the machine to dispense products.

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 14

Page 15: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

CHAPTER 6

VERILOG CODE OF VENDING MACHINE

The objective here is to design Vending Machine Controller which accepts money inputs(i

and j) in any sequence and delivers the products when the required amount has been

deposited and gives back the change. Here an additional facility is provided to the user. It is

possible to withdraw the deposited money in between if the customer wishes so by pressing a

push button.

SPECIFICATIONS:

1. Price of the product=Rs.3.

2. Possible money inputs=Rs.2 and Re.1.

3. Product to be delivered when Rs.3 or Rs.4 is reached.

4. A Push button is there (pu) which indicates the cancellation of transaction and the

return of the amount deposited.

VERILOG CODE:

/*

Here

i=0 indicates no coin has been detected.

i=1 and j=0 indicates the detection of Re.1 coin.

i=1 and j=1 indicates the detection of Rs.2 coin.

pu indicates push button to cancel the transaction.

Output p and c indicates the product delivery and coin return respectively.

*/

module vend(pu,i,j,rst,clk,p,c);

input pu,i,j,rst,clk;

output p,c;

reg [2:0] state,NS;

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 15

Page 16: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

parameter

S0=3'b000,S1=3'b001,S2=3'b010,S3=3'b011,S4=3'b100,S5=3'b101,S6=3'b110,S7=3'b111;

always@ (posedge clk or negedge rst)

if (~rst) state=S0;

else state=NS;

always@(state or i or j or pu)

case(state)

S0:NS=pu?S0:(i?(j?S2:S1):S0);

S1:NS=pu?S5:(i?(j?S3:S2):S1);

S2:NS=pu?S6:(i?(j?S4:S3):S2);

S3:NS=S0;

S4:NS=S0;

S5:NS=S0;

S6:NS=S5;

S7:NS=S0;

endcase

assign

{p,c}={(state[0]&state[1]&~state[2])|(~state[0]&~state[1]&state[2]),(state[2]&~state[1])|

(state[2]&~state[0])};

endmodule

CODE STIMULATION:

The above code is stimulated by writing a test bench. A specific case of a test bench is

shown below.

module testbench();

reg pu,i,j,rst,clk;

wire p,c;

vend test(pu,i,j,rst,clk,p,c);

always

#5 clk=~clk;

initial

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 16

Page 17: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

begin

i=1'b0;

j=1'b0;

clk=1'b0;

rst=1'b0;

pu=1'b0;

#5 rst=1'b1;

#5 i=1'b1;

#5 pu=1'b1;

#100 $finish;

end

endmodule

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 17

Page 18: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

CHAPTER 7

SIMULATION AND RESULTS

The verilog code is simulated and compiled in Xilinx ISE 9.2i tool. And the following

desired results are obtained.

NOTE: Price of the Product is Rs. 3

1. Return of Rs. 2 after the Cancel (pu) button is pressed.

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 18

Page 19: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

2. Product Delivery and Return of Change after Rs. 4 insertion.

3. Product Delivery after Rs. 3 insertion

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 19

Page 20: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

RTL SHEMATIC

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 20

Page 21: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

BLOCKS OF RTL SCHEMATIC

TECHNOLOGY SCHEMATIC

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 21

Page 22: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

CHAPTER 8

CONCLUSION

When we realized that we have at last made a code that could actually work as a user friendly

vending machine. This code can actually provide a variety of options to the user and also

return him/her the balance money. This verilog code has been successfully verified using the

Xilinx ISE 9.2i tool and the desired outputs have been achieved. Vending Systems enhances

productivity, reduces system development cost, and accelerates time to market. Vending

machine give fast response and easy to use by an ordinary person. The designed machine can

be used for many applications and we can easily enhance the number of selections. The next

stage of this study is to convert this model into hardware and to calculate the total power

consumption of the machine. Thus we would conclude saying that we tried our bit to modify

the present day complex vending machine into a user friendly and user specific vending

machine.

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 22

Page 23: HDL Implementation of Vending Machine Report with Verilog Code

HDL Implementation of Vending Machine Controller 2013

REFERENCES

1. Fauziah Zainuddin, Norlin Mohd Ali, Roslina Mohd Sidek, Awanis Romli, Nooryati

Talib & Mohd. Izham Ibrahim (2009) “Conceptual Modeling for Simulation:

Steaming frozen Food Processing in Vending Machine” International Conference on

Computer Science and Information Technology, University Malaysia Pahang,

pp.145-149.

2. Xilinx Inc., Spartan 3 Data sheet: http://ww w.xilinx.com.

3. Bhaskar “VHDL primer” Second Edition.

4. Peter Minns & Ian Elliott, “FSM-based Digital Design using Verilog HDL”, John

Wiley & Sons Ltd 2008.

5. Zhang Wen & Zhang Xin Long (2010) “Design and Implementation of automatic

vending machine Based on the short massage payment” International Conference on

Information and Communication technology in Electrical Sciences, Neijiang,

Sichuan, China.pp.978-981.

| 1st Semester M. Tech( VLSI Design & Embedded Systems) 23