Advertisement
Guest User

tak

a guest
Mar 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.all;
  3.  
  4. ENTITY hex7seg IS
  5. PORT ( hex : integer range 0 to 15;
  6. display : OUT STD_LOGIC_VECTOR(0 TO 6));
  7. END hex7seg;
  8.  
  9. ARCHITECTURE Behavior OF hex7seg IS
  10. BEGIN
  11. --
  12. -- 0
  13. -- ---
  14. -- | |
  15. -- 5| |1
  16. -- | 6 |
  17. -- ---
  18. -- | |
  19. -- 4| |2
  20. -- | |
  21. -- ---
  22. -- 3
  23. --
  24. PROCESS (hex)
  25. BEGIN
  26. CASE hex IS
  27. WHEN 0 => display <= "0000001";
  28. WHEN 1 => display <= "1001111";
  29. WHEN 2 => display <= "0010010";
  30. WHEN 3 => display <= "0000110";
  31. WHEN 4 => display <= "1001100";
  32. WHEN 5 => display <= "0100100";
  33. WHEN 6 => display <= "1100000";
  34. WHEN 7 => display <= "0001111";
  35. WHEN 8 => display <= "0000000";
  36. WHEN 9 => display <= "0001100";
  37. WHEN 10 => display <= "0001000";
  38. WHEN 11 => display <= "1100000";
  39. WHEN 12 => display <= "0110001";
  40. WHEN 13 => display <= "1000010";
  41. WHEN 14 => display <= "0110000";
  42. WHEN OTHERS => display <= "0111000";
  43. END CASE;
  44. END PROCESS;
  45. END Behavior;
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66. LIBRARY ieee;
  67. USE ieee.std_logic_1164.all;
  68.  
  69.  
  70. entity licznik is
  71. port(
  72. CLK : in std_logic;
  73. HEX0 : out std_logic_vector (0 to 6));
  74. end licznik;
  75.  
  76. architecture beh of licznik is
  77.  
  78. component hex7seg is
  79. port( hex : integer range 0 to 15;
  80. display : OUT std_logic_vector( 0 to 6 ));
  81. end component;
  82.  
  83. constant countlimit : integer := 500000000;
  84. signal currentCount : integer range 0 to 214748364 :=0;
  85. signal digit : integer range 0 to 15 :=0;
  86. signal HEXTMP : std_logic_vector (0 to 6);
  87.  
  88. begin
  89.  
  90. SEG0 : hex7seg port map(hex=>digit, display=>HEXTMP);
  91.  
  92. process1 : process(CLK)
  93. begin
  94. if(CLK'event and CLK = '1')
  95. then currentCount <= currentCount +1;
  96. end if;
  97.  
  98. if(CurrentCount >= countLimit) then
  99. digit <= digit +1;
  100. CurrentCount <= 0;
  101. end if;
  102.  
  103. end process;
  104.  
  105. process2: process(digit)
  106. begin
  107. HEX0 <= HEXTMP;
  108. end process;
  109.  
  110. end beh;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement