Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use ieee.std_logic_arith.all;
  4. use ieee.std_logic_unsigned.all;
  5.  
  6. entity sekundnik is
  7. Port(
  8. Clk : in std_logic; --:='0';
  9. Reset : in std_logic; --:='0';
  10. --Enable: out Std_logic_vector (2 downto 0);
  11. wyswietlacz : out STD_LOGIC_VECTOR(0 to 6));
  12. end sekundnik;
  13.  
  14. architecture arch_sekundnik of sekundnik is
  15.  
  16. component hex7seg
  17. PORT ( hex : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
  18. display : OUT STD_LOGIC_VECTOR(0 TO 6));
  19. end component;
  20.  
  21. signal ans: STD_LOGIC_VECTOR(3 downto 0);
  22.  
  23. Signal Segundo : integer range 0 to 50000000 := 0;
  24. Signal Cont : integer range 0 to 9 := 0;
  25.  
  26. begin
  27. Process(Clk, Reset, Segundo, Cont)
  28. begin
  29. if (Reset = '1') then
  30. Segundo <= 0;
  31. Cont <= 0;
  32.  
  33. elsif (Clk'event and Clk = '1') then
  34. Segundo <= Segundo + 1;
  35. if Segundo = 50000000 then
  36. Cont <= Cont+1;
  37. case Cont is
  38. when 0 => ans <= "0000";
  39. when 1 => ans <= "0001";
  40. when 2 => ans <= "0010";
  41. when 3 => ans <= "0011";
  42. when 4 => ans <= "0100";
  43. when 5 => ans <= "0101";
  44. when 6 => ans <= "0110";
  45. when 7 => ans <= "0111";
  46. when 8 => ans <= "1000";
  47. when 9 => ans <= "1001";
  48. when others => ans <="1111";
  49. end Case;
  50.  
  51. if (Cont = 9) then
  52. Cont<=0;
  53. Segundo<=0;
  54. end if;
  55. end if;
  56. end if;
  57.  
  58. gate: hex7seg port map (ans,wyswietlacz);
  59.  
  60. end process;
  61. end arch_sekundnik;
  62.  
  63. LIBRARY ieee;
  64. USE ieee.std_logic_1164.all;
  65.  
  66. ENTITY hex7seg IS
  67. PORT ( hex : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
  68. display : OUT STD_LOGIC_VECTOR(0 TO 6));
  69. END hex7seg;
  70.  
  71. ARCHITECTURE Behavior OF hex7seg IS
  72. BEGIN
  73. --
  74. -- 0
  75. -- ---
  76. -- | |
  77. -- 5| |1
  78. -- | 6 |
  79. -- ---
  80. -- | |
  81. -- 4| |2
  82. -- | |
  83. -- ---
  84. -- 3
  85. --
  86. PROCESS (hex)
  87. BEGIN
  88. CASE hex IS
  89. WHEN "0000" => display <= "0000001";
  90. WHEN "0001" => display <= "1001111";
  91. WHEN "0010" => display <= "0010010";
  92. WHEN "0011" => display <= "0000110";
  93. WHEN "0100" => display <= "1001100";
  94. WHEN "0101" => display <= "0100100";
  95. WHEN "0110" => display <= "1100000";
  96. WHEN "0111" => display <= "0001111";
  97. WHEN "1000" => display <= "0000000";
  98. WHEN "1001" => display <= "0001100";
  99. WHEN "1010" => display <= "0001000";
  100. WHEN "1011" => display <= "1100000";
  101. WHEN "1100" => display <= "0110001";
  102. WHEN "1101" => display <= "1000010";
  103. WHEN "1110" => display <= "0110000";
  104. WHEN OTHERS => display <= "0111000";
  105. END CASE;
  106. END PROCESS;
  107. END Behavior;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement