Advertisement
Device-Cheat

Untitled

Jun 29th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3.  
  4. entity ADC8bit is -- nasze pudełko o nazwie ADC8bit
  5. port (
  6. in_clk : in std_logic; -- zegar
  7. rst_n : in std_logic; -- reset
  8. start : in std_logic; -- start
  9. comp_in : in std_logic; -- comparator
  10. data_out : out std_logic_vector (7 downto 0); -- out std_logic_vector -> porty wyjścia
  11. D_out : out std_logic_vector(7 downto 0);
  12. B_hold : out std_logic_vector(7 downto 0);
  13. sample : out std_logic;
  14. hold : out std_logic;
  15. eoc : out std_logic);
  16. end ADC8bit;
  17.  
  18. architecture Behaviorall of ADC8bit is
  19. type state is (reset, state1, state2, state3, state4, state5, state6, state7, state8, state9, state10, state11, state12, state13, state14, state15, state16, state17, state18);
  20. signal pr_state, nx_state : state;
  21. begin
  22.  
  23. -- dolny obwód
  24. seq : process(in_clk)
  25. begin
  26. if rst_n = '0' then -- negowanie
  27. pr_state <= reset;
  28. elsif in_clk='1' then -- pozycja zegara
  29. pr_state <= nx_state;
  30. end if;
  31. end process;
  32.  
  33.  
  34. -- górny obwód
  35. combinational : process (pr_state, start)
  36. begin
  37. case pr_state is
  38. when reset => -- funkcja resetująca
  39. B_hold <= "11111111";
  40. D_out <= "00000000";
  41. data_out <= "00000000";
  42. hold <= '1';
  43. sample <= '0';
  44. eoc <= '0';
  45.  
  46. if start = '1' then
  47. nx_state <= state1;
  48. else
  49. nx_state <= reset;
  50. end if;
  51.  
  52. when state1 => -- próba
  53. B_hold <= "00000000";
  54. hold <= '0';
  55. sample <= '1';
  56. nx_state <= state2;
  57.  
  58. when state2 => -- utrzymanie
  59. B_hold <= "11111111";
  60. D_out <= "00000000";
  61. nx_state <= state3;
  62.  
  63. when state3 => -- resetuj Pierwszy bit
  64. B_hold(7) <= '0';
  65. D_out(7) <= '1';
  66. data_out(7) <= '1';
  67. nx_state <= state4;
  68.  
  69. when state4 => -- sprawdź z comporatora i ustaw Pierwszy bit
  70. if comp_in = '1' then
  71. B_hold(7) <= '0';
  72. D_out(7) <= '1';
  73. data_out(7) <= '1';
  74. else
  75. B_hold(7) <= '1';
  76. D_out(7) <= '0';
  77. data_out(7) <= '0';
  78. end if;
  79. nx_state <= state5;
  80.  
  81. when state5 => -- resetuj Drugi bit
  82. B_hold(6) <= '0';
  83. D_out(6) <= '1';
  84. data_out(6) <= '1';
  85. nx_state <= state6;
  86.  
  87. when state6 => -- sprawdź z comporatora i ustaw Drugi bit
  88. if comp_in = '1' then
  89. B_hold(6) <= '0';
  90. D_out(6) <= '1';
  91. data_out(6) <= '1';
  92. else
  93. B_hold(6) <= '1';
  94. D_out(6) <= '0';
  95. data_out(6) <= '0';
  96. end if;
  97. nx_state <= state7;
  98.  
  99. when state7 => -- resetuj Trzeci bit
  100. B_hold(5) <= '0';
  101. D_out(5) <= '1';
  102. data_out(5) <= '1';
  103. nx_state <= state8;
  104.  
  105. when state8 => -- sprawdz z comporatora i ustaw Trzeci bit
  106. if comp_in = '1' then
  107. B_hold(5) <= '0';
  108. D_out(5) <= '1';
  109. data_out(5) <= '1';
  110. else
  111. B_hold(5) <= '1';
  112. D_out(5) <= '0';
  113. data_out(5) <= '0';
  114. end if;
  115. nx_state <= state9;
  116.  
  117. when state9 => -- resetuj Czwarty bit
  118. B_hold(4) <= '0';
  119. D_out(4) <= '1';
  120. data_out(4) <= '1';
  121. nx_state <= state10;
  122.  
  123. when state10 => -- sprawdz z comporatora i ustaw Czwarty bit
  124. if comp_in = '1' then
  125. B_hold(4) <= '0';
  126. D_out(4) <= '1';
  127. data_out(4) <= '1';
  128. else
  129. B_hold(4) <= '1';
  130. D_out(4) <= '0';
  131. data_out(4) <= '0';
  132. end if;
  133. nx_state <= state11;
  134.  
  135. when state11 => -- resetuj Piąty bit
  136. B_hold(3) <= '0';
  137. D_out(3) <= '1';
  138. data_out(3) <= '1';
  139. nx_state <= state12;
  140.  
  141. when state12 => -- sprawdz z comporatora i ustaw Piąty bit
  142. if comp_in = '1' then
  143. B_hold(3) <= '0';
  144. D_out(3) <= '1';
  145. data_out(3) <= '1';
  146. else
  147. B_hold(3) <= '1';
  148. D_out(3) <= '0';
  149. data_out(3) <= '0';
  150. end if;
  151. nx_state <= state13;
  152.  
  153. when state13 => -- resetuj Szósty bit
  154. B_hold(2) <= '0';
  155. D_out(2) <= '1';
  156. data_out(2) <= '1';
  157. nx_state <= state14;
  158.  
  159. when state14 => -- sprawdz z comporatora i ustaw Szósty bit
  160. if comp_in = '1' then
  161. B_hold(2) <= '0';
  162. D_out(2) <= '1';
  163. data_out(2) <= '1';
  164. else
  165. B_hold(2) <= '1';
  166. D_out(2) <= '0';
  167. data_out(2) <= '0';
  168. end if;
  169. nx_state <= state15;
  170.  
  171. when state15 => -- resetuj Siódmy bit
  172. B_hold(1) <= '0';
  173. D_out(1) <= '1';
  174. data_out(1) <= '1';
  175. nx_state <= state16;
  176.  
  177. when state16 => -- sprawdz z comporatora i ustaw Siódmy bit
  178. if comp_in = '1' then
  179. B_hold(1) <= '0';
  180. D_out(1) <= '1';
  181. data_out(1) <= '1';
  182. else
  183. B_hold(1) <= '1';
  184. D_out(1) <= '0';
  185. data_out(1) <= '0';
  186. end if;
  187. nx_state <= state17;
  188.  
  189. when state17 => -- resetuj Ósmy bit
  190. B_hold(0) <= '0';
  191. D_out(0) <= '1';
  192. data_out(0) <= '1';
  193. nx_state <= state18;
  194.  
  195. when state18 => -- sprawdz z comporatora i ustaw Ósmy bit
  196. if comp_in = '1' then
  197. B_hold(0) <= '0';
  198. D_out(0) <= '1';
  199. data_out(0) <= '1';
  200. else
  201. B_hold(0) <= '1';
  202. D_out(0) <= '0';
  203. data_out(0) <= '0';
  204. end if;
  205. eoc <= '1';
  206. nx_state <= reset;
  207. end case;
  208. end process;
  209. end Behaviorall;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement