-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDigitalClockOnVGAProje.vhd
366 lines (312 loc) · 10.8 KB
/
DigitalClockOnVGAProje.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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
--License:
-- DigitalClockWithFPGA is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- DigitalClockWithFPGA is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with DigitalClockWithFPGA. If not, see <http://www.gnu.org/licenses/>.
--
--Description:
-- This software can ported to any FPGA board to display two adjustable digital
-- clocks with adjustable colors. The code was tested on Xilinx Spartan 3E and
-- Altera DE0 boards.
--
--Author:
-- Mustafa Ozcelikors
-- thewebblog.net
-- github.com/mozcelikors
-- <[email protected]>
-- Metin Kundakcioglu
-- <[email protected]>
--
--Note:
-- This code may contain Turkish commenting.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity DigitalClockOnVGAProje is
Port ( CLOCK_50 : in STD_LOGIC;
VGA_HS : out STD_LOGIC;
VGA_VS : out STD_LOGIC;
VGA_R : out STD_LOGIC_VECTOR(3 downto 0);
VGA_G : out STD_LOGIC_VECTOR(3 downto 0);
VGA_B : out STD_LOGIC_VECTOR(3 downto 0);
KEY : in std_LOGIC_VECTOR(2 downto 0);
GPIO_0 : in std_logic_vector(30 downto 0);
SW : in std_LOGIC_VECTOR(9 downto 0)
);
end entity DigitalClockOnVGAProje;
architecture DigitalClockOnVGAProje of DigitalClockOnVGAProje is
signal Clock1DigitH1_wire : std_logic_vector(3 downto 0);
signal Clock1DigitH2_wire : std_logic_vector(3 downto 0);
signal Clock1DigitM1_wire : std_logic_vector(3 downto 0);
signal Clock1DigitM2_wire : std_logic_vector(3 downto 0);
signal Clock1DigitS1_wire : std_logic_vector(3 downto 0);
signal Clock1DigitS2_wire : std_logic_vector(3 downto 0);
signal Clock2DigitH1_wire : std_logic_vector(3 downto 0);
signal Clock2DigitH2_wire : std_logic_vector(3 downto 0);
signal Clock2DigitM1_wire : std_logic_vector(3 downto 0);
signal Clock2DigitM2_wire : std_logic_vector(3 downto 0);
signal Clock2DigitS1_wire : std_logic_vector(3 downto 0);
signal Clock2DigitS2_wire : std_logic_vector(3 downto 0);
signal Clock1AdjustHourButton_wire : std_logic;
signal Clock1AdjustMinuteButton_wire : std_logic;
signal Clock2AdjustHourButton_wire : std_logic;
signal Clock2AdjustMinuteButton_wire : std_logic;
signal Clock1Region1_wire : std_logic_vector(6 downto 0);
signal Clock1Region2_wire : std_logic_vector(6 downto 0);
signal Clock1Region3_wire : std_logic_vector(6 downto 0);
signal Clock1Region4_wire : std_logic_vector(6 downto 0);
signal Clock1Region5_wire : std_logic_vector(6 downto 0);
signal Clock1Region6_wire : std_logic_vector(6 downto 0);
signal Clock2Region1_wire : std_logic_vector(6 downto 0);
signal Clock2Region2_wire : std_logic_vector(6 downto 0);
signal Clock2Region3_wire : std_logic_vector(6 downto 0);
signal Clock2Region4_wire : std_logic_vector(6 downto 0);
signal Clock2Region5_wire : std_logic_vector(6 downto 0);
signal Clock2Region6_wire : std_logic_vector(6 downto 0);
signal ResetClock1_wire : std_logic;
signal ResetClock2_wire : std_logic;
signal ChangeColorButton1_wire : std_logic;
signal ChangeColorButton2_wire : std_logic;
signal Clock1_R_in_wire : std_logic_vector(3 downto 0);
signal Clock1_G_in_wire : std_logic_vector(3 downto 0);
signal Clock1_B_in_wire : std_logic_vector(3 downto 0);
signal Clock2_R_in_wire : std_logic_vector(3 downto 0);
signal Clock2_G_in_wire : std_logic_vector(3 downto 0);
signal Clock2_B_in_wire : std_logic_vector(3 downto 0);
signal RotaryCCWOut_wire : std_logic;
signal RotaryCWOut_wire : std_logic;
component Displayer is
Port ( clk : in STD_LOGIC;
HS : out STD_LOGIC;
VS : out STD_LOGIC;
R : out STD_LOGIC_VECTOR(3 downto 0);
G : out STD_LOGIC_VECTOR(3 downto 0);
B : out STD_LOGIC_VECTOR(3 downto 0);
Clock1Region1: in std_logic_vector(6 downto 0);
Clock1Region2: in std_logic_vector(6 downto 0);
Clock1Region3: in std_logic_vector(6 downto 0);
Clock1Region4: in std_logic_vector(6 downto 0);
Clock1Region5: in std_logic_vector(6 downto 0);
Clock1Region6: in std_logic_vector(6 downto 0);
Clock2Region1: in std_logic_vector(6 downto 0);
Clock2Region2: in std_logic_vector(6 downto 0);
Clock2Region3: in std_logic_vector(6 downto 0);
Clock2Region4: in std_logic_vector(6 downto 0);
Clock2Region5: in std_logic_vector(6 downto 0);
Clock2Region6: in std_logic_vector(6 downto 0);
Clock1_R_in : in std_logic_vector(3 downto 0);
Clock1_G_in : in std_logic_vector(3 downto 0);
Clock1_B_in : in std_logic_vector(3 downto 0);
Clock2_R_in : in std_logic_vector(3 downto 0);
Clock2_G_in : in std_logic_vector(3 downto 0);
Clock2_B_in : in std_logic_vector(3 downto 0)
);
end component;
component RotaryEncoder2Ch is
Port(
clk : in std_logic;
A : in std_logic;
B : in std_logic;
Q : out std_logic_vector(9 downto 0);
CCW : out std_logic;
CW : out std_logic;
CHNG: out std_logic --change flag
);
end component;
component RegionGenerator is
Port (
Digit : in std_logic_vector(3 downto 0);
Region : out std_logic_vector(6 downto 0)
);
end component;
component DigitalClockGenerator is
Port (
Clock : in std_logic;
Reset : in std_logic;
AdjustHourButton : in std_logic;
AdjustMinuteButton : in std_logic;
RotaryCCWOut : in std_logic;
RotaryCWOut : in std_logic;
DigitH1 : out std_logic_vector(3 downto 0);
DigitH2 : out std_logic_vector(3 downto 0);
DigitM1 : out std_logic_vector(3 downto 0);
DigitM2 : out std_logic_vector(3 downto 0);
DigitS1 : out std_logic_vector(3 downto 0);
DigitS2 : out std_logic_vector(3 downto 0)
);
end component;
component KeyDebouncer is
Port(
clk : in std_logic;
button_in : in std_logic;
button_out : out std_logic
);
end component;
component ColorGenerator is
Port (
ChangeColorButton : in std_logic;
R_out : out std_logic_vector(3 downto 0);
G_out : out std_logic_vector(3 downto 0);
B_out : out std_logic_vector(3 downto 0)
);
end component;
begin
DSP1: entity work.Displayer port map (
clk => CLOCK_50,
HS => VGA_HS,
VS => VGA_VS,
R => VGA_R,
G => VGA_G,
B => VGA_B,
Clock1Region1 => Clock1Region1_wire,
Clock1Region2 => Clock1Region2_wire,
Clock1Region3 => Clock1Region3_wire,
Clock1Region4 => Clock1Region4_wire,
Clock1Region5 => Clock1Region5_wire,
Clock1Region6 => Clock1Region6_wire,
Clock2Region1 => Clock2Region1_wire,
Clock2Region2 => Clock2Region2_wire,
Clock2Region3 => Clock2Region3_wire,
Clock2Region4 => Clock2Region4_wire,
Clock2Region5 => Clock2Region5_wire,
Clock2Region6 => Clock2Region6_wire,
Clock1_R_in => Clock1_R_in_wire,
Clock1_G_in => Clock1_G_in_wire,
Clock1_B_in => CLock1_B_in_wire,
Clock2_R_in => Clock2_R_in_wire,
Clock2_G_in => Clock2_G_in_wire,
Clock2_B_in => CLock2_B_in_wire
);
RG1: RegionGenerator port map (
Digit => Clock1DigitH1_wire,
Region => Clock1Region1_wire
);
RG2: RegionGenerator port map (
Digit => Clock1DigitH2_wire,
Region => Clock1Region2_wire
);
RG3: RegionGenerator port map (
Digit => Clock1DigitM1_wire,
Region => Clock1Region3_wire
);
RG4: RegionGenerator port map (
Digit => Clock1DigitM2_wire,
Region => Clock1Region4_wire
);
RG5: RegionGenerator port map (
Digit => Clock1DigitS1_wire,
Region => Clock1Region5_wire
);
RG6: RegionGenerator port map (
Digit => Clock1DigitS2_wire,
Region => Clock1Region6_wire
);
RG7: RegionGenerator port map (
Digit => Clock2DigitH1_wire,
Region => Clock2Region1_wire
);
RG8: RegionGenerator port map (
Digit => Clock2DigitH2_wire,
Region => Clock2Region2_wire
);
RG9: RegionGenerator port map (
Digit => Clock2DigitM1_wire,
Region => Clock2Region3_wire
);
RG10: RegionGenerator port map (
Digit => Clock2DigitM2_wire,
Region => Clock2Region4_wire
);
RG11: RegionGenerator port map (
Digit => Clock2DigitS1_wire,
Region => Clock2Region5_wire
);
RG12: RegionGenerator port map (
Digit => Clock2DigitS2_wire,
Region => Clock2Region6_wire
);
RE1: RotaryEncoder2Ch port map (
clk => CLOCK_50,
A => GPIO_0(30),
B => GPIO_0(29),
CCW => RotaryCCWOut_wire,
CW => RotaryCWOut_wire
);
DCG1: DigitalClockGenerator port map (
Clock => CLOCK_50,
Reset => ResetClock1_wire,
AdjustHourButton => Clock1AdjustHourButton_wire,
AdjustMinuteButton => Clock1AdjustMinuteButton_wire,
DigitH1 => Clock1DigitH1_wire,
DigitH2 => Clock1DigitH2_wire,
DigitM1 => Clock1DigitM1_wire,
DigitM2 => Clock1DigitM2_wire,
DigitS1 => Clock1DigitS1_wire,
DigitS2 => Clock1DigitS2_wire,
RotaryCCWOut => RotaryCCWOut_wire,
RotaryCWOut => RotaryCWOut_wire
);
DCG2: DigitalClockGenerator port map (
Clock => CLOCK_50,
Reset => ResetClock1_wire,
AdjustHourButton => Clock2AdjustHourButton_wire,
AdjustMinuteButton => Clock2AdjustMinuteButton_wire,
DigitH1 => Clock2DigitH1_wire,
DigitH2 => Clock2DigitH2_wire,
DigitM1 => Clock2DigitM1_wire,
DigitM2 => Clock2DigitM2_wire,
DigitS1 => Clock2DigitS1_wire,
DigitS2 => Clock2DigitS2_wire,
RotaryCCWOut => RotaryCCWOut_wire,
RotaryCWOut => RotaryCWOut_wire
);
-- KEY 0 RESET
KD1: KeyDebouncer port map(
clk => CLOCK_50,
button_in => KEY(0),
button_out => ResetClock1_wire
);
KD2: KeyDebouncer port map(
clk => CLOCK_50,
button_in => KEY(2),
button_out => Clock1AdjustHourButton_wire
);
KD3: KeyDebouncer port map(
clk => CLOCK_50,
button_in => KEY(1),
button_out => Clock1AdjustMinuteButton_wire
);
CG1: ColorGenerator port map(
ChangeColorButton => ChangeColorButton1_wire,
R_out => Clock1_R_in_wire,
B_out => Clock1_B_in_wire,
G_out => Clock1_G_in_wire
);
CG2: ColorGenerator port map(
ChangeColorButton => ChangeColorButton2_wire,
R_out => Clock2_R_in_wire,
B_out => Clock2_B_in_wire,
G_out => Clock2_G_in_wire
);
KD4: KeyDebouncer port map(
clk => CLOCK_50,
button_in => SW(1),
button_out => ChangeColorButton1_wire
);
KD5: KeyDebouncer port map(
clk => CLOCK_50,
button_in => SW(0),
button_out => ChangeColorButton2_wire
);
Clock2AdjustHourButton_wire <= '0';
Clock2AdjustMinuteButton_wire <= '0';
ResetClock2_wire <= '0';
end DigitalClockOnVGAProje;