You are on page 1of 7

Vol. I - DC Vol. II - AC Vol. III - Semiconductors Vol. IV - Digital Vol. V - Reference Vol.

VI - Experiments Worksheets Videos

All About Circuits Forum > Software, Microcomputing, and Communications Forums > Programmer's Corner
vhdl vending machine.

User Name Password

User Name

Remember Me?

Register

Blogs

FAQ

Community

Today's Posts

Search

Notices Welcome to the All About Circuits forums. Our forum is a place where thousands of students, hobbyists and professionals from around the world share knowledge and ideas. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. Programmer's Corner Discussion forum for all aspects of programming and software engineering. Any software programming language welcome: C, C++, C#, Fortran, Java, Matlab, etc.

Thread Tools #1 04-10-2009, 09:34 PM gammaman Junior Member vhdl vending machine.

Display Modes

Join Date: Feb 2009 Posts: 29

I am trying to implement a vhdl vending machine. I have vectors to keep track of the coins. But this is not my main concern. What I want to be able to do is give the user multiple choices of items all with varying prices. I then want the program to detect how many and what type of coin (nickel,dime,quarter) was put in the machine, until the price or greater is reached. It will then calculate how much money to return. So what I need help with is the Case selection part of the code below. I need help writing a function so that it is clean. Code:
--using textio.all Entity Soda_Machine is port( --would need maximum of 30 nickles NICKEL_IN : std_logic_vector(4 downto 0); --would need maximum of 15 dimes DIME_IN : std_logic_vector(3 downto 0); --would need maxium of 6 quarters QUARTER_IN: std_logic_vector(2 downto 0); SELECTION: std_logic_vector(15 downto 0); PRICE: out std_logic_vector(15 downto 0); RESET: BOOLEAN; CLK: BIT; --return change and soda NICKEL_OUT, DIME_OUT, DISPENSE: out BOOLEAN ); End Soda_Machine; architecture BEHAVIOR of Soda_Machine is signal Current_Coin_Count, Next_Coin_Count: INTEGER range 0 to 30; -- 30 nickles is $1.50 signal Current_Return_Change, Next_Return_Change : BOOLEAN; begin process(NICKEL_IN, DIME_IN, QUARTER_IN, RESET, CLK, Current_Coin_Count, Current_Return_Change) --maximum amount of coins --possible is 30 niickles

variable Temp_Coin_Count: INTEGER range 0 to 30; begin -- Set all Change Returned to 0 NICKEL_OUT <= FALSE; DIME_OUT <= FALSE; DISPENSE <= FALSE; Next_Coin_Count <= 0; NEXT_Return_Change <= FALSE; -- Synchronous reset if (not RESET) then Temp_Coin_Count := Current_Coin_Count; Case SELECTION is when "000" => PRICE := "110010"; End Case; -- Check whether change was put in the Machine if (NICKEL_IN) then Temp_Coin_Count := Temp_Coin_Count + 1; --counting number of nickles inputed elsif(DIME_IN) then Temp_Coin_Count := Temp_Coin_Count + elsif(QUARTER_IN) then Temp_Coin_Count := Temp_Coin_Count + inputed end if; -- Keeps track if enough change was put --Macine Requires 25 Nickles if(Temp_Coin_Count >= 25) then Temp_Coin_Count := Temp_Coin_Count --soda given to customer DISPENSE <= TRUE; end if; 2; --counting number of dimes inputed 5; --counting number of quarters in machine 25;

--If too many nickles change is returned if(Temp_Coin_Count >= 1 or Current_Return_Change) then if(Temp_Coin_Count >= 2) then --dime returned DIME_OUT <= TRUE; Temp_Coin_Count := Temp_Coin_Count - 2; --stil return more change Next_Return_Change <= TRUE; end if; if(Temp_Coin_Count = 1) then --nickle returned NICKEL_OUT <= TRUE; Temp_Coin_Count := Temp_Coin_Count - 1; end if; end if; Next_Coin_Count <= Temp_Coin_Count; end if; end process; process begin

--returns change on positive clock edege wait until CLK' event and CLK = '1'; Current_Return_Change <= NEXT_Return_Change; Current_Coin_Count <= Next_Coin_Count; end process; end BEHAVIOR;

