Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3.  
  4. entity hex7seg is
  5. port (
  6. hex : integer range 0 to 15;
  7. display : out STD_LOGIC_VECTOR(0 to 6)
  8. );
  9. end hex7seg;
  10.  
  11. architecture behhex7seg of hex7seg is
  12. begin
  13. process (hex)
  14. begin
  15. case hex is
  16. WHEN 0 => display <= "0000001";
  17. WHEN 1 => display <= "1001111";
  18. WHEN 2 => display <= "0010010";
  19. WHEN 3 => display <= "0000110";
  20. WHEN 4 => display <= "1001100";
  21. WHEN 5 => display <= "0100100";
  22. WHEN 6 => display <= "0100000";
  23. WHEN 7 => display <= "0001111";
  24. WHEN 8 => display <= "0000000";
  25. WHEN OTHERS => display <= "0000100";
  26. end case;
  27. end process;
  28. end behhex7seg;
  29.  
  30. library ieee;
  31. use ieee.std_logic_1164.all;
  32.  
  33. entity licznik is
  34. port(
  35. CLK : in std_logic;
  36. HEX0 : out std_logic_vector(0 to 6)
  37. );
  38. end licznik;
  39.  
  40. architecture behlicznik of licznik is
  41.  
  42. component hex7seg is
  43. port(
  44. hex : integer range 0 to 15;
  45. display: out std_logic_vector(0 to 6)
  46. );
  47. end component;
  48.  
  49. constant countLimit : integer := 50000000;
  50. signal currentCount : integer range 0 to 214748364 := 0;
  51. signal digit : integer range 0 to 15 := 0;
  52. signal digit2 : integer range 0 to 15 := 0;
  53. signal HEXTMP : std_logic_vector (0 to 6);
  54. signal HEXTMP2 : std_logic_vector (0 to 6);
  55.  
  56. begin
  57. SEG0 : hex7seg port map(hex=>digit, display=>HEXTMP);
  58. SEG1 : hex7seg port map(hex=>digit2, display=>HEXTMP);
  59.  
  60. process1 : process(CLK)
  61. begin
  62. if(CLK'event and CLK = '0')
  63. then currentCount <= currentCount + 1;
  64. end if;
  65.  
  66. if (currentCount >= countLimit) then
  67. if(digit <9) then
  68. digit <= digit +1;
  69. else
  70. digit<=0;
  71. if (digi2 < 5) then
  72.  
  73. end if;
  74. currentCount <= 0;
  75. end if;
  76. end process;
  77.  
  78. process2: process(digit)
  79. begin
  80. HEX0 <= HEXTMP;
  81. end process;
  82.  
  83. process3: process(digit)
  84. begin
  85. HEX1 <= HEXTMP2;
  86. end process;
  87. end behlicznik;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement