Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.53 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    17:49:56 03/21/2019
  6. -- Design Name:
  7. -- Module Name:    licznik - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.STD_LOGIC_ARITH.ALL;
  23. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  24.  
  25. ---- Uncomment the following library declaration if instantiating
  26. ---- any Xilinx primitives in this code.
  27. --library UNISIM;
  28. --use UNISIM.VComponents.all;
  29.  
  30. entity licznik is
  31. Port     ( clk_i : in std_logic;
  32.            rst_i : in std_logic;
  33.            led_o : out std_logic);
  34. end licznik;
  35.  
  36. architecture Behavioral of licznik is
  37. constant n : integer := 3;
  38. -- constant n : integer := 50000000;
  39. signal licznik : integer range 0 to n - 1 := 0;
  40. signal clk_o: std_logic := '0';
  41.  
  42. begin
  43.     process (rst_i, clk_i)
  44.         begin
  45.         if (rst_i = '1') then
  46.             licznik <= 0;
  47.             clk_o <= '0';
  48.         elsif (rising_edge(clk_i)) then
  49.             licznik <= licznik + 1;
  50.             if (licznik = (n / 2)) then
  51.                 clk_o <= '1';
  52.             elsif (licznik = n-1) then
  53.                 clk_o <= '0';
  54.                 licznik <= 0;
  55.             end if;
  56.         end if;
  57.     end process;
  58. led_o <= clk_o;
  59. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement