Advertisement
Guest User

licznik

a guest
Jan 22nd, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.std_logic_unsigned.all;
  4.  
  5. entity licznik is
  6. PORT(DIR: in STD_LOGIC;
  7. clk: in STD_LOGIC;
  8. carry: out STD_LOGIC;
  9. Q: buffer STD_LOGIC_VECTOR(3 downto 0));
  10. end licznik;
  11. architecture licz of licznik is
  12. begin
  13.  
  14. process(clk)
  15.  
  16. begin
  17.  
  18. if rising_edge (clk) then
  19. carry <= '0';
  20. if DIR='0'
  21. then Q<=Q+1;
  22. if Q = "1001" then
  23. Q <= "0000";
  24. carry <= '1';
  25.  
  26. end if;
  27. else
  28. Q<=Q-1;
  29. if Q = "0000" then
  30. Q <= "1001";
  31. carry <= '1';
  32. end if;
  33. end if;
  34. end if;
  35. end process;
  36. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement