All content, diagrams, equations, html and css by Benj Carson. Hulk Logo by Jeff Mrochuk. Please send any questions, suggestions or other feedback to Benj Carson.
VGA monitors accept three analog colour signals in the range of 0 to 0.7V. While the UP1 boards have a built in VGA connection, the Nios boards do not. The authors are using Nios board for their project and are required to build their own VGA output hardware. This has it's advantages, since we are no longer limited to ugly "digital" VGA. Using a few more pins and a couple of resistors beautiful 8bpp (256 color) VGA output can be produced.
Typical 8bpp systems use a 3-3-2 bit distribution: 3 bits for red, 3 for green and 2 for blue. Other breakdowns are possible. This design is based on a 3.3V VDD which is available from the expansion headers on the Nios board. The schematic is shown below:
Each of the outputs, RED0-2, GREEN0-2 and BLUE0-1 originate from the chip and must pass through a 3.3V buffer before reaching this circuit.
For a single 3 bit colour the required digital to analog conversion should be:
Binary Value | Analog Value |
---|---|
000 | 0.0V |
001 | 0.1V |
010 | 0.2V |
011 | 0.3V |
100 | 0.4V |
101 | 0.5V |
110 | 0.6V |
111 | 0.7V |
The 100Ω resistor was chosen somewhat arbitrarily. It is half of the voltage divider formed by the other three resistors. If it is too small currents may exceed maximum ratings, and if it is too large the current may become disturbed by noise. Using the three cases when only one pin is active, the value of each resistor is determined using the following equations:
For the most significant bit:
Where Von is the analog voltage desired for the given binary value. For the next bit:
And for the last bit:
For 2 bit colour (i.e. blue), the desired conversion is:
Binary Value | Analog Value |
---|---|
00 | 0.0V |
01 | 0.233V |
10 | 0.466V |
11 | 0.7V |
The following two equations were used. For the MSB:
And for the last bit:
This method can be adapted to a 5V output expansion slot as well.