1 |
34 |
rrred |
library IEEE;
|
2 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
3 |
|
|
use IEEE.STD_LOGIC_ARITH.all;
|
4 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.all;
|
5 |
|
|
-- Module Generates Video Sync Signals for Video Montor Interface
|
6 |
|
|
-- RGB and Sync outputs tie directly to monitor conector pins
|
7 |
|
|
ENTITY VGA_SYNC IS
|
8 |
|
|
PORT( clock_25Mhz : IN STD_LOGIC;
|
9 |
|
|
red, green, blue : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
|
10 |
|
|
red_out, green_out, blue_out : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
|
11 |
|
|
horiz_sync_out, vert_sync_out,
|
12 |
|
|
video_on, pixel_clock : OUT STD_LOGIC;
|
13 |
|
|
pixel_row, pixel_column : OUT STD_LOGIC_VECTOR(9 DOWNTO 0));
|
14 |
|
|
END VGA_SYNC;
|
15 |
|
|
ARCHITECTURE a OF VGA_SYNC IS
|
16 |
|
|
SIGNAL horiz_sync, vert_sync : STD_LOGIC;
|
17 |
|
|
SIGNAL video_on_int, video_on_v, video_on_h : STD_LOGIC;
|
18 |
|
|
SIGNAL h_count, v_count :STD_LOGIC_VECTOR(9 DOWNTO 0);
|
19 |
|
|
--
|
20 |
|
|
-- To select a different screen resolution, clock rate, and refresh rate
|
21 |
|
|
-- pick a set of new video timing constant values from table at end of code section
|
22 |
|
|
-- enter eight new sync timing constants below and
|
23 |
|
|
-- adjust PLL frequency output to pixel clock rate from table
|
24 |
|
|
-- using MegaWizard to edit video_PLL.vhd
|
25 |
|
|
-- Horizontal Timing Constants
|
26 |
|
|
CONSTANT H_pixels_across: Natural := 640;
|
27 |
|
|
CONSTANT H_sync_low: Natural := 664;
|
28 |
|
|
CONSTANT H_sync_high: Natural := 760;
|
29 |
|
|
CONSTANT H_end_count: Natural := 800;
|
30 |
|
|
-- Vertical Timing Constants
|
31 |
|
|
CONSTANT V_pixels_down: Natural := 480;
|
32 |
|
|
CONSTANT V_sync_low: Natural := 491;
|
33 |
|
|
CONSTANT V_sync_high: Natural := 493;
|
34 |
|
|
CONSTANT V_end_count: Natural := 525;
|
35 |
|
|
|
36 |
|
|
BEGIN
|
37 |
|
|
|
38 |
|
|
-- video_on is high only when RGB pixel data is being displayed
|
39 |
|
|
-- used to blank color signals at screen edges during retrace
|
40 |
|
|
video_on_int <= video_on_H AND video_on_V;
|
41 |
|
|
-- output pixel clock and video on for external user logic
|
42 |
|
|
pixel_clock <= clock_25Mhz;
|
43 |
|
|
video_on <= video_on_int;
|
44 |
|
|
|
45 |
|
|
PROCESS
|
46 |
|
|
BEGIN
|
47 |
|
|
WAIT UNTIL(clock_25Mhz'EVENT) AND (clock_25Mhz='1');
|
48 |
|
|
|
49 |
|
|
--Generate Horizontal and Vertical Timing Signals for Video Signal
|
50 |
|
|
-- H_count counts pixels (#pixels across + extra time for sync signals)
|
51 |
|
|
--
|
52 |
|
|
-- Horiz_sync ------------------------------------__________--------
|
53 |
|
|
-- H_count 0 #pixels sync low end
|
54 |
|
|
--
|
55 |
|
|
IF (h_count = H_end_count) THEN
|
56 |
|
|
h_count <= "0000000000";
|
57 |
|
|
ELSE
|
58 |
|
|
h_count <= h_count + 1;
|
59 |
|
|
END IF;
|
60 |
|
|
|
61 |
|
|
--Generate Horizontal Sync Signal using H_count
|
62 |
|
|
IF (h_count <= H_sync_high) AND (h_count >= H_sync_low) THEN
|
63 |
|
|
horiz_sync <= '0';
|
64 |
|
|
ELSE
|
65 |
|
|
horiz_sync <= '1';
|
66 |
|
|
END IF;
|
67 |
|
|
|
68 |
|
|
--V_count counts rows of pixels (#pixel rows down + extra time for V sync signal)
|
69 |
|
|
--
|
70 |
|
|
-- Vert_sync -----------------------------------------------_______------------
|
71 |
|
|
-- V_count 0 last pixel row V sync low end
|
72 |
|
|
--
|
73 |
|
|
IF (v_count >= V_end_count) AND (h_count >= H_sync_low) THEN
|
74 |
|
|
v_count <= "0000000000";
|
75 |
|
|
ELSIF (h_count = H_sync_low) THEN
|
76 |
|
|
v_count <= v_count + 1;
|
77 |
|
|
END IF;
|
78 |
|
|
|
79 |
|
|
-- Generate Vertical Sync Signal using V_count
|
80 |
|
|
IF (v_count <= V_sync_high) AND (v_count >= V_sync_low) THEN
|
81 |
|
|
vert_sync <= '0';
|
82 |
|
|
ELSE
|
83 |
|
|
vert_sync <= '1';
|
84 |
|
|
END IF;
|
85 |
|
|
|
86 |
|
|
-- Generate Video on Screen Signals for Pixel Data
|
87 |
|
|
-- Video on = 1 indicates pixel are being displayed
|
88 |
|
|
-- Video on = 0 retrace - user logic can update pixel
|
89 |
|
|
-- memory without needing to read memory for display
|
90 |
|
|
IF (h_count < H_pixels_across) THEN
|
91 |
|
|
video_on_h <= '1';
|
92 |
|
|
pixel_column <= h_count;
|
93 |
|
|
ELSE
|
94 |
|
|
video_on_h <= '0';
|
95 |
|
|
END IF;
|
96 |
|
|
|
97 |
|
|
IF (v_count <= V_pixels_down) THEN
|
98 |
|
|
video_on_v <= '1';
|
99 |
|
|
pixel_row <= v_count;
|
100 |
|
|
ELSE
|
101 |
|
|
video_on_v <= '0';
|
102 |
|
|
END IF;
|
103 |
|
|
|
104 |
|
|
-- Put all video signals through DFFs to elminate any small timing delays that cause a blurry image
|
105 |
|
|
horiz_sync_out <= horiz_sync;
|
106 |
|
|
vert_sync_out <= vert_sync;
|
107 |
|
|
|
108 |
|
|
red_out <= red AND video_on_int & video_on_int & video_on_int & video_on_int;
|
109 |
|
|
green_out <= green AND video_on_int & video_on_int & video_on_int & video_on_int;
|
110 |
|
|
blue_out <= blue AND video_on_int & video_on_int & video_on_int & video_on_int;
|
111 |
|
|
|
112 |
|
|
END PROCESS;
|
113 |
|
|
END a;
|
114 |
|
|
--
|
115 |
|
|
-- Common Video Modes - pixel clock and sync counter values
|
116 |
|
|
--
|
117 |
|
|
-- Mode Refresh Hor. Sync Pixel clock Interlaced? VESA?
|
118 |
|
|
-- ------------------------------------------------------------
|
119 |
|
|
-- 640x480 60Hz 31.5khz 25.175Mhz No No
|
120 |
|
|
-- 640x480 63Hz 32.8khz 28.322Mhz No No
|
121 |
|
|
-- 640x480 70Hz 36.5khz 31.5Mhz No No
|
122 |
|
|
-- 640x480 72Hz 37.9khz 31.5Mhz No Yes
|
123 |
|
|
-- 800x600 56Hz 35.1khz 36.0Mhz No Yes
|
124 |
|
|
-- 800x600 56Hz 35.4khz 36.0Mhz No No
|
125 |
|
|
-- 800x600 60Hz 37.9khz 40.0Mhz No Yes
|
126 |
|
|
-- 800x600 60Hz 37.9khz 40.0Mhz No No
|
127 |
|
|
-- 800x600 72Hz 48.0khz 50.0Mhz No Yes
|
128 |
|
|
-- 1024x768 60Hz 48.4khz 65.0Mhz No Yes
|
129 |
|
|
-- 1024x768 60Hz 48.4khz 62.0Mhz No No
|
130 |
|
|
-- 1024x768 70Hz 56.5khz 75.0Mhz No Yes
|
131 |
|
|
-- 1024x768 70Hz 56.25khz 72.0Mhz No No
|
132 |
|
|
-- 1024x768 76Hz 62.5khz 85.0Mhz No No
|
133 |
|
|
-- 1280x1024 59Hz 63.6khz 110.0Mhz No No
|
134 |
|
|
-- 1280x1024 61Hz 64.24khz 110.0Mhz No No
|
135 |
|
|
-- 1280x1024 74Hz 78.85khz 135.0Mhz No No
|
136 |
|
|
--
|
137 |
|
|
-- Pixel clock within 5% works on most monitors.
|
138 |
|
|
-- Faster clocks produce higher refresh rates at the same resolution on
|
139 |
|
|
-- most new monitors up to the maximum rate.
|
140 |
|
|
-- Some older monitors may not support higher refresh rates
|
141 |
|
|
-- or may only sync at specific refresh rates - VESA modes most common.
|
142 |
|
|
-- Pixel clock within 5% works on most old monitors.
|
143 |
|
|
-- Refresh rates below 60Hz will have some flicker.
|
144 |
|
|
-- Bad values such as very high refresh rates may damage some monitors
|
145 |
|
|
-- that do not support faster refreseh rates - check monitor specs.
|
146 |
|
|
--
|
147 |
|
|
-- Small adjustments to the sync low count ranges can be used to move
|
148 |
|
|
-- video image left, right (H), down or up (V) on the monitor
|
149 |
|
|
--
|
150 |
|
|
--
|
151 |
|
|
-- 640x480@60Hz Non-Interlaced mode
|
152 |
|
|
-- Horizontal Sync = 31.5kHz
|
153 |
|
|
-- Timing: H=(0.95us, 3.81us, 1.59us), V=(0.35ms, 0.064ms, 1.02ms)
|
154 |
|
|
--
|
155 |
|
|
-- clock horizontal timing vertical timing flags
|
156 |
|
|
-- Mhz pix.col low high end pix.rows low high end
|
157 |
|
|
--640x480 25.175 640 664 760 800 480 491 493 525
|
158 |
|
|
-- <-> <->
|
159 |
|
|
-- sync pulses: Horiz----------___------ Vert-----------___-------
|
160 |
|
|
--
|
161 |
|
|
-- Alternate 640x480@60Hz Non-Interlaced mode
|
162 |
|
|
-- Horizontal Sync = 31.5kHz
|
163 |
|
|
-- Timing: H=(1.27us, 3.81us, 1.27us) V=(0.32ms, 0.06ms, 1.05ms)
|
164 |
|
|
--
|
165 |
|
|
-- name clock horizontal timing vertical timing flags
|
166 |
|
|
--640x480 25.175 640 672 768 800 480 490 492 525
|
167 |
|
|
--
|
168 |
|
|
--
|
169 |
|
|
-- 640x480@63Hz Non-Interlaced mode (non-standard)
|
170 |
|
|
-- Horizontal Sync = 32.8kHz
|
171 |
|
|
-- Timing: H=(1.41us, 1.41us, 5.08us) V=(0.24ms, 0.092ms, 0.92ms)
|
172 |
|
|
--
|
173 |
|
|
-- name clock horizontal timing vertical timing flags
|
174 |
|
|
--640x480 28.322 640 680 720 864 480 488 491 521
|
175 |
|
|
--
|
176 |
|
|
--
|
177 |
|
|
-- 640x480@70Hz Non-Interlaced mode (non-standard)
|
178 |
|
|
-- Horizontal Sync = 36.5kHz
|
179 |
|
|
-- Timing: H=(1.27us, 1.27us, 4.57us) V=(0.22ms, 0.082ms, 0.82ms)
|
180 |
|
|
--
|
181 |
|
|
-- name clock horizontal timing vertical timing flags
|
182 |
|
|
--640x480 31.5 640 680 720 864 480 488 491 521
|
183 |
|
|
--
|
184 |
|
|
--
|
185 |
|
|
-- VESA 640x480@72Hz Non-Interlaced mode
|
186 |
|
|
-- Horizontal Sync = 37.9kHz
|
187 |
|
|
-- Timing: H=(0.76us, 1.27us, 4.06us) V=(0.24ms, 0.079ms, 0.74ms)
|
188 |
|
|
--
|
189 |
|
|
-- name clock horizontal timing vertical timing flags
|
190 |
|
|
--640x480 31.5 640 664 704 832 480 489 492 520
|
191 |
|
|
--
|
192 |
|
|
--
|
193 |
|
|
-- VESA 800x600@56Hz Non-Interlaced mode
|
194 |
|
|
-- Horizontal Sync = 35.1kHz
|
195 |
|
|
-- Timing: H=(0.67us, 2.00us, 3.56us) V=(0.03ms, 0.063ms, 0.70ms)
|
196 |
|
|
--
|
197 |
|
|
-- name clock horizontal timing vertical timing flags
|
198 |
|
|
--800x600 36 800 824 896 1024 600 601 603 625
|
199 |
|
|
--
|
200 |
|
|
--
|
201 |
|
|
-- Alternate 800x600@56Hz Non-Interlaced mode
|
202 |
|
|
-- Horizontal Sync = 35.4kHz
|
203 |
|
|
-- Timing: H=(0.89us, 4.00us, 1.11us) V=(0.11ms, 0.057ms, 0.79ms)
|
204 |
|
|
--
|
205 |
|
|
-- name clock horizontal timing vertical timing flags
|
206 |
|
|
--800x600 36 800 832 976 1016 600 604 606 634
|
207 |
|
|
--
|
208 |
|
|
--
|
209 |
|
|
-- VESA 800x600@60Hz Non-Interlaced mode
|
210 |
|
|
-- Horizontal Sync = 37.9kHz
|
211 |
|
|
-- Timing: H=(1.00us, 3.20us, 2.20us) V=(0.03ms, 0.106ms, 0.61ms)
|
212 |
|
|
--
|
213 |
|
|
-- name clock horizontal timing vertical timing flags
|
214 |
|
|
--800x600 40 800 840 968 1056 600 601 605 628 +hsync +vsync
|
215 |
|
|
--
|
216 |
|
|
--
|
217 |
|
|
-- Alternate 800x600@60Hz Non-Interlaced mode
|
218 |
|
|
-- Horizontal Sync = 37.9kHz
|
219 |
|
|
-- Timing: H=(1.20us, 3.80us, 1.40us) V=(0.13ms, 0.053ms, 0.69ms)
|
220 |
|
|
--
|
221 |
|
|
-- name clock horizontal timing vertical timing flags
|
222 |
|
|
--800x600 40 800 848 1000 1056 600 605 607 633
|
223 |
|
|
--
|
224 |
|
|
--
|
225 |
|
|
-- VESA 800x600@72Hz Non-Interlaced mode
|
226 |
|
|
-- Horizontal Sync = 48kHz
|
227 |
|
|
-- Timing: H=(1.12us, 2.40us, 1.28us) V=(0.77ms, 0.13ms, 0.48ms)
|
228 |
|
|
--
|
229 |
|
|
-- name clock horizontal timing vertical timing flags
|
230 |
|
|
--800x600 50 800 856 976 1040 600 637 643 666 +hsync +vsync
|
231 |
|
|
--
|
232 |
|
|
--
|
233 |
|
|
-- VESA 1024x768@60Hz Non-Interlaced mode
|
234 |
|
|
-- Horizontal Sync = 48.4kHz
|
235 |
|
|
-- Timing: H=(0.12us, 2.22us, 2.58us) V=(0.06ms, 0.12ms, 0.60ms)
|
236 |
|
|
--
|
237 |
|
|
-- name clock horizontal timing vertical timing flags
|
238 |
|
|
--1024x768 65 1024 1032 1176 1344 768 771 777 806 -hsync -vsync
|
239 |
|
|
--
|
240 |
|
|
--
|
241 |
|
|
-- 1024x768@60Hz Non-Interlaced mode (non-standard dot-clock)
|
242 |
|
|
-- Horizontal Sync = 48.4kHz
|
243 |
|
|
-- Timing: H=(0.65us, 2.84us, 0.65us) V=(0.12ms, 0.041ms, 0.66ms)
|
244 |
|
|
--
|
245 |
|
|
-- name clock horizontal timing vertical timing flags
|
246 |
|
|
--1024x768 62 1024 1064 1240 1280 768 774 776 808
|
247 |
|
|
--
|
248 |
|
|
--
|
249 |
|
|
-- VESA 1024x768@70Hz Non-Interlaced mode
|
250 |
|
|
-- Horizontal Sync=56.5kHz
|
251 |
|
|
-- Timing: H=(0.32us, 1.81us, 1.92us) V=(0.05ms, 0.14ms, 0.51ms)
|
252 |
|
|
--
|
253 |
|
|
-- name clock horizontal timing vertical timing flags
|
254 |
|
|
--1024x768 75 1024 1048 1184 1328 768 771 777 806 -hsync -vsync
|
255 |
|
|
--
|
256 |
|
|
--
|
257 |
|
|
-- 1024x768@70Hz Non-Interlaced mode (non-standard dot-clock)
|
258 |
|
|
-- Horizontal Sync=56.25kHz
|
259 |
|
|
-- Timing: H=(0.44us, 1.89us, 1.22us) V=(0.036ms, 0.11ms, 0.53ms)
|
260 |
|
|
--
|
261 |
|
|
-- name clock horizontal timing vertical timing flags
|
262 |
|
|
--1024x768 72 1024 1056 1192 1280 768 770 776 806 -hsync -vsync
|
263 |
|
|
--
|
264 |
|
|
--
|
265 |
|
|
-- 1024x768@76Hz Non-Interlaced mode
|
266 |
|
|
-- Horizontal Sync=62.5kHz
|
267 |
|
|
-- Timing: H=(0.09us, 1.41us, 2.45us) V=(0.09ms, 0.048ms, 0.62ms)
|
268 |
|
|
--
|
269 |
|
|
-- name clock horizontal timing vertical timing flags
|
270 |
|
|
--1024x768 85 1024 1032 1152 1360 768 784 787 823
|
271 |
|
|
--
|
272 |
|
|
--
|
273 |
|
|
-- 1280x1024@59Hz Non-Interlaced mode (non-standard)
|
274 |
|
|
-- Horizontal Sync=63.6kHz
|
275 |
|
|
-- Timing: H=(0.36us, 1.45us, 2.25us) V=(0.08ms, 0.11ms, 0.65ms)
|
276 |
|
|
--
|
277 |
|
|
-- name clock horizontal timing vertical timing flags
|
278 |
|
|
--1280x1024 110 1280 1320 1480 1728 1024 1029 1036 1077
|
279 |
|
|
--
|
280 |
|
|
--
|
281 |
|
|
-- 1280x1024@61Hz, Non-Interlaced mode
|
282 |
|
|
-- Horizontal Sync=64.25kHz
|
283 |
|
|
-- Timing: H=(0.44us, 1.67us, 1.82us) V=(0.02ms, 0.05ms, 0.41ms)
|
284 |
|
|
--
|
285 |
|
|
-- name clock horizontal timing vertical timing flags
|
286 |
|
|
--1280x1024 110 1280 1328 1512 1712 1024 1025 1028 1054
|
287 |
|
|
--
|
288 |
|
|
--
|
289 |
|
|
-- 1280x1024@74Hz, Non-Interlaced mode
|
290 |
|
|
-- Horizontal Sync=78.85kHz
|
291 |
|
|
-- Timing: H=(0.24us, 1.07us, 1.90us) V=(0.04ms, 0.04ms, 0.43ms)
|
292 |
|
|
--
|
293 |
|
|
-- name clock horizontal timing vertical timing flags
|
294 |
|
|
--1280x1024 135 1280 1312 1456 1712 1024 1027 1030 1064
|
295 |
|
|
--
|
296 |
|
|
-- VGA female connector: 15 pin small "D" connector
|
297 |
|
|
-- _________________________
|
298 |
|
|
-- \ 5 4 3 2 1 /
|
299 |
|
|
-- \ 10 X 8 7 6 /
|
300 |
|
|
-- \ 15 14 13 12 11 /
|
301 |
|
|
-- \_________________/
|
302 |
|
|
-- Signal Name Pin Number Notes
|
303 |
|
|
-- -----------------------------------------------------------------------
|
304 |
|
|
-- RED video 1 Analog signal, around 0.7 volt, peak-to-peak 75 ohm
|
305 |
|
|
-- GREEN video 2 Analog signal, sround 0.7 volt, peak-to-peak 75 ohm
|
306 |
|
|
-- BLUE video 3 Analog signal, around 0.7 volt, peak-to-peak 75 ohm
|
307 |
|
|
-- Monitor ID #2 4
|
308 |
|
|
-- Digital Ground 5 Ground for the video system.
|
309 |
|
|
-- RED ground 6 \ The RGB color video signals each have a separate
|
310 |
|
|
-- GREEN ground 7 | ground connection.
|
311 |
|
|
-- BLUE ground 8 /
|
312 |
|
|
-- KEY 9 (X = Not present)
|
313 |
|
|
-- SYNC ground 10 TTL return for the SYNC lines.
|
314 |
|
|
-- Monitor ID #0 11
|
315 |
|
|
-- Monitor ID #1 12
|
316 |
|
|
-- Horizontal Sync 13 Digital levels (0 to 5 volts, TTL output)
|
317 |
|
|
-- Vertical Sync 14 Digital levels (0 to 5 volts, TTL output)
|
318 |
|
|
-- Not Connected 15 (Not used)
|
319 |
|
|
--
|