-- -- Beep.vhd -- ----------------------- -- A 30Hz beep with trigger signal timed for a 60Hz clock -- Beep duration 0.10s --coding by --Chris Blasko, Kevin Lister, Tyler Brandon --This will produce a 30Hz square wave, which will need --amplification and probably an isolation capacitor. -- --Total logic cells used: 102/1152 ( 8%) -- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity beep is port(v_sync : in std_logic; collision : in std_logic; --reset : in std_logic; sound : buffer std_logic); end beep; architecture behavioral of beep is begin counter :process(v_sync, collision) variable count : integer; variable done : std_logic; begin if rising_edge(v_sync) then --Note: v_sync acts like a 60 Hz clock --if reset = '0' then --synchronous reset -- count := 0; -- done := '1'; --elsif if collision = '0' and done = '1' then --If there is NO collision and the sound has --run its 0.10 second duration sound <='0'; --make all quiet (no noise) else --Collison detected (collision = 1) OR we haven't finished the beep (done = 0). done := '0'; --Let the program know we are producing sound count := count + 1; if count < 7 then --produce sound for 0.10 seconds (6 / 60Hz) --Alternate between on and off (produces a 30Hz square wave) if sound = '1' then sound <= '0'; else sound <= '1'; end if; else --after 0.10 seconds done := '1'; --Tell the program we are done producing sound count := 0; --Reset the counter to zero end if; end if; -- end if end if;--end if rising_edge( v_sync ) end process counter; end behavioral;