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