Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jan 21st, 2012  |  syntax: VHDL  |  size: 3.65 KB  |  hits: 145  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //----------------------Dzielnik częstotliwości--------------------------//
  2. library ieee;
  3. use ieee.std_logic_1164.all;
  4. entity dzielnik is
  5. port(
  6. clk in st/d_logic;
  7. c1,c2: out std_logic;
  8. );
  9. end dzielnik;
  10. architecture behavioral of dzielnik is
  11. begin
  12. D0: process (clk) --Na wyjściu dla guzika chemy osiągnąć
  13. mniejszą częstotliwość,1MHz
  14. variable i: integer := 0;
  15. begin
  16. if clk'event and clk='1' then --kolejny obieg zegara
  17. i := i + 1;
  18. if i = 25175 then
  19. c1 <= '0';
  20. i := 0;
  21. else if i > 12587.5
  22. c1 <= '1';
  23. else
  24. c1 <= '0';
  25. end if;
  26. end if;
  27. end process;
  28.  
  29. D1: process (clk) --Na wyjściu dla układu generującego
  30. chemy osiągnąć mniejszą częstotliwość,3Hz
  31. variable i: integer := 0;
  32. begin
  33. if clk'event and clk='1' then --kolejny obieg zegara
  34. i := i + 1;
  35. if i = 8391666 then
  36. c2 <= '0';
  37. i := 0;
  38. else if i > 4195833
  39. c2 <= '1';
  40. else
  41. c2 <= '0';
  42. end if;
  43. end if;
  44. end process;
  45. end behavioral;
  46. //-----------------------Debauncer dla guzika eliminujący drganie styków-----------------//
  47. library ieee;
  48. use ieee.std_logic_1164.all;
  49. entity debouncer is
  50. port (
  51. clk: in std_logic;
  52. przycisk: in std_logic;
  53. przycisk_deb: out std_logic
  54. );
  55. end debouncer;
  56. architecture behavioral of debouncer is
  57. signal shift: std_logic_vector(3 downto 0);
  58. signal stan: std_logic := '0';
  59. begin
  60. debounce : process(clk, shift, stan)
  61. begin
  62. if rising_edge(clk) then
  63. shift(2 downto 0) <= shift(3 downto 1);
  64. shift(3) <= przycisk;
  65. case shift is
  66. when "0000" => stan <= '0';
  67. when "1111" => stan <= '1';
  68. when others => stan <= stan;
  69. end case;
  70. end if;
  71. przycisk_deb <= state;
  72. end process;
  73. end behavioral;
  74. //---------------Transkoder kodu binarnego na wyświetlacz siedmiosegmentowy----------------//
  75. library ieee;
  76. use ieee.std_logic_1164.all;
  77. entity transkoder is
  78. port(
  79. wej: in std_logic_vector(2 downto 0);
  80. wyj: out std_logic_vector(6 downto 0);
  81. );
  82. end transkoder;
  83. architecture behavioral of transkoder is
  84. begin
  85. case wej is
  86. when "001" => wyj <= "1001111"; --1
  87. when "010" => wyj <= "0010010"; --2
  88. when "011" => wyj <= "0000110"; --3
  89. when "100" => wyj <= "1001100"; --4
  90. when "101" => wyj <= "0100100"; --5
  91. when "110" => wyj <= "0100100"; --6
  92. end case;
  93. end behavioral;
  94. //----------------Przerzutnik typu T dla guzika(blokada cyfry na wyświetlaczu)-------------//
  95. library ieee;
  96. use ieee.std_logic_1164.all;
  97. entity przerzutnik_t is
  98. port(
  99. clk: in std_logic;
  100. t: in std_logic;
  101. q: out std_logic;
  102. );
  103. end przerzutnik_t
  104. architecture behavioral of przerzutnik_t is
  105. begin
  106. signal q_teraz: std_logic;
  107. signal q_nast: std_logic;
  108. P : process(clk)
  109. begin
  110. if clk'event and clk = '1'
  111. q_teraz <= q_nast;
  112. q_nast = q_teraz when t='0' else not(q_teraz);
  113. q <= q_teraz;
  114. end if;
  115. end process;
  116. end behavioral;
  117. //-------------------------------------Licznik modulo 6-----------------------------------//
  118. library ieee;
  119. use ieee.std_logic_1164.all;
  120. entity licznik_mod_6 is
  121. port(
  122. clk: in std_logic;
  123. wyj: out std_logic_vector(2 downto 0);
  124. );
  125. end licznik_mod_6;
  126. architecture behavioral of licznik_mod_6 is
  127. begin
  128. P : process(clk)
  129. variable i: integer := 0;
  130. begin
  131. if clk'event and clk = '1' then
  132. i := i + 1; --liczymy obiegi
  133. if i = 7 then
  134. i := 0;
  135. end if;
  136. case i is when 1 => wyj <= "001";
  137. when 2 => wyj <= "010";
  138. when 3 => wyj <= "011";
  139. when 4 => wyj <= "100";
  140. when 5 => wyj <= "101";
  141. when 6 => wyj <= "110";
  142. end case;
  143. end if;
  144. end process;
  145. end behavioral;
  146. //---------------------------------Zaprzeczenie-----------------------------------------------//
  147. library ieee;
  148. use ieee.std_logic_1164.all;
  149. entity zaprzeczenie is
  150. port(
  151. wej: in std_logic;
  152. wyj: out std_logic;
  153. );
  154. end zaprzeczenie;
  155. architecture behavioral of zaprzeczenie is
  156. begin
  157. wyj <= not(wej);
  158. end behavioral;