---------------------------------------------------------------------------- ---------------------------------------------------------------------------- -- The Marienbad Game -- EE 552 Project -- Group Members: Koziar, Kory -- McDermott, Ashley -- Stangeland, Duane -- -- File : Buttons.vhd ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- -- Buttons.vhd is used to debounce the signal coming in from the altera -- board push buttons, PB1 and PB2. This is accomplished by looking for -- the push button signals to be low, the push buttons are normally high. -- Once that has been detected then a counter is used to delay 1ms and then -- a signal is latched to 1. ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- library ieee; use ieee.std_logic_1164.ALL; use ieee.std_logic_ARITH.all; use ieee.std_logic_unsigned.all; ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- -- The entity buttons is an interface between the altera board push buttons -- and the rest of the VHDL code. It has four inputs and two outputs -- described below. ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- entity Buttons is port( signal Clock : in std_logic; -- System clock signal Power_On : in std_logic; -- Reset signal signal PB1 : in std_logic; -- Push button 1 signal PB2 : in std_logic; -- Push button 2 signal Reset_Ready : out std_logic; -- Reset latched signal Computer : out std_logic -- Computer/player game ); end Buttons; architecture behavior of Buttons is signal PB1_Latch : std_logic; -- Push button 1 latched signal signal PB2_Latch : std_logic; -- Push button 2 latched signal signal Counter : integer range 0 to 25175; -- Time delay counter begin ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- -- PUSH_BUTTON process is used to debounce the singals coming in from the -- altera board. This is accomplished by looking for the change in the -- status of the push buttons. If a button is pressed then a counter is -- used to delay the assignment of a latched signal. ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- PUSH_BUTTON: process(Clock) begin if (Clock = '1' and Clock'event) then -- If 0 then reset to initial values if (Power_On = '0') then Reset_Ready <= '0'; PB1_Latch <= '0'; Computer <= '0'; PB2_Latch <= '0'; Counter <= 0; else -- Check for push button 1 pressed if ( PB1 = '0' ) then PB1_Latch <= '1'; elsif (PB1_Latch = '1') then -- Debounce the signal if ( counter < 25175 ) then counter <= ( counter + 1 ); -- Set the reset flag else Reset_Ready <= '1'; end if; -- Check for push button 2 pressed elsif ( PB2 = '0' ) then PB2_Latch <= '1'; elsif (PB2_Latch = '1') then -- Debounce the signal if ( counter < 25175 ) then counter <= ( counter + 1 ); -- Set game to computer vs. player mode else Computer <= '1'; end if; end if; end if; end if; end process PUSH_BUTTON; end behavior;