-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomeAutomation.vhd
160 lines (160 loc) · 2.95 KB
/
HomeAutomation.vhd
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
library IEEE;
use IEEE.std_logic_1164.all;
entity project_entity is -- should include IEEE.std_logic_1164.all
port(
clk, reset, I1, I2, I3, I4: in std_logic;
I5: in std_logic_vector(7 downto 0);
fdoor, rdoor, buzz, alarm, heat, cool: out std_logic;
disp: out std_logic_vector(2 downto 0)
);
end project_entity;
architecture project_architecture of project_entity is
type states is (start, closeFdoor, closeRdoor, Wbuzz, Salarm, heater, cooler);
signal cur_st, nxt_st: states;
begin
cur_st_pr: process(clk, reset)
begin
if (reset = '1') then
cur_st <= start;
elsif (rising_edge(clk)) then
cur_st <= nxt_st;
end if;
end process cur_st_pr;
nxt_st_pr: process(cur_st, I1, I2, I3, I4, I5)
begin
case cur_st is
when start =>
if (I1 = '1') then
nxt_st <= closeFdoor;
elsif (I2 = '1') then
nxt_st <= closeRdoor;
elsif (I3 = '1') then
nxt_st <= Wbuzz;
elsif (I4 = '1') then
nxt_st <= Salarm;
elsif (I5 < "00110010") then
nxt_st <= heater;
elsif (I5 > "01000110") then
nxt_st <= cooler;
else
nxt_st <= start;
end if;
when closeFdoor =>
10
if (I2 = '1') then
nxt_st <= closeRdoor;
elsif (I3 = '1') then
nxt_st <= Wbuzz;
elsif (I4 = '1') then
nxt_st <= Salarm;
elsif (I5 < "00110010") then
nxt_st <= heater;
elsif (I5 > "01000110") then
nxt_st <= cooler;
else
nxt_st <= start;
end if;
when closeRdoor =>
if (I3 = '1') then
nxt_st <= Wbuzz;
elsif (I4 = '1') then
nxt_st <= Salarm;
elsif (I5 < "00110010") then
nxt_st <= heater;
elsif (I5 > "01000110") then
nxt_st <= cooler;
else
nxt_st <= start;
end if;
when Wbuzz =>
if (I4 = '1') then
nxt_st <= Salarm;
elsif (I5 < "00110010") then
nxt_st <= heater;
elsif (I5 > "01000110") then
nxt_st <= cooler;
else
nxt_st <= start;
end if;
when Salarm =>
if (I5 < "00110010") then
nxt_st <= heater;
elsif (I5 > "01000110") then
nxt_st <= cooler;
else
nxt_st <= start;
end if;
when heater =>
if (I5 > "01000110") then
nxt_st <= cooler;
else
nxt_st <= start;
end if;
when cooler =>
11
nxt_st <= start;
end case;
end process nxt_st_pr;
out_reg_pr: process(clk, reset)
begin
case cur_st is
when start =>
fdoor <= '0';
rdoor <= '0';
buzz <= '0';
alarm <= '0';
cool <= '0';
heat <= '0';
disp <= "000";
when closeFdoor =>
fdoor <= '1';
rdoor <= '0';
buzz <= '0';
alarm <= '0';
cool <= '0';
heat <= '0';
disp <= "001";
when closeRdoor =>
fdoor <= '0';
rdoor <= '1';
buzz <= '0';
alarm <= '0';
cool <= '0';
heat <= '0';
disp <= "010";
when Wbuzz =>
fdoor <= '0';
rdoor <= '0';
buzz <= '1';
alarm <= '0';
cool <= '0';
heat <= '0';
disp <= "011";
when Salarm =>
fdoor <= '0';
rdoor <= '0';
buzz <= '0';
alarm <= '1';
cool <= '0';
heat <= '0';
disp <= "100";
when heater =>
fdoor <= '0';
rdoor <= '0';
12
buzz <= '0';
alarm <= '0';
heat <= '1';
cool <= '0';
disp <= "101";
when cooler =>
fdoor <= '0';
rdoor <= '0';
buzz <= '0';
alarm <= '0';
heat <= '0';
cool <= '1';
disp <= "110";
end case;
end process out_reg_pr;
end project_architecture;