Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------------
- -- Company:
- -- Engineer:
- --
- -- Create Date: 15:13:26 12/13/2018
- -- Design Name:
- -- Module Name: funzionamento - 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 funzionamento is
- Port ( clk : in STD_LOGIC;
- rst : in STD_LOGIC;
- timer :in integer range 0 to 31;
- freq : in STD_LOGIC;
- p : in STD_LOGIC;
- stato_debug :out STD_LOGIC_VECTOR (0 TO 1);
- count_debug : out std_logic_vector (0 to 4);
- irrigazione : out STD_LOGIC;
- ugello : out STD_LOGIC);
- end funzionamento;
- architecture Behavioral of funzionamento is
- type state is (off,high,attesa,low);
- signal cs,nxs : state;
- signal done:std_logic ;
- signal stato_contatore : STD_LOGIC_VECTOR (0 TO 1);
- component contatore
- 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 component;
- begin
- processo_clock :process(clk)
- --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(clk)) then
- if (rst='1') then cs<=off;
- else cs<=nxs;
- end if;
- end if;
- end process;
- funzionamento_stati :process(p,freq,done,cs)
- begin
- --DESCRIVO IL COMPORTAMENTO DELLA MACCHINA ,
- -- SPECIFICANDO LE TRANSIZIONI CHE AVVENGONO IN BASE
- -- ALLA VARIAZIONE DI'P' , DI 'freq' E DI 'done'
- case cs is
- when off =>
- --STATO INIZIALE IN CUI LA MACCHINA È SPENTA
- --O ARRIVA DOPO AVER TERMINATO IL PROPRIO CICLO DI FUNZIONAMENTO
- if (done = '0') then
- if (p='1' and freq='1' ) then nxs<=high;
- elsif (p='1' and freq ='0' ) then nxs<=low;
- else nxs<=off;
- end if;
- else nxs<=off;
- end if;
- stato_debug<=conv_std_logic_vector(state'POS(cs),2);
- stato_contatore<=conv_std_logic_vector(state'POS(cs),2);
- when high =>
- --FREQUENZA DI FUNZIONAMENTO ALTA,IN CUI L'IMPIANTO EROGA ACQUA
- -- AD INTERVALLI PIÙ RAVVICINATI
- if (done= '0') then
- if( p='1' and freq = '1' ) then nxs<=high;
- elsif (p='0' and freq='0' ) then nxs<=attesa;
- elsif (p='0' and freq='1' ) then nxs<=attesa;
- elsif (p='1' and freq ='0' ) then nxs<=low;
- else nxs<=off;
- end if;
- else nxs<=off;
- end if;
- stato_debug<=conv_std_logic_vector(state'POS(cs),2);
- stato_contatore<=conv_std_logic_vector(state'POS(cs),2);
- when attesa =>
- --STATO DI PAUSA , IN CUI LA MACCHINA BLOCCA IL CONTATORE E L'EROGAZIONE DELL'ACQUA
- if (done= '0') then
- if( p='1' and freq = '1' ) then nxs<=high;
- elsif (p='0' and freq='0') then nxs<=attesa;
- elsif (p='0' and freq='1') then nxs<=attesa;
- elsif (p='1' and freq ='0') then nxs<=low;
- else nxs<=off;
- end if;
- else nxs<=off;
- end if;
- stato_debug<=conv_std_logic_vector(state'POS(cs),2);
- stato_contatore<=conv_std_logic_vector(state'POS(cs),2);
- when low =>
- --FREQUENZA DI FUNZIONAMENTO BASSA,IN CUI L'IMPIANTO EROGA ACQUA
- --PIÙ LENTAMENTE RISPETTO ALLO STATO 'high'
- if (done= '0') then
- if( p='1' and freq = '1' ) then nxs<=high;
- elsif (p='0' and freq='0') then nxs<=attesa;
- elsif (p='0' and freq='1' ) then nxs<=attesa;
- elsif (p='1' and freq ='0') then nxs<=low;
- else nxs<=off;
- end if;
- else nxs<=off;
- end if;
- stato_debug<=conv_std_logic_vector(state'POS(cs),2);
- stato_contatore<=conv_std_logic_vector(state'POS(cs),2);
- end case;
- end process;
- I0 : contatore port map ( clk,rst,timer,stato_contatore,count_debug,done,irrigazione,ugello);
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement