-
Notifications
You must be signed in to change notification settings - Fork 0
/
washcontrol.vhdl
67 lines (56 loc) · 1.36 KB
/
washcontrol.vhdl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
library IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_misc.all;
entity washcontrol is
port (
inicia, cheia, tempo, vazia: in std_logic;
clock: in std_logic;
entrada_agua: out std_logic;
aciona_motor: out std_logic;
saida_agua: out std_logic
);
end entity;
architecture behavioral of washcontrol is
type state_t is (e_ociosa, e_enchendo, e_lavando, e_esvaziando);
signal estado_atual, prox_estado : state_t := e_ociosa;
begin
update: process (clock)
begin
if rising_edge(clock) then
estado_atual <= prox_estado;
end if;
end process;
transition: process (estado_atual, inicia, cheia, tempo, vazia)
begin
case estado_atual is
when e_ociosa =>
entrada_agua <= '0';
aciona_motor <= '0';
saida_agua <= '0';
if rising_edge(inicia) then
prox_estado <= e_enchendo;
end if;
when e_enchendo =>
entrada_agua <= '1';
aciona_motor <= '0';
saida_agua <= '0';
if rising_edge(cheia) then
prox_estado <= e_lavando;
end if;
when e_lavando =>
entrada_agua <= '0';
aciona_motor <= '1';
saida_agua <= '0';
if rising_edge(tempo) then
prox_estado <= e_esvaziando;
end if;
when e_esvaziando =>
entrada_agua <= '0';
aciona_motor <= '0';
saida_agua <= '1';
if rising_edge(vazia) then
prox_estado <= e_ociosa;
end if;
end case;
end process;
end architecture;