Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. --------------------------------------------------------------------------------
- 2. -- Company:
- 3. -- Engineer:
- 4. --
- 5. -- Create Date: 11:07:08 12/24/2018
- 6. -- Design Name:
- 7. -- Module Name: C:/Users/Amato/Desktop/universita/Tecnologie digitali/Irrigatore/first_irrigator_test.vhd
- 8. -- Project Name: Irrigatore
- 9. -- Target Device:
- 10. -- Tool versions:
- 11. -- Description:
- 12. --
- 13. -- VHDL Test Bench Created by ISE for module: irrigatore
- 14. --
- 15. -- Dependencies:
- 16. --
- 17. -- Revision:
- 18. -- Revision 0.01 - File Created
- 19. -- Additional Comments:
- 20. --
- 21. -- Notes:
- 22. -- This testbench has been automatically generated using types std_logic and
- 23. -- std_logic_vector for the ports of the unit under test. Xilinx recommends
- 24. -- that these types always be used for the top-level I/O of a design in order
- 25. -- to guarantee that the testbench will bind correctly to the post-implementation
- 26. -- simulation model.
- 27. --------------------------------------------------------------------------------
- 28. LIBRARY ieee;
- 29. USE ieee.std_logic_1164.ALL;
- 30. USE ieee.std_logic_arith.ALL;
- 31.
- 32. -- Uncomment the following library declaration if using
- 33. -- arithmetic functions with Signed or Unsigned values
- 34. --USE ieee.numeric_std.ALL;
- 35.
- 36. ENTITY first_irrigator_test IS
- 37. END first_irrigator_test;
- 38.
- 39. ARCHITECTURE behavior OF first_irrigator_test IS
- 40.
- 41. -- Component Declaration for the Unit Under Test (UUT)
- 42.
- 43. COMPONENT irrigatore
- 44. PORT(
- 45. rst : IN std_logic;
- 46. clk : IN std_logic;
- 47. anomaly : IN std_logic;
- 48. start_stop : IN std_logic;
- 49. timer : IN std_logic_vector(5 downto 0);
- 50. rot_frequency : IN std_logic;
- 51. water : OUT std_logic;
- 52. rotation : OUT std_logic;
- 53. debug_time : OUT std_logic_vector(5 downto 0);
- 54. debug_state : OUT std_logic_vector(2 downto 0)
- 55. );
- 56. END COMPONENT;
- 57.
- 58.
- 59. --Inputs
- 60. signal rst : std_logic := '0';
- 61. signal clk : std_logic := '0';
- 62. signal anomaly : std_logic := '0';
- 63. signal start_stop : std_logic := '0';
- 64. signal timer : std_logic_vector(5 downto 0) := (others => '0');
- 65. signal rot_frequency : std_logic := '0';
- 66.
- 67. --Outputs
- 68. signal water : std_logic;
- 69. signal rotation : std_logic;
- 70. signal debug_time : std_logic_vector(5 downto 0);
- 71. signal debug_state : std_logic_vector(2 downto 0);
- 72.
- 73. -- Clock period definitions
- 74. constant clk_period : time := 10 ns;
- 75.
- 76. BEGIN
- 77.
- 78. -- Instantiate the Unit Under Test (UUT)
- 79. uut: irrigatore PORT MAP (
- 80. rst => rst,
- 81. clk => clk,
- 82. anomaly => anomaly,
- 83. start_stop => start_stop,
- 84. timer => timer,
- 85. rot_frequency => rot_frequency,
- 86. water => water,
- 87. rotation => rotation,
- 88. debug_time => debug_time,
- 89. debug_state => debug_state
- 90. );
- 91.
- 92. -- Clock process definitions
- 93. clk_process :process
- 94. begin
- 95. clk <= '0';
- 96. wait for clk_period/2;
- 97. clk <= '1';
- 98. wait for clk_period/2;
- 99. end process;
- 100.
- 101.
- 102. -- Stimulus process
- 103. stim_proc: process
- 104. variable vet,vet1 : std_logic_vector(2 downto 0):=(others =>'0');
- 105. begin
- 106. -- hold reset state for 100 ns.
- 107. rst<='1';
- 108. wait for clk_period/2*10;
- 109. rst<='0';
- 110. wait for clk_period/2*10;
- 111.
- 112. -- insert stimulus here
- 113. timer <= "000011"; --fin quando rimango in spento il timer può essere cambiato
- 114. -- RIMANGO IN OFF
- 115. for i in 7 downto 4 loop
- 116. vet:=conv_std_logic_vector(i,3); --mi permette di gestire tutti i casi in cui l'anomalia è 1
- 117. anomaly<=vet(2);
- 118. start_stop<=vet(1);
- 119. rot_frequency<=vet(0);
- 120. wait for clk_period/2*2;
- 121. end loop;
- 122. -- RIMANGO IN OFF
- 123. for i in 1 downto 0 loop
- 124. vet:=conv_std_logic_vector(i,3); --mi permette di gestire i casi in cui l'anomalia e lo start_stop stanno a zero
- 125. anomaly<=vet(2);
- 126. start_stop<=vet(1);
- 127. rot_frequency<=vet(0);
- 128. wait for clk_period/2*2;
- 129. end loop;
- 130. -- VADO IN IRRIGAZIONE LENTA
- 131. anomaly<='0';
- 132. start_stop<='1';
- 133. timer<="000010"; --prima del passaggio al nuovo stato inserisco un altro tempo che quindi diventa il nuovo tempo di irrigazione
- 134. rot_frequency<='0';
- 135. wait for clk_period/2;
- 136.
- 137. -- RIMANGO IN IRRIGAZIONE LENTA
- 138. anomaly<='0';
- 139. start_stop<='0';
- 140. rot_frequency<='0';
- 141. timer <= "000111";--questo tempo non determina una variazione del tempo di irrigazione
- 142. wait for clk_period/2*3;
- 143.
- 144. --VADO DA IRRIGAZIONE LENTA A SOSPENSIONE LENTA 2 VOLTE
- 145. for i in 3 downto 2 loop
- 146. --VADO
- 147. vet:=conv_std_logic_vector(i,3);
- 148. anomaly<=vet(2);
- 149. start_stop<=vet(1);
- 150. rot_frequency<=vet(0);
- 151. wait for clk_period/2;
- 152. -- RIMANGO IN SOSPENSIONE LENTA
- 153. for j in 0 to 1 loop
- 154. vet1:=conv_std_logic_vector(j,3);
- 155. anomaly<=vet1(2);
- 156. start_stop<=vet1(1);
- 157. rot_frequency<=vet1(0);
- 158. wait for clk_period/2*2;
- 159. end loop;
- 160. -- RITORNO
- 161. anomaly<=vet(2);
- 162. start_stop<=vet(1);
- 163. rot_frequency<=vet(0);
- 164. wait for clk_period/2*3;
- 165. end loop;
- 166.
- 167. --RILEVO UN ANOMALIA IN IRRIGAZIONE LENTA(TUTTE LE COMBINAZIONI)
- 168. for i in 0 to 3 loop
- 169. -- SI SPEGNE LA MACCHINA
- 170. vet:=conv_std_logic_vector(i,3);
- 171. anomaly<='1';
- 172. start_stop<=vet(1);
- 173. rot_frequency<=vet(0);
- 174. wait for clk_period/2*2;
- 175. -- RITORNO AD IRRIGAZIONE LENTA
- 176. anomaly<='0';
- 177. start_stop<='1';
- 178. rot_frequency<='0';
- 179. wait for clk_period/2*2;
- 180. end loop;
- 181.
- 182. -- VADO DA IRRIGAZIONE LENTA A IRRIGAZIONE VELOCE
- 183. anomaly<='0';
- 184. start_stop<='0';
- 185. rot_frequency<='1';
- 186. timer <= "001111";
- 187. wait for clk_period/2*2;
- 188. -- RIMANGO IN IRRIGAZIONE VELOCE
- 189. anomaly<='0';
- 190. start_stop<='0';
- 191. timer<="000011";
- 192. rot_frequency<='1';
- 193. wait for clk_period/2*2;
- 194.
- 195. --VADO DA IRRIGAZIONE VELOCE A SOSPENSIONE VELOCE 2 VOLTE
- 196. for i in 2 to 3 loop
- 197. --VADO
- 198. vet:=conv_std_logic_vector(i,3);
- 199. anomaly<=vet(2);
- 200. start_stop<=vet(1);
- 201. rot_frequency<=vet(0);
- 202. wait for clk_period/2;
- 203. -- RIMANGO IN SOSPENSIONE VELOCE
- 204. for j in 0 to 1 loop
- 205. vet1:=conv_std_logic_vector(j,3);
- 206. anomaly<=vet1(2);
- 207. start_stop<=vet1(1);
- 208. rot_frequency<=vet1(0);
- 209. wait for clk_period/2*2;
- 210. end loop;
- 211. -- RITORNO
- 212. anomaly<=vet(2);
- 213. start_stop<=vet(1);
- 214. rot_frequency<=vet(0);
- 215. wait for clk_period/2*3;
- 216. end loop;
- 217.
- 218.
- 219. --RILEVO UN ANOMALIA IN IRRIGAZIONE VELOCE(TUTTE LE COMBINAZIONI)
- 220. for i in 0 to 3 loop
- 221. -- SI SPEGNE LA MACCHINA
- 222. anomaly<='1';
- 223. start_stop<=vet(1);
- 224. rot_frequency<=vet(0);
- 225. wait for clk_period/2*2;
- 226. -- RITORNO AD IRRIGAZIONE VELOCE
- 227. anomaly<='0';
- 228. start_stop<='1';
- 229. rot_frequency<='1';
- 230. wait for clk_period/2*2;
- 231. end loop;
- 232. -- VADO DA IRRIGAZIONE VELOCE A IRRIGAZIONE LENTA DOVE FINISCO DI IRRIGARE
- 233. anomaly<='0';
- 234. start_stop<='0';
- 235. rot_frequency<='0';
- 236.
- 237.
- 238. ---- All'inizio abbiamo utilizzato clk_period/2*n, in quanto avendo implementato la macchina con un'automa di Mealy e
- 239. ---- avendo utilizzato un pulsante impulsivo, volevamo cercare di sincronizzare ogni singola variazione di ingresso
- 240. ---- con la sua rispettiva uscita.
- 241. wait;
- 242. end process;
- 243. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement