16 Color VGA
by
Tetris Team
KhernYang Twang
Feng Gui
Taozhi Peng

Introduction

        In this application note, we are discussing how to create more colors for the VGA. To simplify the explanation, we are going to use 16 colors only. Currently, people had been using 8 colors to display their programs and it does look ugly at times. Hopefully this application note can help others to create a more colorful and vivid program to display onto the monitor.
 

Design

        Before discussing the techniques of creating 16 colors, we have to understand how the VGA monitor works. The monitor has 5 input pins. They are horizontal sync, vertical sync, red, green, and blue. We are only concern with the red, green, and blue pins. When logic '1' is applied to one of the pins in VHDL, it refers to applying +5V to the pin. And logic '0' refers to 0V. The table below shows the 8 color that can be displayed on the VGA.
 
Color
Red Pin
Green Pin
Blue Pin
Black
0
0
0
Blue
0
0
1
Green
0
1
0
Cyan
0
1
1
Red
1
0
0
Violet
1
0
1
Yellow
1
1
0
White
1
1
1

We noticed that the color changes when a different voltage is applied to the pins. For example, the intensity for the red color varies depending on the voltage applied to the red pin. The higher the voltage, the brighter the color will be. This discovery enables us to create a wider variety color palette.

        Now we procede with the explaination of creating another 8 colors. The extra 8 colors are created by substituting 0V as logic '0' to +2.5V. MaxPlus2 does not support any variation of voltage to the output pins, therefore we have to use Pulse Width Modulation. Pulse Width Modulation is alternating a signal at regular interval to create the effects of variating voltage. The +2.5V is created by alternating a signal at 50% duty cycle. A good example of 50% duty cycle signal is the clock signal. The graph for generating +2.5V is shown below:

The table below shows all 16 colors.

( Clock gives a 50% duty cycle that modulate a +2.5V)
Color
Red
Green
Blue
Black
0
0
0
Blue
0
0
1
Green
0
1
0
Cyan
0
1
1
Red
1
0
0
Violet
1
0
1
Yellow
1
1
0
White
1
1
1
Grey
Clock
Clock
Clock
Intense Blue
Clock
Clock
1
Intense Green
Clock
1
Clock
Intense Cyan
Clock
1
1
Intense Red
1
Clock
Clock
Intense Violet
1
Clock
1
Intense Yellow
1
1
Clock
Intense White
1
1
1

        We have created another set of color palette. The colors that use +2.5V as logic '0' are called intense colors. They are slightly brighter than the colors that use 0V for logic '0'. Although the differences are not much, it is noticeable. The only color that is similar is white and intense white.

        A wider set of color can be created however due to the limitation of the clock, we can only display 16 colors in 640*480 resolution at 60fps (frame per second). If we reduce the resolution or the fps, more clock cycle can be used to refresh each pixel. Therefore we can modulate more colors signal at different interval to create different level of voltage.

        The limitation is caused by generating a signal at regular interval. The reference signal to use generate the regulating signal is the clock. Any signal faster than the clock is not possible on the UP1 board unless a faster external clock crystal is connected to it.

Test Program

        We have developed a VHDL code that cycles through the 16 set of colors. The equipments needed are a Altera UP1 board and a VGA monitor. To cycle the colors, we need a push button to increment to each color. The pin assignment is given below
 
Description
Signal Name
Pin Number
Horizontal Sync
Horiz_sync
240
Vertical Sync
Vert_sync
239
Red
Red
236
Green
Green
237
Blue
Blue
238
Push Button
button
28
Clock
Clock
91

Contact Us

If you have any enquires, please contact Khern at ktwang@ee.ualberta.ca .