Advertisement
Guest User

Untitled

a guest
Jan 6th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.55 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    04:59:30 12/15/2018
  6. -- Design Name:
  7. -- Module Name:    contatore - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.STD_LOGIC_arith.ALL;
  23.  
  24. -- Uncomment the following library declaration if using
  25. -- arithmetic functions with Signed or Unsigned values
  26. --use IEEE.NUMERIC_STD.ALL;
  27.  
  28. -- Uncomment the following library declaration if instantiating
  29. -- any Xilinx primitives in this code.
  30. --library UNISIM;
  31. --use UNISIM.VComponents.all;
  32.  
  33. entity contatore is
  34.     Port ( clock: in std_logic;
  35.                 reset : in std_logic;
  36.                 timex :in integer range 0 to 31;
  37.               stato_corrente : in  std_logic_vector (0 to 1);  
  38.               conteggio_debug : out  std_logic_vector (0 to 4);
  39.               fatto : out std_logic;
  40.               acqua : out std_logic;
  41.               uscita : out std_logic );
  42. end contatore;
  43.  
  44. architecture Behavioral of contatore is
  45. signal  conteggio,nuovo_conteggio  :integer range 0 to 31 ;
  46. begin
  47.  
  48. processo_clock :process(clock) --ISTANZIO UN CLOCK IN MODO CHE LA FSM FUNZIONI SUL FRONTE DI SALITA (RISING EDGE);
  49.                                       --SEMPRE SU TALE FRONTE AGGIORNO UN CONTATORE CHE MI OCCORRÀ PER ALCUNE TRANSIZIONI DI STATO
  50. begin
  51.     if(rising_edge(clock)) then
  52.        if (reset='1') then conteggio<=0;
  53.             else conteggio<=nuovo_conteggio;
  54.        end if;
  55.     end if;
  56. end process;
  57.  
  58.  
  59. process(stato_corrente,conteggio,timex)
  60. begin
  61. if (stato_corrente="11") then
  62.     if (conteggio = timex) or(conteggio > timex) then nuovo_conteggio<=0; fatto<='1'; uscita<='0';acqua<='0';
  63.     elsif((conteggio rem 4=0) and (conteggio /=0)) then uscita<='1'; nuovo_conteggio<=conteggio+1; fatto<='0';acqua<='0';
  64.         else uscita<='0'; nuovo_conteggio<=conteggio+1; fatto<='0';acqua<='1';
  65.     end if;
  66. elsif(stato_corrente="01") then
  67. if (conteggio = timex)or(conteggio > timex) then nuovo_conteggio<=0; fatto<='1'; uscita<='0';acqua<='0';
  68.     elsif((conteggio rem 2=0) and (conteggio /=0)) then uscita<='1'; nuovo_conteggio<=conteggio+1; fatto<='0';acqua<='0';
  69.         else uscita<='0'; nuovo_conteggio<=conteggio+1; fatto<='0';acqua<='1';
  70.     end if;
  71. else nuovo_conteggio<=conteggio; fatto<='0'; uscita<='0';acqua<='0';
  72. end if;
  73. end process;
  74.  
  75. conteggio_debug<=conv_std_logic_vector(conteggio,5);
  76. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement