The VGA controller handles the low-level details of communicating with a monitor over a VGA connector. The VGA controller is implemented in vga.v. It controls the DE2-115's video digital-to-analog converter, the Analog Devices ADV7123.
The VGA controller maintains a 2-dimensional array of color values in video memory. The width of the array is 640 (0-639), and the height of the array is 480 (0-479). Each value represents the color of a pixel: bits 23-16 specify the amount of red; bits 15-8 specify the amount of green; and bits 7-0 specify the amount of blue (this is known as true color). Because of the limited size of SRAM on the DE2-115 board, the E100 only uses the upper 5 bits of each red/green/blue value; the lower 3 bits of each red/green/blue value are ignored and will be read as 0.
Pixel coordinates are denoted as (x,y). The coordinate of the upper left pixel is (0,0); the coordinate of the lower right pixel is (639,479).
vga_command and vga_response implement the standard I/O protocol. The command parameters are vga_write, vga_x1, vga_y1, vga_x2, vga_y2, and vga_color_write.
If the E100 program sends a command with vga_write=1, this signifies that the program wants to set the color of a rectangle to vga_color_write. The upper-left corner of the rectangle is (vga_x1, vga_y1), and the lower-right corner of the rectangle is (vga_x2, vga_y2). vga_x1 must be less than or equal to vga_x2, and vga_y1 must be less than or equal to vga_y2.
If the E100 program sends a command with vga_write=0, this signifies that the program wants to read the color of the pixel at (vga_x1, vga_y1). In this case, the color of this pixel will be returned in the response parameter vga_color_read.
ase100 simulates the VGA controller accurately enough for you to test your device driver and to run assembly-language programs. Click the Save VGA button to save the contents of VGA memory to a file.
Many of your projects will display pictures on the VGA monitor. See this handout for help in creating these pictures in the E100 color format.
Write a device driver for the VGA controller that a program can call to write a pixel to the monitor at a specified (x,y) coordinate. Then, write a program that sends an array of color values to the VGA monitor. The color values should be stored in an array, with the length of the array specified by another variable. Write the color values in the array to the pixels in the top row of the VGA monitor. You may want to first set the monitor to be completely black, so you can see your array of colors more easily.
Optional: If you want an extra challenge, add a device driver function to read pixels from the video memory. Then write a test program that complements the color value for each pixel (use the not instruction) and updates the monitor display with the complemented color value for each pixel.