OpenCores
URL https://opencores.org/ocsvn/z80soc/z80soc/trunk

Subversion Repositories z80soc

[/] [z80soc/] [tags/] [z80soc05c/] [S3E/] [vga_sync.vhd] - Blame information for rev 11

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.