VGA Controller PDF
VGA Controller PDF
SuperPixels
VgaCon contains a memory block for storing the colour of each pixel to be drawn on the screen.
However, the FLEX10K70 does not have enough on-chip memory to save a value for each monitor
pixel. A simple solution to this problem is to map a large block of monitor pixels to a single
memory location. In the monitor diagram below, a 10x8 pixel block (called a SuperPixel) is
mapped into a single location in memory. This scheme produces a virtual resolution
of 64x60SuperPixels. VgaCon actually stores a grid of 64x64 SuperPixels in its memory. However
the last four rows are not displayed.
VgaCon Interface
The row, column, and colour signals define the coordinates and colour of the SuperPixel that you
wish to be placed on the screen. Set the write_request signal to '1' to write the SuperPixel into the
VGA controller memory. However, the controller is not always able to write the pixel immediately. It
indicates this with the write_allowed signal. You must wait until the write_allowed signal is '1' for the
write to complete. When write_allowed changes to '1' or if it is already at '1', the SuperPixel is written
on the next positive clock edge. At that point, you can return write_request to '0'. Alternatively, you
can keep write_request at '1' to write a new SuperPixel during the next clock cycle. You can write a
new pixel every clock cycle until write_allowed is '0'.
NOTE: With a 25 MHz clock, it will take between 25 and 30 microseconds until write_allowed is '1'
for the first time. When write_allowed returns to '0' it will take a similar amount of time for it to be '1'
again. So when simulating with a 25 MHz clock, be sure to set the simulation end time to at least 30
microseconds to see write_allowed change.
Port/Param Description
clock
This port must be connected to the clock pin in the top-level design. The
VGA controller requires that the clock pin is connected to the onboard
clock on the UP2 board for correct functionality. This can be
accomplished by assigning the clock pin to pin 91 on the FLEX10K70.
resetn
The resetn port should connect to an active low signal that forces the
controller back to its initial state. Typically this port should be connected
to a resetn pin in the top-level design.
row[5:0]
column[5:0]
colour[2:0]
Black
colour = "001"
Bright Green
write_request
write_allowed
done_screen
This signal indicates that the entire screen has been drawn. The
controller asserts this signal high for one clock cycle every 16.6ms. This
signal is useful for timing and delay purposes. The demo program below
uses this signal to flash a diagonal line on the screen approximately
every half-second.
hsync
vsync
data_r
data_g
data_b
ramfile
Produces the horizontal and vertical sync signals for the VGA monitor.
These ports must connect to top-level output pins that must be assigned
to pins 240 and 239 respectively on the FLEX10K70.
Produces the red, green, and blue signals for the VGA monitor
corresponding to the contents of the VGA controller RAM. Again, these
ports must connect to top-level output pins which are assigned to pins
236, 237, and 238 respectively on the FLEX10K70.
This is a parameter which should be assigned to a MIF file that contains
the initial contents of the controller RAM memory. It allows one to easily
create an initial picture that is displayed on the screen. A utility is
provided below which can convert standard graphic files to MIF format.
VGA Demo
Instructions:
1.
2.
3.
4.
5.
Save the 2-colour demo or the 8-colour demo to your home directory.
Double-click and downloaded file to create a directory that contains the files listed below.
Open the project file (vga_demo.qpf) in Quartus.
Compile the design.
Download the design to the FLEX10K70 on the UP2 board. The programming switch on the
board must be in the up position. The demo displays a mailbox in the background. Push the
button labelled FLEX_PB2 to turn on the flashing diagonal line.
File
Description
vga_demo.qpf
vga_demo.qsf
Contains the PIN and DEVICE assignments for the VGA demo.
vgacon.vhd
vga_demo.v
vga_demo.mif
Initial RAM contents for the VGA controller. This contains the picture of
the mailbox that is displayed initially by the demo.
pbmtomif.c
Converts a graphics file in PBM (ASCII) format to a MIF file that can be
loaded into the VGA controller RAM memory. This program was used to
convert a PBM graphic of the mailbox into the demo MIF file. It is
particularly useful if you wish to create an initial background
for applications such as tic-tac-toe game. You can draw the background
with any graphic editor, shrink it to a 64x64 resolution and save it in PBM
format. xv is a graphical UNIX program that will allow one to convert
common graphic formats such as GIF, JPEG, and BMP to PBM.
Instructions for compiling and running PBMtoMIF are in this source file.
once in a parallel scheme. This colour information for each pixel is provided by a RGB (Red,
Green, Blue) triplet. Three analog signals are used to represent relative amounts of red, green, and
blue that compose the colour. However, the UP2 board produces digital signals. Thus, the controller
is only able to provide full intensity or turn off for each of the RGB components. The VGA monitor
does not save any of the pixels written to it so the pixels must be continuously written to the
monitor for the image to remain stable. The protocol for the transmission is shown below.
Horizontal Cycle
The horizontal cycle is part of the VGA standard and defines a method for setting the colours of all
the pixels in a particular row. The colour values for the 640 pixels are sent out on each of the first
640 clock cyles. The colour values are then forced to zero (black), while the hsync signal is asserted
low to tell the monitor to move to the next horizontal row of pixels. The exact timing between these
signals is defined in the VHDL source code for the VGA controller. The VGA controller only
allows your requests to write pixels while the colour signals are forced to zero. At all other times, it
is reading from memory and it cannot write to the memory at the same time.
Vertical Cycle
The vertical cycle allows the monitor to synchronize which rows are being written by the horizontal
cycles. 480 horizontal cycles are produced during the first stage of the vertical cycle. In the next
stage, the colour values are again forced to zero (black), while the vsync signal is asserted. The
vsync signal tells the monitor to go back to the (0,0) pixel. The data that follows starts with the first
horizontal row of pixels.