Design of a Simple VGA Controller in VHDL

Introduction: Design of a Simple VGA Controller in VHDL

About: Mitu Raj -- Just a Hobbyst and Learner -- Chip Designer -- Software Developer -- Physics and Mathematics Enthusiast

In this instructable we are gonna design a simple VGA Controller in RTL. VGA Controller is the digital circuit designed to drive VGA displays. It reads from Frame Buffer (VGA Memory) which represents the frame to be displayed, and generates necessary data and sync signals for display purpose.

Step 1: Interface of a VGA Controller

Following are the main interface signals in a VGA Controller

  • Pixel Clock or VGA Clock
  • HSYNC and VSYNC signals

For the VGA display chosen, you have to first calculate the frequency of Pixel Clock needed to drive it. It depends on 3 parameters: Total Horizontal Pixels, Total Vertical Pixels, Screen Refresh Rate.

Typically, F = THP * TVP * Refresh Rate

Find the documentation on pixel clock needed for various VGA displays, in the attached RAR.

HSYNC and VSYNC signals are generated from Pixel clock. The timing of HSYNC and VSYNC signals depend on number of parameters: Horizontal and Vertical Frontporch, Horizontal and Vertical Backporch, Horizontal and Vertical Display Pixels, Horizontal and Vertical Sync Pulse Widths and Polarities.

These parameters are standardized for a chosen VGA display. Find these documents in the attached RAR.

These parameters are configurable parameters in our VGA Controller IP.

Step 2: Integrating VGA Controller With a VGA Display

The figure shows how to integrate VGA Controller with a VGA display. You need two more components to complete the system:

  • Frame Buffer : Memory that holds the frame to be displayed.
  • Video DAC : DAC that converts RGB digital data and drives the VGA Display with RGB analog signals at appropriate voltage level.

One of the simplest and popular Video DACs is ADV7125. It is an 8-bit DAC that converts RGB digital words to 0-0.7 V analog signals and drive the VGA display.

Step 3: Frame Buffer Design

It is the memory that 'stores' the image to be displayed. It is typically a RAM or sometimes ROM. We will discuss how to design a frame buffer to represent an image. Frame buffer passes this digital info to a Video DAC on command from VGA Controller.

First we have to decide the pixel depth needed. It decides the quality of the image, the variety of colors a pixel can represent. For an 8-bit DAC, we need to represent the primary color components of a pixel: R, G, and B in 8 bits each. It means, a pixel is of 24-bit.

Each pixel is stored in a contiguous manner in Frame Buffer memory locations.

Suppose an image to be displayed is 800x600 pixels.

Therefore Frame Buffer needed is 800x600 = 480000 x 24 bits memory

Total size of the memory is 800x600x24 = 1400 kB approx.

If black and white image, 800x600x1 = 60 kB approx.

Block RAMs maybe used to represent a Frame Buffer in Xilinx FPGAs.

Step 4: Notes

  • Additional signals are needed on VGA Controller depending on the DAC chosen. I have used ADV7125.
  • Add cycle delays thru flip-flops on VSYNC and HSYNC before driving VGA display. This is because of DAC and Memory latencies. The pixel signals should be synchronised with HSYNC and VSYNC. In my case, it was 2 cycle delay.
  • If Frame Buffer of given size cannot be designed on FPGA due to block ram size limitation, use smaller memory to represent the image and simply edit the code to roll over the address on the available memory's boundary, rather than the full frame's boundary. This will replicate same image over and over along the whole screen. Another method is pixel scaling in which each pixel is replicated to show the entire image in full screen, in a lesser resolution. This can be done by tweaking address incrementation logic in the code.
  • The IP is completely portable across all FPGAs and is timing verified up to 100 MHz on Virtex-4 FPGA.

Step 5: Attached Files

The RAR contains:

  • VGA Controller code
  • PDFs of VGA standards.

Be the First to Share

    Recommendations

    • Battery Powered Contest

      Battery Powered Contest
    • Plywood Challenge

      Plywood Challenge
    • Plastic Contest

      Plastic Contest

    49 Discussions

    0
    apollinegruauxs4
    apollinegruauxs4

    5 weeks ago

    Hi , really interesting article ! I'm working on an frequency analyzer for a project , do you mind to send me the password to acces the files ? Thanks !
    apollinegruaux@yahoo.com
    Apolline :)

    0
    talher
    talher

    2 months ago

    Very interesting! Can I have the password, please?
    Thank you.

    0
    AmCoder
    AmCoder

    Reply 7 weeks ago

    ok

    0
    vasakpal
    vasakpal

    2 months ago

    Excellent tutorial. Can I have the password?

    0
    AmCoder
    AmCoder

    Reply 2 months ago

    sure

    0
    AmCoder
    AmCoder

    Reply 5 months ago

    done

    0
    gsauer75
    gsauer75

    Question 5 months ago

    Hello Mitu Raj,

    your article is very good and it's similar to my problem to show the video signal from a c-mos chip. Could you send me the password for the RAR-Archive so i can take look how you solve it.
    Thank you.
    e-mail: gordon.sauer@ruag.com

    0
    AmCoder
    AmCoder

    Reply 5 months ago

    done

    0
    petarpav
    petarpav

    Question 6 months ago

    Hello, could you please send me the password?

    0
    AmCoder
    AmCoder

    Reply 5 months ago

    sure

    0
    CsatlosA
    CsatlosA

    Question 7 months ago

    Can you send the password for the zip file, please? I have a project to do which is similar to yours?
    mail id is: csatlos_andrei27@yahoo.com

    0
    AmCoder
    AmCoder

    Reply 6 months ago

    done :)

    0
    Fawkees
    Fawkees

    Question 7 months ago

    Hey dude I have to do a similar projet rn, could you send me the password for the zip so I can take a look at it?
    would appreciate it :)
    mail is: kshetriae@gmail.com

    0
    AmCoder
    AmCoder

    Reply 7 months ago

    sure:)