Select All

Bookmarks

Digg del.icio.us StumbleUpon Google

Tags machine, vending, vhdl Previous Thread | Next Thread Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules Similar Threads Thread Thread Starter Forum Replies Last Post

Forum Jump

Similar Threads Project (vending machine) mr.harm The Projects Forum 2 03-222009 09:07 PM 02-182009 08:24 AM 02-172009 03:42 PM 02-162009 05:40 AM 08-102008 08:31 PM

modelig a sequetial circuit for vending machine modeling a sequential circuit using vending machine modeling a sequential circuit for vending machine using moore and mealy fsm Auto Washing Machine for FPGA (VHDL Codes)

FUNJOKE

Homework Help

FUNJOKE

The Projects Forum

FUNJOKE

General Electronics Chat

vincelimch

The Projects Forum

11

All times are GMT. The time now is 12:29 PM.

- All About Circuits - Archive - Privacy Statement - Terms of Service - Newsgroup Ar User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License. Powered by vBulletin Version 3.8.6 Copyright 2000 - 2011, Jelsoft Enterprises Ltd.
--using textio.all Entity Soda_Machine is port( --would need maximum of 30 nickles NICKEL_IN : std_logic_vector(4 downto 0); --would need maximum of 15 dimes DIME_IN : std_logic_vector(3 downto 0); --would need maxium of 6 quarters QUARTER_IN: std_logic_vector(2 downto 0); SELECTION: std_logic_vector(15 downto 0); PRICE: out std_logic_vector(15 downto 0); RESET: BOOLEAN; CLK: BIT; --return change and soda NICKEL_OUT, DIME_OUT, DISPENSE: out BOOLEAN ); End Soda_Machine; architecture BEHAVIOR of Soda_Machine is signal Current_Coin_Count,

Next_Coin_Count: INTEGER range 0 to 30; -- 30 nickles is $1.50 signal Current_Return_Change, Next_Return_Change : BOOLEAN; begin process(NICKEL_IN, DIME_IN, QUARTER_IN, RESET, CLK, Current_Coin_Count, Current_Return_Change) --maximum amount of coins --possible is 30 niickles variable Temp_Coin_Count: INTEGER range 0 to 30; begin -- Set all Change Returned to 0 NICKEL_OUT <= FALSE; DIME_OUT <= FALSE; DISPENSE <= FALSE; Next_Coin_Count <= 0; NEXT_Return_Change <= FALSE; -- Synchronous reset if (not RESET) then Temp_Coin_Count := Current_Coin_Count; Case SELECTION is when "000" => PRICE := "110010"; End Case; -- Check whether change was put in the Machine if (NICKEL_IN) then Temp_Coin_Count := Temp_Coin_Count + 1; --counting number of nickles inputed elsif(DIME_IN) then Temp_Coin_Count := Temp_Coin_Count + elsif(QUARTER_IN) then Temp_Coin_Count := Temp_Coin_Count + inputed end if; -- Keeps track if enough change was put --Macine Requires 25 Nickles if(Temp_Coin_Count >= 25) then Temp_Coin_Count := Temp_Coin_Count --soda given to customer DISPENSE <= TRUE; end if; 2; --counting number of dimes inputed 5; --counting number of quarters in machine 25;

--If too many nickles change is returned if(Temp_Coin_Count >= 1 or Current_Return_Change) then if(Temp_Coin_Count >= 2) then --dime returned DIME_OUT <= TRUE; Temp_Coin_Count := Temp_Coin_Count - 2; --stil return more change Next_Return_Change <= TRUE; end if; if(Temp_Coin_Count = 1) then --nickle returned NICKEL_OUT <= TRUE; Temp_Coin_Count := Temp_Coin_Count - 1; end if;

end if; Next_Coin_Count <= Temp_Coin_Count; end if; end process; process begin --returns change on positive clock edege wait until CLK' event and CLK = '1'; Current_Return_Change <= NEXT_Return_Change; Current_Coin_Count <= Next_Coin_Count; end process; end BEHAVIOR;

You might also like