Electronic – Displaying Characters In Verilog With VGA

verilogvga

I'm taking a intro to ECE course as a CS student and for a final project we are to design a game coded in Verilog using the VGA display on a DE1-SoC board.

I decided to create a hangman game but I am stuck on how to display characters on the VGA screen. I've come up with three options: make the alphabet and underscores as images and upload them to the VGA display, use some sort of character buffer built in (I found info about that part online but I can't find any examples of using it) or just draw each character pixel by pixel.

The pixel by pixel way seems extremely complicated but at the same time, there are almost no resources that I could find about the other two methods. Can someone tell me which way would be the most efficient and easiest to work with for my game? We only really learned about displaying shapes in class but I'm not sure drawing each letter is the most efficient method.

Best Answer

Ultimately you will have to send pixel data to the display. There is no way around that; that's just how VGA works. The monitor at the other end only understands frames, the FPGA will need to generate complete frames at the correct rate. The simplest way to do this is to have a frame buffer that holds pixel data for the entire display. This generally will require more memory than the FPGA will have internally, so that means your frame buffer will have to sit on an external memory.

However, if what you intend to display has some structure, then you may not need a complete frame buffer. For example, if you want to make a text-only display, then all you need is a character buffer that indicates what character to display at every position on the display, each position corresponding to a character-sized box of pixels. Then you can build a 'mapping' between the characters in the buffer and the pixels on the display - a font buffer. To generate a line of video, pull characters from the corresponding row in the character buffer, use that to index the font buffer, and then display the pixels that correspond to the particular row in the selected characters. This would be a very simple text drawing pipeline. It is possible to do something similar with sprites as well so you can do basic graphics without requiring a complete frame buffer. Depending on the implementation, it can be more efficient to use a hardware sprite drawing engine since moving the sprite only involves updating the position in the drawing engine instead of rewriting all of the pixels that make up the sprite.