Advertisement
Guest User

Untitled

a guest
Jan 6th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 4.84 KB | None | 0 0
  1. --------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:   04:54:45 12/14/2018
  6. -- Design Name:  
  7. -- Module Name:   /home/ise/Documents/irrigazione_progetto/tb_progetto.vhd
  8. -- Project Name:  irrigazione_progetto
  9. -- Target Device:  
  10. -- Tool versions:  
  11. -- Description:  
  12. --
  13. -- VHDL Test Bench Created by ISE for module: funzionamento
  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 tb_progetto IS
  37. END tb_progetto;
  38.  
  39. ARCHITECTURE behavior OF tb_progetto IS
  40.  
  41.     -- Component Declaration for the Unit Under Test (UUT)
  42.  
  43.     COMPONENT funzionamento
  44.     PORT(
  45.          clk : IN  std_logic;
  46.          rst : IN  std_logic;
  47.          timer : IN  integer range 0 to 31;
  48.          freq : IN  std_logic;
  49.          p : IN  std_logic;
  50.             count_debug :out STD_LOGIC_VECTOR (0 TO 4);
  51.             stato_debug :out STD_LOGIC_VECTOR (0 TO 1);
  52.             irrigazione : out  STD_LOGIC;
  53.          ugello : OUT  std_logic
  54.         );
  55.     END COMPONENT;
  56.    
  57.  
  58.    --Inputs
  59.    signal clk : std_logic := '0';
  60.    signal rst : std_logic := '0';
  61.    signal timer : integer range 0 to 31;
  62.    signal freq : std_logic := '0';
  63.    signal p : std_logic := '0';
  64.  
  65.     --Outputs
  66.     signal count_debug : STD_LOGIC_VECTOR (0 TO 4);
  67.     signal stato_debug : STD_LOGIC_VECTOR (0 TO 1);
  68.    signal ugello : std_logic;
  69.     signal irrigazione : STD_LOGIC;
  70.    
  71.  
  72.  
  73.  
  74.    -- Clock period definitions
  75.    constant clk_period : time := 10
  76.     ns;
  77.  
  78. BEGIN
  79.  
  80.     -- Instantiate the Unit Under Test (UUT)
  81.    uut: funzionamento PORT MAP (
  82.           clk => clk,
  83.           rst => rst,
  84.           timer => timer,
  85.           freq => freq,
  86.           p => p,
  87.              count_debug=>count_debug,
  88.              stato_debug=>stato_debug,
  89.              irrigazione=> irrigazione,
  90.           ugello => ugello
  91.         );
  92.  
  93.    -- Clock process definitions
  94.    clk_process :process
  95.    begin
  96.         clk <= '0';
  97.         wait for clk_period/2;
  98.         clk <= '1';
  99.         wait for clk_period/2;
  100.    end process;
  101.  
  102.  
  103.    -- Stimulus process
  104.    stim_proc: process
  105.    begin       
  106.       -- hold reset state for 100 ns.
  107.       wait for 100 ns; 
  108.  
  109.             rst<='1';
  110.             wait for 10 ns;
  111.  
  112.             rst<='0';
  113.             wait for 10 ns;
  114.            
  115.       wait for clk_period*10;
  116.  
  117.       -- insert stimulus here
  118.        
  119.        
  120.        
  121. --Inseriamo un numero di cicli compreso nel range dato     
  122.         timer<=20;
  123.  
  124. --Inseriamo delle combinazioni che permettano la permanenza nello stato 'off'
  125.       p<='0';
  126.       freq<='0';
  127.       wait for clk_period*10;
  128.  
  129.       p<='0';
  130.       freq<='1';
  131.       wait for clk_period*10;
  132.  
  133. --Passiamo allo stato di irrigazione a frequenza alta
  134. -- Permaniamo nello stato fino alla fine del conteggio
  135.       p<='1';
  136.       freq<='1';
  137.       wait until count_debug="00000";
  138.  
  139.  
  140. --Alla fine del ciclo di funzionamento ritorniamo nello stato off
  141.       p<='0';
  142.       freq<='0';
  143.       wait for clk_period*5;
  144.  
  145.  
  146. --Passiamo allo stato di irrigazione a frequenza bassa
  147. -- Permaniamo nello stato fino alla fine del conteggio
  148.        p<='1';
  149.          freq<='0';
  150.       wait until count_debug="00000";
  151.        
  152.      
  153. --Alla fine del ciclo di funzionamento ritorniamo nello stato off
  154.       p<='0';
  155.       freq<='0';
  156.       wait for clk_period*5;
  157.  
  158. --Passiamo allo stato di irrigazione a frequenza alta
  159.       p<='1';
  160.       freq<='1';
  161.       wait for clk_period*5;
  162.        
  163. --Sospendiamo il processo e permaniamo nello stato di 'attesa'
  164. --testando tutte le combinazioni
  165.  
  166.         p<='0';
  167.       freq<='0';
  168.       wait for clk_period*5;
  169.        
  170.          p<='0';
  171.       freq<='1';
  172.       wait for clk_period*5;
  173.        
  174. --Torniamo nello stato di irrigazione a frequenza alta
  175.         p<='1';
  176.       wait for clk_period*10;
  177.        
  178. --Passiamo allo stato di irrigazione a frequenza bassa
  179.        p<='1';
  180.          freq<='0';
  181.       wait for clk_period*5;
  182.  
  183.  
  184. --variamo anche il valore di timer ( ovvero dei cicli di irrigazione)
  185.         timer<=24;
  186.         wait for clk_period*15;
  187.  
  188. --Ritorniano allo stato 'low' variando nuovamente il timer
  189. --impostando un valore più piccolo del precedente
  190.             timer<=6;
  191.             p<='1';
  192.             freq<='0';
  193.         wait for clk_period*10;
  194.        
  195. --Passiamo direttamenta allo stato 'high'
  196.             p<='1';
  197.             freq<='1';
  198.        wait for clk_period*10;
  199.             timer<=20;
  200.        
  201.  
  202.       wait;
  203.    end process;
  204.  
  205. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement