Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------------
- -- Company:
- -- Engineer:
- --
- -- Create Date: 04:59:30 12/15/2018
- -- Design Name:
- -- Module Name: contatore - Behavioral
- -- Project Name:
- -- Target Devices:
- -- Tool versions:
- -- Description:
- --
- -- Dependencies:
- --
- -- Revision:
- -- Revision 0.01 - File Created
- -- Additional Comments:
- --
- ----------------------------------------------------------------------------------
- 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;
- -- Uncomment the following library declaration if instantiating
- -- any Xilinx primitives in this code.
- --library UNISIM;
- --use UNISIM.VComponents.all;
- entity contatore is
- Port ( clock: in std_logic;
- reset : in std_logic;
- timex :in integer range 0 to 31;
- stato_corrente : in std_logic_vector (0 to 1);
- conteggio_debug : out std_logic_vector (0 to 4);
- fatto : out std_logic;
- acqua : out std_logic;
- uscita : out std_logic );
- end contatore;
- architecture Behavioral of contatore is
- signal conteggio,nuovo_conteggio :integer range 0 to 31 ;
- begin
- processo_clock :process(clock) --ISTANZIO UN CLOCK IN MODO CHE LA FSM FUNZIONI SUL FRONTE DI SALITA (RISING EDGE);
- --SEMPRE SU TALE FRONTE AGGIORNO UN CONTATORE CHE MI OCCORRÀ PER ALCUNE TRANSIZIONI DI STATO
- begin
- if(rising_edge(clock)) then
- if (reset='1') then conteggio<=0;
- else conteggio<=nuovo_conteggio;
- end if;
- end if;
- end process;
- process(stato_corrente,conteggio,timex)
- begin
- if (stato_corrente="11") then
- if (conteggio = timex) or(conteggio > timex) then nuovo_conteggio<=0; fatto<='1'; uscita<='0';acqua<='0';
- elsif((conteggio rem 4=0) and (conteggio /=0)) then uscita<='1'; nuovo_conteggio<=conteggio+1; fatto<='0';acqua<='0';
- else uscita<='0'; nuovo_conteggio<=conteggio+1; fatto<='0';acqua<='1';
- end if;
- elsif(stato_corrente="01") then
- if (conteggio = timex)or(conteggio > timex) then nuovo_conteggio<=0; fatto<='1'; uscita<='0';acqua<='0';
- elsif((conteggio rem 2=0) and (conteggio /=0)) then uscita<='1'; nuovo_conteggio<=conteggio+1; fatto<='0';acqua<='0';
- else uscita<='0'; nuovo_conteggio<=conteggio+1; fatto<='0';acqua<='1';
- end if;
- else nuovo_conteggio<=conteggio; fatto<='0'; uscita<='0';acqua<='0';
- end if;
- end process;
- conteggio_debug<=conv_std_logic_vector(conteggio,5);
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement