Build A Vga Monitor Controller
Build A Vga Monitor Controller
always a challenge. But things are getting Figure 1 shows that the scan-
easier. I recently took another look at the ning starts from row 0, column 0
Horizontal
VGA video signal and realized that I in the top left corner of the retrace
could build a VGA monitor controller screen and moves to the right VGA Monitor 480 pixels
screen Horizontal per column
with just two binary counters, four flip- until it reaches the last column. scan
flops, and 11 AND gates. Yes, that’s When the scan reaches the end Vertical
retrace
right, just two 10-bit binary up counters, of a row, it retraces to the begin-
four SR flip-flops, and 11 AND gates! ning of the next row. When it
Now, of course, this isn’t a replacement reaches the last pixel in the bot- Row 479
for your high-end graphics card in your tom right corner of the screen,
Figure 1—Scanning starts from row 0, column 0 and moves to the
PC, nor is it even a low-end video card, it retraces back to the top left right and down until reaching row 479, column 639.
but it’s capable of displaying images on a corner and repeats the scanning
standard VGA monitor. Most important- process. In order to reduce flick-
ly, this simple VGA monitor controller er on the screen, the entire screen must chronization, and vertical synchroniza-
circuit allows you to easily understand be scanned 60 times per second (or more). tion. The three color signals, collectively
how the VGA monitor works and how to During the horizontal and the vertical referred to as the RGB signal, control the
control it. When I presented this to my retraces, all the pixels are turned off. color of a pixel at a given location on
introductory digital logic design class, the screen. They are analog signals with
the students were totally amazed that it FIVE CONTROL SIGNALS voltages ranging from 0 to 0.7 V.
could be this simple. The VGA monitor is controlled by five Different color intensities are obtained
signals: red, green, blue, horizontal syn- by varying the voltage. For simplicity,
PIXELS ON SCREEN your circuit could treat these
To begin, you need to under- a) b)
three color signals as digital
stand how a VGA monitor signals, so you could just turn
works. The monitor screen for each one on or off. As Figure
a standard VGA format con- 2a demonstrates, such a cir-
tains 640 columns by 480 rows cuit would be capable of dis-
of picture elements called pix- playing only eight colors (23 =
els (see Figure 1). An image is 8). Figure 2b shows a slightly
displayed on the screen by enhanced digital-to-analog
turning on and off individual converter circuit that can
pixels. Turning on one pixel display up to 64 colors (26).
doesn’t represent much, but The horizontal and verti-
combining numerous pixels cal synchronization signals
generates an image. The moni- are used to control the tim-
tor continuously scans through ing of the scan rate. Unlike
the entire screen, rapidly turn- the three analog RGB sig-
ing individual pixels on and nals, these two sync signals
off. Although pixels are turned are digital signals. In other
on one at a time, you get the words, they take on either a
impression that all the pix- logic 0 or a logic 1 value.
Figure 2—D/A converter circuits drive the RGB signals.You can use them to produce
els are on because the moni- eight colors (a) or 64 colors (b). The VGA monitor controller controls the digital signals. The horizontal synchro-
tor scans so quickly. This is The analog signals are connected to the VGA monitor via a 15-pin D-Sub connector. nization signal determines
a) “0000000000” b)
“0000000000”
1 COUNT D9–0
LOAD 10-bit Up counter 1
Clear CLEAR COUNT D9–0
25.175-MHz Clock CLOCK with load LOAD 10-bit Up counter
Q9–0 CLEAR CLEAR
ROLL_OVER CLOCK with load
10 640 = 1010000000 Q9–0
(H_CNT = D)
10 480 = 0111100000
(V_CNT = R)
660 = 1010010100
(H_CNT = D+E)
494 = 0111101110
(V_CNT = R+S)
755 = 1011110011
(H_CNT= D+E+B)
496 = 0111110000
(V_CNT = R+S+P)
800 = 1100100000
(H_CNT= D+E+B+C)
528 = 1000010000
ROLL _OVER (V_CNT = R+S+P+Q)
COLUMN_OUT
10
ROW_OUT
10
c) d)
S Q H_SYNC_OUT
HCOUNT (H_CNT = D)
CLK
25.175-MHz Clock CLOCK (H_CNT = D+E) RESET V_SYNC_OUT
CLEAR (H_CNT = D+E+B) R
CLEAR 25.175-MHz CLOCK H_SYNC _OUT
(H_CNT = D+E+B=C) RED RED_OUT
H_DATA_ON
Q9–0 ROLL _OVER S Q GREEN VGS Monitor GREEN_OUT
CLK BLUE controller
BLUE_OUT
R
CLEAR COLUMN_OUT9–0
ROLL _OVER9–0
VCOUNT
(V_CNT = R) S Q V_SYNC_OUT
CLOCK
(V_CNT = R+S) CLK
CLEAR
(V_CNT = R+S+P) R
(V_CNT = R+S+P+Q) CLEAR
Q9–0
V_DATA_ON
S Q
CLK
R
CLEAR
RESET
RED_OUT
RED
GREEN GREEN_OUT
BLUE_OUT
BLUE
COLUMN_OUT
10
ROW_OUT
10
Figure 5—The VGA monitor controller circuit contains the following: a horizontal counter circuit for generating the horizontal sync and column count signals (a); a vertical count-
er circuit for generating the vertical sync and row count signals (b); a complete VGA controller circuit (c); and a logic symbol for the controller circuit (d).