--------------------------------------------------------------------------------------------------- -- -- Title : mini_vending_machine -- Design : mini_vending_machine -- Author : Jamie Byun -- Company : JMJS -- --------------------------------------------------------------------------------------------------- -- -- File : mini_vending_machine.vhd -- Generated : Tue Dec 3 13:13:56 2002 -- From : interface description file -- By : Itf2Vhdl ver. 1.20 -- --------------------------------------------------------------------------------------------------- -- -- Description : -- --------------------------------------------------------------------------------------------------- --{{ Section below this comment is automatically maintained -- and may be overwritten --{entity {mini_vending_machine} architecture {JMJS_Logic}} library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_unsigned.all; entity mini_vending_machine is port( rst : in STD_LOGIC; clk : in STD_LOGIC; coffee_button : in STD_LOGIC; orange_button : in STD_LOGIC; tea_button : in STD_LOGIC; change_return : in STD_LOGIC; coin_500 : in STD_LOGIC; coin_100 : in STD_LOGIC; coin_50 : in STD_LOGIC; coin_10 : in STD_LOGIC; change : out STD_LOGIC_VECTOR(7 downto 0); coffee_out : out STD_LOGIC; tea_out : out STD_LOGIC; orange_out : out STD_LOGIC ); end mini_vending_machine; --}} End of automatically maintained section architecture JMJS_Logic of mini_vending_machine is signal sum : std_logic_vector(7 downto 0); begin process(clk) begin if (rst = '1') then sum <= "00000000"; orange_out <= '0'; tea_out <= '0'; coffee_out <= '0'; elsif (clk'event and clk='1') then if (coin_500 = '1' ) then sum <= sum + 50; orange_out <= '0'; tea_out <= '0'; coffee_out <= '0'; elsif (coin_100 = '1') then sum <= sum + 10; orange_out <= '0'; tea_out <= '0'; coffee_out <= '0'; elsif (coin_50 = '1') then sum <= sum + 5; orange_out <= '0'; tea_out <= '0'; coffee_out <= '0'; elsif (coin_10 = '1') then sum <= sum + 1; orange_out <= '0'; tea_out <= '0'; coffee_out <= '0'; elsif (change_return = '1') then sum <= "00000000"; orange_out <= '0'; tea_out <= '0'; coffee_out <= '0'; elsif (coffee_button = '1' and sum >= 30) then sum <= sum - 30; coffee_out <= '1'; tea_out <= '0'; orange_out <= '0'; elsif (tea_button='1' and sum >= 15) then sum <= sum - 15; coffee_out <= '0'; tea_out <= '1'; orange_out <= '0'; elsif (orange_button = '1' and sum >= 10) then sum <= sum - 10; coffee_out <= '0'; tea_out <= '0'; orange_out <= '1'; else coffee_out <= '0'; tea_out <= '0'; orange_out <= '0'; end if; end if; end process; process(clk) begin if (clk'event and clk='1') then if (change_return = '1') then change <= sum; else change <= (others => '0'); end if; end if; end process; end JMJS_Logic;