--------------------------------------------------------------------------------------------------- -- -- Title : mini_vending_machine1 -- Design : mini_vending_machine1 -- Author : Jamie Byun -- Company : JMJS -- --------------------------------------------------------------------------------------------------- -- -- File : mini_vending_machine1.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_machine1 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_machine1; --}} End of automatically maintained section architecture JMJS_Logic of mini_vending_machine1 is signal sum : std_logic_vector(7 downto 0); begin process(clk) begin if (rst = '1') then sum <= "00000000"; elsif (clk'event and clk='1') then if (coin_500 = '1' ) then sum <= sum + 50; elsif (coin_100 = '1') then sum <= sum + 10; elsif (coin_50 = '1') then sum <= sum + 5; elsif (coin_10 = '1') then sum <= sum + 1; elsif (change_return = '1') then sum <= "00000000"; elsif (coffee_button = '1' and sum >= 30) then sum <= sum - 30; elsif (tea_button='1' and sum >= 15) then sum <= sum - 15; elsif (orange_button = '1' and sum >= 10) then sum <= sum - 10; end if; end if; end process; process(clk) begin if (rst = '1') then coffee_out <= '0'; elsif (clk'event and clk = '1') then if (coffee_button = '1' and sum >= 30) then coffee_out <= '1'; else coffee_out <= '0'; end if; end if; end process; process(clk) begin if (rst = '1') then tea_out <= '0'; elsif (clk'event and clk = '1') then if (tea_button = '1' and sum >= 15) then tea_out <= '1'; else tea_out <= '0'; end if; end if; end process; process(clk) begin if (rst = '1') then orange_out <= '0'; elsif (clk'event and clk = '1') then if (orange_button = '1' and sum >= 10) then orange_out <= '1'; else 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;