Facebook
From Juan Pantin, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 46
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  4.  
  5. entity Musica is
  6.     Port ( clk : in  STD_LOGIC;
  7.            a : in  STD_LOGIC;
  8.            altavoz : inout  STD_LOGIC);
  9. end Musica;
  10.  
  11. architecture musica_arch of Musica is
  12.  
  13. signal cont : std_logic_vector (16 downto 0);
  14. constant cont_max: std_logic_vector :="11011101111100100";  -- frecuencia de LA
  15.  
  16. begin
  17.         process (clk)
  18.                 begin
  19.                 if clk'event and clk= '1' then
  20.                         cont <= cont+1;
  21.                         if cont= cont_max then
  22.                                 cont <="00000000000000000";
  23.                         end if;
  24.                 end if;
  25.         end process;
  26.        
  27.         process (altavoz)
  28.                 begin
  29.                 if a= '1' then
  30.                         altavoz <= cont (16);
  31.                 else
  32.                         altavoz <= '0';
  33.                 end if;
  34.         end process;
  35.  
  36. end musica_arch;