crsandu

dediu_1

Feb 28th, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.STD_LOGIC_ARITH.ALL; -- pentru operatii aritmetice
  4. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  5.  
  6. entity Counter is
  7. PORT(
  8. CLK: IN std_logic;
  9. CE: IN std_logic;
  10. R_OUT: OUT std_logic_vector(15 downto 0));
  11. end Counter;
  12.  
  13. architecture Behavioral of Counter is
  14. begin
  15. NUMARATOR: process(CLK, CE)
  16. variable valoare: std_logic_vector(15 downto 0) := (others => '0'); -- facem tot numarul 0
  17. begin
  18. IF(CE = '1') THEN
  19. IF(RISING_EDGE(CLK)) THEN
  20. IF(valoare = x"FFFF") THEN
  21. valoare := (others=>'0');
  22. ELSE
  23. valoare := valoare + x"0001";
  24. END IF;
  25. END IF;
  26. END IF;
  27.  
  28. R_OUT <= valoare; -- punem valoarea pe iesire
  29. end process NUMARATOR;
  30. end Behavioral;
Add Comment
Please, Sign In to add comment