Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- VHDL Test Bench Created by ISE for module: irrigatore
- --
- -- Dependencies:
- --
- -- Revision:
- -- Revision 0.01 - File Created
- -- Additional Comments:
- --
- -- Notes:
- -- This testbench has been automatically generated using types std_logic and
- -- std_logic_vector for the ports of the unit under test. Xilinx recommends
- -- that these types always be used for the top-level I/O of a design in order
- -- to guarantee that the testbench will bind correctly to the post-implementation
- -- simulation model.
- --------------------------------------------------------------------------------
- LIBRARY ieee;
- USE ieee.std_logic_1164.ALL;
- USE ieee.std_logic_arith.ALL;
- -- Uncomment the following library declaration if using
- -- arithmetic functions with Signed or Unsigned values
- --USE ieee.numeric_std.ALL;
- ENTITY first_irrigator_test IS
- END first_irrigator_test;
- ARCHITECTURE behavior OF first_irrigator_test IS
- -- Component Declaration for the Unit Under Test (UUT)
- COMPONENT irrigatore
- PORT(
- rst : IN std_logic;
- clk : IN std_logic;
- anomaly : IN std_logic;
- start_stop : IN std_logic;
- timer : IN std_logic_vector(5 downto 0);
- rot_frequency : IN std_logic;
- water : OUT std_logic;
- rotation : OUT std_logic;
- debug_time : OUT std_logic_vector(5 downto 0);
- debug_state : OUT std_logic_vector(2 downto 0)
- );
- END COMPONENT;
- --Inputs
- signal rst : std_logic := '0';
- signal clk : std_logic := '0';
- signal anomaly : std_logic := '0';
- signal start_stop : std_logic := '0';
- signal timer : std_logic_vector(5 downto 0) := (others => '0');
- signal rot_frequency : std_logic := '0';
- --Outputs
- signal water : std_logic;
- signal rotation : std_logic;
- signal debug_time : std_logic_vector(5 downto 0);
- signal debug_state : std_logic_vector(2 downto 0);
- -- Clock period definitions
- constant clk_period : time := 10 ns;
- BEGIN
- -- Instantiate the Unit Under Test (UUT)
- uut: irrigatore PORT MAP (
- rst => rst,
- clk => clk,
- anomaly => anomaly,
- start_stop => start_stop,
- timer => timer,
- rot_frequency => rot_frequency,
- water => water,
- rotation => rotation,
- debug_time => debug_time,
- debug_state => debug_state
- );
- -- Clock process definitions
- clk_process :process
- begin
- clk <= '0';
- wait for clk_period/2;
- clk <= '1';
- wait for clk_period/2;
- end process;
- -- Stimulus process
- stim_proc: process
- variable vet,vet1 : std_logic_vector(2 downto 0):=(others =>'0');
- begin
- -- hold reset state for 100 ns.
- rst<='1';
- wait for clk_period/2*10;
- rst<='0';
- wait for clk_period/2*10;
- -- insert stimulus here
- timer <= "000011"; --fin quando rimango in spento il timer può essere cambiato
- -- RIMANGO IN OFF
- for i in 7 downto 4 loop
- vet:=conv_std_logic_vector(i,3); --mi permette di gestire tutti i casi in cui l'anomalia è 1
- anomaly<=vet(2);
- start_stop<=vet(1);
- rot_frequency<=vet(0);
- wait for clk_period/2*2;
- end loop;
- -- RIMANGO IN OFF
- for i in 1 downto 0 loop
- vet:=conv_std_logic_vector(i,3); --mi permette di gestire i casi in cui l'anomalia e lo start_stop stanno a zero
- anomaly<=vet(2);
- start_stop<=vet(1);
- rot_frequency<=vet(0);
- wait for clk_period/2*2;
- end loop;
- -- VADO IN IRRIGAZIONE LENTA
- anomaly<='0';
- start_stop<='1';
- timer<="000010"; --prima del passaggio al nuovo stato inserisco un altro tempo che quindi diventa il nuovo tempo di irrigazione
- rot_frequency<='0';
- wait for clk_period/2;
- -- RIMANGO IN IRRIGAZIONE LENTA
- anomaly<='0';
- start_stop<='0';
- rot_frequency<='0';
- timer <= "000111";--questo tempo non determina una variazione del tempo di irrigazione
- wait for clk_period/2*3;
- --VADO DA IRRIGAZIONE LENTA A SOSPENSIONE LENTA 2 VOLTE
- for i in 3 downto 2 loop
- --VADO
- vet:=conv_std_logic_vector(i,3);
- anomaly<=vet(2);
- start_stop<=vet(1);
- rot_frequency<=vet(0);
- wait for clk_period/2;
- -- RIMANGO IN SOSPENSIONE LENTA
- for j in 0 to 1 loop
- vet1:=conv_std_logic_vector(j,3);
- anomaly<=vet1(2);
- start_stop<=vet1(1);
- rot_frequency<=vet1(0);
- wait for clk_period/2*2;
- end loop;
- -- RITORNO
- anomaly<=vet(2);
- start_stop<=vet(1);
- rot_frequency<=vet(0);
- wait for clk_period/2*3;
- end loop;
- --RILEVO UN ANOMALIA IN IRRIGAZIONE LENTA(TUTTE LE COMBINAZIONI)
- for i in 0 to 3 loop
- -- SI SPEGNE LA MACCHINA
- vet:=conv_std_logic_vector(i,3);
- anomaly<='1';
- start_stop<=vet(1);
- rot_frequency<=vet(0);
- wait for clk_period/2*2;
- -- RITORNO AD IRRIGAZIONE LENTA
- anomaly<='0';
- start_stop<='1';
- rot_frequency<='0';
- wait for clk_period/2*2;
- end loop;
- -- VADO DA IRRIGAZIONE LENTA A IRRIGAZIONE VELOCE
- anomaly<='0';
- start_stop<='0';
- rot_frequency<='1';
- timer <= "001111";
- wait for clk_period/2*2;
- -- RIMANGO IN IRRIGAZIONE VELOCE
- anomaly<='0';
- start_stop<='0';
- timer<="000011";
- rot_frequency<='1';
- wait for clk_period/2*2;
- --VADO DA IRRIGAZIONE VELOCE A SOSPENSIONE VELOCE 2 VOLTE
- for i in 2 to 3 loop
- --VADO
- vet:=conv_std_logic_vector(i,3);
- anomaly<=vet(2);
- start_stop<=vet(1);
- rot_frequency<=vet(0);
- wait for clk_period/2;
- -- RIMANGO IN SOSPENSIONE VELOCE
- for j in 0 to 1 loop
- vet1:=conv_std_logic_vector(j,3);
- anomaly<=vet1(2);
- start_stop<=vet1(1);
- rot_frequency<=vet1(0);
- wait for clk_period/2*2;
- end loop;
- -- RITORNO
- anomaly<=vet(2);
- start_stop<=vet(1);
- rot_frequency<=vet(0);
- wait for clk_period/2*3;
- end loop;
- --RILEVO UN ANOMALIA IN IRRIGAZIONE VELOCE(TUTTE LE COMBINAZIONI)
- for i in 0 to 3 loop
- -- SI SPEGNE LA MACCHINA
- anomaly<='1';
- start_stop<=vet(1);
- rot_frequency<=vet(0);
- wait for clk_period/2*2;
- -- RITORNO AD IRRIGAZIONE VELOCE
- anomaly<='0';
- start_stop<='1';
- rot_frequency<='1';
- wait for clk_period/2*2;
- end loop;
- -- VADO DA IRRIGAZIONE VELOCE A IRRIGAZIONE LENTA DOVE FINISCO DI IRRIGARE
- anomaly<='0';
- start_stop<='0';
- rot_frequency<='0';
- ---- All'inizio abbiamo utilizzato clk_period/2*n, in quanto avendo implementato la macchina con un'automa di Mealy e
- ---- avendo utilizzato un pulsante impulsivo, volevamo cercare di sincronizzare ogni singola variazione di ingresso
- ---- con la sua rispettiva uscita.
- wait;
- end process;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement