Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use IEEE.STD_LOGIC_UNSIGNED.ALL;
- -- entity
- entity Zmywarka is
- Port ( reset : in STD_LOGIC;
- clk : in STD_LOGIC;
- program : in STD_LOGIC;
- woda_max : in STD_LOGIC;
- woda_min : in STD_LOGIC;
- zawor : out STD_LOGIC;
- grzalka : out STD_LOGIC;
- pompa : out STD_LOGIC;
- nablyszczacz : out STD_LOGIC;
- tabletka : out STD_LOGIC
- );
- end Zmywarka;
- -- stan, w jakim znajduje się automat
- -- "00" - START/STOP
- -- "01" - WODA
- -- "10" - ZMYWANIE
- -- "11" - WYPOMPOWANIE WODY
- -- architektura
- architecture Zmywarka_arch of Zmywarka is
- type MOJE_STANY is (START_STOP, WODA, ZMYWANIE, WYPOMPOWANIE); -- deklaracja typu MOJE_STANY o wartościach: (moje stany)
- signal stan, stan_nastepny : MOJE_STANY;
- signal czasomierz : std_logic_vector (3 downto 0); -- wyjscie licznika czasu zmywania
- signal postep : std_logic_vector (2 downto 0); -- licznik cykli zmywarki
- signal wyjscie : std_logic_vector (1 downto 0); -- wyjscie, informujace o stanie zmywarki
- begin
- zmyw: process (stan, program, woda_max, woda_min, czasomierz, postep)
- begin
- stan_nastepny <= stan;
- case stan is
- when START_STOP =>
- if program = '1' and postep = "000" then
- stan_nastepny <= WODA;
- end if;
- when WODA =>
- if program = '0' then
- stan_nastepny <= START_STOP;
- elsif woda_max = '1' then
- if postep = "000" then
- stan_nastepny <= WYPOMPOWANIE;
- else
- stan_nastepny <= ZMYWANIE;
- end if;
- end if;
- when ZMYWANIE =>
- if program = '0' then
- stan_nastepny <= START_STOP;
- elsif czasomierz = "1111" then
- stan_nastepny <= WYPOMPOWANIE;
- end if;
- when WYPOMPOWANIE =>
- if program = '0' then
- stan_nastepny <= START_STOP;
- elsif woda_min = '1' then
- if postep /= "000" then
- stan_nastepny <= START_STOP;
- else
- stan_nastepny <= WODA;
- end if;
- end if;
- when others =>
- stan_nastepny <= START_STOP;
- end case;
- end process zmyw;
- rejestr_stanu_wewnetrznego: process (reset, clk)
- begin
- if reset = '0' then
- stan <= START_STOP;
- elsif clk'event and clk = '1' then
- stan <= stan_nastepny;
- end if;
- end process rejestr_stanu_wewnetrznego;
- licznik_czasu_zmywania: process (reset, clk)
- begin
- if reset = '0' then
- czasomierz <= (others => '0');
- elsif clk'event and clk = '1' then
- if stan = ZMYWANIE then
- czasomierz <= czasomierz + "01";
- else
- czasomierz <= (others => '0');
- end if;
- end if;
- end process licznik_czasu_zmywania;
- licznik_cykli: process (reset, clk)
- begin
- if reset = '0' then
- postep <= (others => '0');
- elsif clk'event and clk = '1' then
- if stan = WYPOMPOWANIE and stan_nastepny = WODA then
- postep <= postep + "01";
- else
- postep <= postep;
- end if;
- end if;
- end process licznik_cykli;
- zawor <= '1' when stan = WODA else '0';
- grzalka <= '1' when stan = ZMYWANIE else '0';
- pompa <= '1' when stan = WYPOMPOWANIE else '0';
- nablyszczacz <= '1' when stan = ZMYWANIE else '0';
- tabletka <= '1' when stan = ZMYWANIE else '0';
- wyjscie <= "00" when stan = START_STOP else
- "01" when stan = WODA else
- "10" when stan = ZMYWANIE else
- "11";
- end Zmywarka_arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement