-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimeTop.vhd
executable file
·349 lines (312 loc) · 7.08 KB
/
TimeTop.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
Library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
Entity TimeTop is
Port(
CLK,Rstb : in std_logic;
iPushS,iPushO,iPush10,iPush5 : in std_logic;
-- iPushS is change state
-- iPushO is change state to overtime
-- iPush10 is start/stop time counts 10 min
-- iPush5 is start/stop time counts 5 min
Sw15,Sw2 : in std_logic;
-- Sw15 is start/stop time counts 15 min
-- Sw2 is start/stop time counts 2 min
SwRe15,SwRe2 : in std_logic;
-- SwRe15 is reset time counts 15 min
-- SwRe2 is reset time counts 2 min
oLED : out std_logic_vector(4 downto 0);
oBuzz : out std_logic;
oBCD : out std_logic_vector(6 downto 0);
dp : out std_logic;
com : out std_logic_vector(3 downto 0)
);
End TimeTop;
Architecture Structural of TimeTop is
Component CLK1ms is
Port(
CLK : in std_logic;
Rstb : in std_logic;
o1ms : out std_logic
);
End Component CLK1ms;
Component CLK1s is
Port(
CLK : in std_logic;
Rstb : in std_logic;
i1ms : in std_logic;
o1s : out std_logic
);
End Component CLK1s;
Component ScanDigit is
Port(
CLK : in std_logic;
Rstb : in std_logic;
i1ms : in std_logic;
iDigit1 : in std_logic_vector(3 downto 0);
iDigit2 : in std_logic_vector(3 downto 0);
iDigit3 : in std_logic_vector(3 downto 0);
iDigit4 : in std_logic_vector(3 downto 0);
oDigit : out std_logic_vector(3 downto 0);
oData : out std_logic_vector(3 downto 0);
dp : out std_logic
);
End Component ScanDigit;
Component BCD is
Port(
I : in std_logic_vector(3 downto 0);
O : out std_logic_vector(6 downto 0)
);
End Component BCD;
Component Debouce is
Port(
CLK : in std_logic;
Rstb : in std_logic;
i1ms : in std_logic;
I : in std_logic;
O : out std_logic
);
End Component Debouce;
Component FSM is
Port(
CLK,Rstb : in std_logic;
iState,iOver : in std_logic;
i10Digit1,i10Digit2,i10Digit3,i10Digit4 : in std_logic_vector(3 downto 0);
i15Digit1,i15Digit2,i15Digit3,i15Digit4 : in std_logic_vector(3 downto 0);
i5Digit1,i5Digit2,i5Digit3,i5Digit4 : in std_logic_vector(3 downto 0);
i2Digit1,i2Digit2,i2Digit3,i2Digit4 : in std_logic_vector(3 downto 0);
oDigit1,oDigit2,oDigit3,oDigit4 : out std_logic_vector(3 downto 0)
);
End Component FSM;
Component CD10min is
Port(
CLK,Rstb : in std_logic;
i1ms,i1s : in std_logic;
I10,iRe : in std_logic;
o10Digit1,o10Digit2,o10Digit3,o10Digit4 : out std_logic_vector(3 downto 0);
oStart,oFinish : out std_logic
);
End Component CD10min;
Component CD15min is
Port(
CLK,Rstb : in std_logic;
i1s : in std_logic;
I15,iRe : in std_logic;
o15Digit1,o15Digit2,o15Digit3,o15Digit4 : out std_logic_vector(3 downto 0)
);
End Component CD15min;
Component CD2min is
Port(
CLK,Rstb : in std_logic;
i1s : in std_logic;
I2,iRe : in std_logic;
o2Digit1,o2Digit2,o2Digit3,o2Digit4 : out std_logic_vector(3 downto 0)
);
End Component CD2min;
Component Overtime5min is
Port(
CLK,Rstb : in std_logic;
i1ms,i1s : in std_logic;
I5 : in std_logic;
o5Digit1,o5Digit2,o5Digit3,o5Digit4 : out std_logic_vector(3 downto 0);
oStart,oFinish : out std_logic
);
End Component Overtime5min;
Component Counts_Quarter is
Port(
CLK,Rstb : in std_logic;
i1ms,i1s : in std_logic;
iStart,iFinish : in std_logic;
sOverC,fOverC : in std_logic;
O_LED : out std_logic_vector(4 downto 0);
oRe : out std_logic
);
End Component Counts_Quarter;
Component Buzzer is
Port(
CLK,Rstb : in std_logic;
i1ms,i1s : in std_logic;
iS10,iF10,iS5,iF5 : in std_logic;
oBuz : out std_logic
);
End Component Buzzer;
signal w1ms,w1s : std_logic;
signal wData : std_logic_vector(3 downto 0);
signal w10Digit1,w10Digit2,w10Digit3,w10Digit4 : std_logic_vector(3 downto 0);
signal w15Digit1,w15Digit2,w15Digit3,w15Digit4 : std_logic_vector(3 downto 0);
signal w5Digit1,w5Digit2,w5Digit3,w5Digit4 : std_logic_vector(3 downto 0);
signal w2Digit1,w2Digit2,w2Digit3,w2Digit4 : std_logic_vector(3 downto 0);
signal wDigit1,wDigit2,wDigit3,wDigit4 : std_logic_vector(3 downto 0);
signal wIS,wIO,wI10,wI5 : std_logic;
signal wRe : std_logic;
signal wStart,wFinish : std_logic;
signal wOverS,wOverF : std_logic;
Begin
u_CLK1ms : CLK1ms
Port Map(
CLK => CLK,
Rstb => Rstb,
o1ms => w1ms
);
u_CLK1s : CLK1s
Port Map(
CLK => CLK,
Rstb => Rstb,
i1ms => w1ms,
o1s => w1s
);
u_PushState : Debouce
Port Map(
CLK => CLK,
Rstb => Rstb,
i1ms => w1ms,
I => iPushS,
O => wIS
);
u_PushOver : Debouce
Port Map(
CLK => CLK,
Rstb => Rstb,
i1ms => w1ms,
I => iPushO,
O => wIO
);
u_Push10 : Debouce
Port Map(
CLK => CLK,
Rstb => Rstb,
i1ms => w1ms,
I => iPush10,
O => wI10
);
u_Push5 : Debouce
Port Map(
CLK => CLK,
Rstb => Rstb,
i1ms => w1ms,
I => iPush5,
O => wI5
);
u_Counts : Counts_Quarter
Port Map(
CLK => CLK,
Rstb => Rstb,
i1ms => w1ms,
i1s => w1s,
iStart => wStart,
iFinish => wFinish,
sOverC => wOverS,
fOverC => wOverF,
O_LED => oLED,
oRe => wRe
);
u_FSM : FSM
Port Map(
CLK => CLK,
Rstb => Rstb,
iState => wIS,
iOver => wIO,
i10Digit1 => w10Digit1,
i10Digit2 => w10Digit2,
i10Digit3 => w10Digit3,
i10Digit4 => w10Digit4,
i15Digit1 => w15Digit1,
i15Digit2 => w15Digit2,
i15Digit3 => w15Digit3,
i15Digit4 => w15Digit4,
i5Digit1 => w5Digit1,
i5Digit2 => w5Digit2,
i5Digit3 => w5Digit3,
i5Digit4 => w5Digit4,
i2Digit1 => w2Digit1,
i2Digit2 => w2Digit2,
i2Digit3 => w2Digit3,
i2Digit4 => w2Digit4,
oDigit1 => wDigit1,
oDigit2 => wDigit2,
oDigit3 => wDigit3,
oDigit4 => wDigit4
);
u_10min : CD10min
Port Map(
CLK => CLK,
Rstb => Rstb,
i1s => w1s,
i1ms => w1ms,
I10 => wI10,
iRe => wRe,
o10Digit1 => w10Digit1,
o10Digit2 => w10Digit2,
o10Digit3 => w10Digit3,
o10Digit4 => w10Digit4,
oStart => wStart,
oFinish => wFinish
);
u_15min : CD15min
Port Map(
CLK => CLK,
Rstb => Rstb,
i1s => w1s,
I15 => Sw15,
iRe => SwRe15,
o15Digit1 => w15Digit1,
o15Digit2 => w15Digit2,
o15Digit3 => w15Digit3,
o15Digit4 => w15Digit4
);
u_2min : CD2min
Port Map(
CLK => CLK,
Rstb => Rstb,
i1s => w1s,
I2 => Sw2,
iRe => SwRe2,
o2Digit1 => w2Digit1,
o2Digit2 => w2Digit2,
o2Digit3 => w2Digit3,
o2Digit4 => w2Digit4
);
u_5min : Overtime5min
Port Map(
CLK => CLK,
Rstb => Rstb,
i1s => w1s,
i1ms => w1ms,
I5 => wI5,
o5Digit1 => w5Digit1,
o5Digit2 => w5Digit2,
o5Digit3 => w5Digit3,
o5Digit4 => w5Digit4,
oStart => wOverS,
oFinish => wOverF
);
u_Buz : Buzzer
Port Map(
CLK => CLK,
Rstb => Rstb,
i1ms => w1ms,
i1s => w1s,
iS10 => wStart,
iF10 => wFinish,
iS5 => wOverS,
iF5 => wOverF,
oBuz => oBuzz
);
u_ScanDigit : ScanDigit
Port Map(
CLK => CLK,
Rstb => Rstb,
i1ms => w1ms,
iDigit1 => wDigit1,
iDigit2 => wDigit2,
iDigit3 => wDigit3,
iDigit4 => wDigit4,
oDigit => com,
oData => wData,
dp => dp
);
u_BCD : BCD
Port Map(
I => wData,
O => oBCD
);
End Structural;