Guest User

Untitled

a guest
May 20th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_unsigned.all;
  4.  
  5. entity counter is
  6. port (
  7. A :out std_logic; -- Output impulse
  8. Di :in std_logic_vector (10 downto 0); -- Input time delta
  9. clk :in std_logic; -- Input clock
  10. reset :in std_logic -- Input reset
  11. );
  12. end entity;
  13.  
  14. architecture counter_architecture of counter is
  15. signal count :INTEGER := 0; -- counter
  16. begin
  17. process (clk, reset) begin
  18. if (reset = '1') then
  19. count <= 0; -- reset
  20. elsif (rising_edge(clk)) then
  21. if (count < Di) then
  22. if (count < 100) then -- sound for 1s
  23. A <= '1'; -- sound
  24. else
  25. A <= '0'; -- no sound
  26. end if;
  27. count <= count + 1; -- increment count
  28. else
  29. count <= 0; -- start over
  30. end if;
  31. end if;
  32. end process;
  33. end architecture;
Add Comment
Please, Sign In to add comment