-
Notifications
You must be signed in to change notification settings - Fork 0
/
energy_monitor.vhd
189 lines (169 loc) · 3.76 KB
/
energy_monitor.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
library ieee;
use ieee.std_logic_1164.all;
entity energy_monitor is port
(
AGTB : in std_logic;
AEQB : in std_logic;
ALTB : in std_logic;
vacation_mode : in std_logic;
MC_test_mode : in std_logic;
window_open : in std_logic;
door_open : in std_logic;
furnace : out std_logic;
at_temp : out std_logic;
AC : out std_logic;
blower : out std_logic;
window : out std_logic;
door : out std_logic;
vacation : out std_logic;
run : out std_logic;
increase : out std_logic;
decrease : out std_logic
);
end energy_monitor;
ARCHITECTURE control OF energy_monitor IS
begin
--
-- process (AGTB)
-- begin
--
-- if (AGTB = '1') then
-- -- if A is greater than B, run is ON and we increase the counter
-- run <= '1';
-- increase <= '1';
-- decrease <= '0';
-- -- A greater than B the led for furnace should be ON
-- furnace <= '1';
-- -- blower is on whenever A is different from B
-- blower <= '1';
-- end if;
--
-- end process;
--
-- process (AEQB)
-- begin
-- -- if A is equal to B, run is OFF and the counter does not change
-- if (AEQB = '1') then
-- run <= '0';
-- increase <='0';
-- decrease <= '0';
-- -- A equal to B, led for at_temp should be on and blower should be off
-- at_temp <= '1';
-- blower <= '0';
-- end if;
-- end process;
--
--
-- process (ALTB)
-- begin
-- -- if A less than B, run is OFF and we decrease the counter
-- if (ALTB = '1') then
-- run <= '1';
-- increase <= '0';
-- decrease <= '1';
-- -- A is less than B, led for AC should be ON
-- AC <= '1';
-- -- blower is on whenever A is different from B
-- blower <= '1';
-- end if;
-- end process;
--
--
-- -- if the door or window is open we don't run the HVAC
-- process (window_open)
-- begin
-- if (window_open = '1') then
-- run <= '0';
-- -- turn on window led
-- window <= '1';
-- -- blower is OFF when window is open
-- blower <= '0';
-- end if;
-- end process;
--
--
-- process (door_open)
-- begin
-- if (door_open ='1') then
-- run <= '0';
-- -- turn on door led
-- door <= '1';
-- -- blower is oFF when door is open
-- blower <= '0';
-- end if;
-- end process;
--
--
-- --to test the comparator
-- process (MC_test_Mode)
-- begin
-- if (MC_test_mode = '1') then
-- -- stop running
-- run <= '0';
-- -- blower OFF when MC_test_mode is ON
-- blower <= '0';
-- end if;
-- end process;
--
-- process (vacation_mode)
-- begin
-- if (vacation_mode = '1') then
-- -- led for vacation is ON when vacation_mode is ON
-- vacation <= '1';
-- end if;
-- end process;
--
process (AGTB, AEQB, ALTB, window_open, door_open, vacation_mode, MC_test_mode)
begin
-- Default values
run <= '0';
if (AGTB = '1') then
increase <= '1';
decrease <= '0';
furnace <= '1';
else
increase <= '0';
furnace <= '0';
end if;
if (ALTB = '1') then
increase <= '0';
decrease <= '1';
AC <= '1';
else
decrease <= '0';
AC<= '0';
end if;
if (AEQB = '1' OR MC_test_mode = '1' OR window_open = '1' OR door_open = '1') then
run <= '0';
else
run <= '1';
end if;
if (AEQB = '1') then
blower <= '0';
at_temp <= '1';
else
blower <= '1';
at_temp <= '0';
end if ;
if (AEQB = '0' AND NOT (MC_test_mode = '1' OR window_open = '1' OR door_open = '1')) then
blower <= '1';
else
blower <= '0';
end if;
if (door_open ='1') then
door <= '1';
else
door <= '0';
end if;
if (window_open = '1') then
window <= '1';
else
window <= '0';
end if;
if (vacation_mode = '1') then
vacation <='1';
else
vacation <='0';
end if;
end process;
end control;