-------------------------------------------------------------------------------- -- Author : Unknown Talent -- -- Course : ENSC151-2 (99-1) -- -- Description: VHDL for FINAL PROJECT. This program is used to output an -- -- alarm sound to the audio port and cause one of the LED's on the board to be-- -- lit when any button is pressed or movement is detected by the motion -- -- sensor. It also sends signals to the HC12 to tell it which buttons are -- -- being pressed. -- -------------------------------------------------------------------------------- LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all; ENTITY final IS PORT ( clock : IN STD_LOGIC; -- 100Mhz Clck on FPGA pa : IN STD_LOGIC_VECTOR(2 DOWNTO 0); -- Port A IN lcde : OUT STD_LOGIC; -- LCD Enable lcdrw : OUT STD_LOGIC; -- LCD Read Write lcdrs : OUT STD_LOGIC; -- LCD Reset pb : IN STD_LOGIC_VECTOR(7 DOWNTO 0); -- Port B IN lcd : OUT STD_LOGIC_VECTOR(7 DOWNTO 0); -- LCD OUT buttons : IN STD_LOGIC_VECTOR(3 DOWNTO 0); -- 4 Buttons on FPGA led : OUT STD_LOGIC; -- LED on FPGA paout : OUT STD_LOGIC_VECTOR(3 DOWNTO 0); -- Port A OUT (push button result) keypad : IN STD_LOGIC_VECTOR(5 DOWNTO 0); -- Our Custom Made Keypad Input motion : IN STD_LOGIC; -- Input Pin for Motion Detector lh, rh : OUT STD_LOGIC; -- Left and right stereo out siren : IN STD_LOGIC; -- Input from Port T to activate siren irq : OUT STD_LOGIC; -- IRQ status xirq : OUT STD_LOGIC -- XIRQ status ); END final; ARCHITECTURE foo OF final IS signal notetime : STD_LOGIC_VECTOR (12 DOWNTO 0); BEGIN lcd <= pb; --PortB connects to LCD data bus. lcdrs <= pa(0); --LCD register select. lcdrw <= pa(1); --LCD read/write. lcde <= pa(2); --LCD enable. xirq <= '1'; --No interrupt state sound:process(clock) variable count : integer range 0 to 38; begin if (clock'event and clock='1') then if siren = '1' then if (notetime < "0110000110101" ) then if (count = 19) then lh <= '1'; rh <= '1'; elsif (count = 38) then lh <= '0'; rh <= '0'; count := 1; end if; elsif (notetime >= "0110000110101") then if (count = 12) then lh <= '1'; rh <= '1'; elsif (count = 24) then lh <= '0'; rh <= '0'; count := 1; end if; elsif (notetime = "1100001101010" ) then notetime <= "0000000000000"; end if; notetime <= notetime + 1; count := count + 1; end if; end if; end process sound; interrupt:process(keypad,buttons,motion) begin if (not(buttons = "1111") or not(keypad = "000000") or (motion = '1')) then irq <= '0'; led <= '0'; else irq <= '1'; led <= '1'; end if; if keypad(0) = '1' then paout <= "0001"; elsif keypad(1) = '1' then paout <= "0010"; elsif keypad(2) = '1' then paout <= "0011"; elsif keypad(3) = '1' then paout <= "0100"; elsif keypad(4) = '1' then paout <= "0101"; elsif keypad(5) = '1' then paout <= "0110"; elsif buttons(3) = '0' then paout <= "1100"; elsif buttons(2) = '0' then paout <= "1101"; elsif buttons(1) = '0' then paout <= "1110"; elsif buttons(0) = '0' then paout <= "1111"; elsif motion = '1' then paout <= "1011"; end if; end process interrupt; END foo;