---------------------------------------------------------------------------------- -- Engineer: Ryan Stamper and Patrick Murphy -- -- Create Date: 03/01/2018 09:33:21 AM -- Module Name: buzzerControl -- Project Name: Model of Universal Off Switch -- Target Devices: Basys 3 FPGA -- Tool Versions: Vivado 2014.2 -- Description: emits sounds that indicate to the user the device is going to turn off all the connected devices. -- -- Dependencies: The IEEE library -- -- Revision: 1 -- Additional Comments: -- ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; -- The module requires a button input signal (btn) to know when to start. -- It also needs a clock signal running at 100 MHz. The basys 3 board we used outputs this by default. -- Changing the clock frequency will change the pitch of the sound as well as how long the sound is output after the button is pressed. entity buzzerControl is Port ( clk : in STD_LOGIC; btn : in STD_LOGIC; buzzer : out STD_LOGIC); end buzzerControl; architecture Behavioral of buzzerControl is -- Signals signal tempBuzz : STD_LOGIC := '0'; begin -- This process models the timed behavior of the buzzer. BuzzerControl: process (clk, btn) -- This is used to keep track of how much time has passed. variable clkCount : integer := 100000001; begin -- Start tone sequence when button is released if (btn = '1') then clkCount := 0; end if; -- Run tone sequence at clock if (rising_edge(clk)) then -- First 1/2 second output A at 440Hz if (clkCount < 50000000) then if ((clkCount mod 227272) = 0) then tempBuzz <= not tempBuzz; end if; -- Increment the clock count clkCount := clkCount + 1; -- Other 1/2 of second output F at 349.2Hz elsif ((clkCount >= 50000000) and (clkCount < 100000000)) then if ((clkCount mod 286369) = 0) then tempBuzz <= not tempBuzz; end if; -- Increment clock count clkCount := clkCount + 1 ; -- Otherwise output nothing else tempBuzz <= '0'; -- stop incrementing the clock count end if; end if; end process BuzzerControl; -- Assign our buzzer signal to the output buzzer <= tempBuzz; end Behavioral;