Advertisement
Guest User

Untitled

a guest
Mar 8th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.83 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.STD_LOGIC_ARITH.ALL;
  4. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  5.  
  6. entity clock_divider is
  7.     port
  8.     (
  9.         mclk: in std_logic; -- master clock, set to pin V10
  10.         switch: out std_logic_vector(1 downto 0) -- output of divided clock
  11.     );
  12. end clock_divider;
  13.  
  14. architecture Behavioral of clock_divider is
  15.     -- change this if you need to increase the size of the counter vector
  16.     signal counter : std_logic_vector(10 downto 0) := (others => '0');
  17. begin
  18.  
  19.     process (mclk)  -- using the system clock
  20.     begin
  21.         if mclk = '1' and mclk'Event then  
  22.             counter <= counter +1;
  23.         end if;    
  24.     end process;
  25.  
  26.     -- if you want a longer delay, use a higher set of numbers here.
  27.     -- if you are trying to simulation, use a lower number (like 1 downto 0)
  28.     switch <= counter(10 downto 9);
  29.  
  30. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement