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

Subversion Repositories z80soc

[/] [z80soc/] [tags/] [z80soc05b/] [rtl/] [VHDL/] [vga_sync.vhd] - Blame information for rev 33

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

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

powered by: WebSVN 2.1.0

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