2
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ It depends on how your VGA controller is working. If you have a frame buffer, you can have a character lookup table which maps the character values to pixel bitmaps and then plot the pixels for each character. \$\endgroup\$ Commented Mar 26, 2016 at 19:00

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ A less memory-intensive version would be a line pixel buffer, with the buffer update triggered by the horizontal sync. \$\endgroup\$ Commented Mar 26, 2016 at 21:31
  • \$\begingroup\$ Not sure how that would be less memory. The line buffer would still have to be filled from somewhere on every horizontal sync. \$\endgroup\$ Commented Mar 26, 2016 at 21:53
  • \$\begingroup\$ The pixels would be provided (most likely) from a pixel lookup table, and this table would only need to contain one of each possible character (64 would probably do, or 256 at most), rather than the 2000 needed for a standard 80x25 screen. \$\endgroup\$ Commented Mar 26, 2016 at 21:59
  • \$\begingroup\$ That's basically what I outlined, no? You have one byte per character location (80x25 chars would be 2000 bytes, this ought to fit in a block RAM), then a table of bitmaps that is indexed by the character and pixel row. To output a scan line, iterate over the characters in the corresponding row in the character buffer, use that to get the correct row the corresponding bitmap, output that while fetching the next character. Not sure how a line buffer fits in here. Unless I am misunderstanding what you mean by line buffer. \$\endgroup\$ Commented Mar 26, 2016 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.