FPGA VGA for 6502: Brainstorming
Updated: Dec 9, 2021
I am currently brainstorming ways to add an FPGA-based VGA circuit to one of my 6502 builds. And... I have questions. :)
As part of my Ben Eater 6502+VGA build, I had the following breadboard build. On the breadboard build, the right side is a 6502 circuit, with the left side being a VGA circuit. The VGA output supports a whopping resolution of 100x64! :) I then designed a VGA PCB and replaced that portion of the breadboard solution. That then evolved into a PCB-based 6502 system.
If you're interested in what the current video output looks like, you can see it in the video posted in this blog post.
I now want to replace the existing VGA circuit with an FPGA-based VGA solution supporting a higher resolution (e.g., 1920x1080). The current VGA solution works by writing to "video memory" the color values for each pixel, with each pixel of the 100x64 resolution having 2 bits to represent each of the colors: red, green, and blue. See Let’s build a video card! | Ben Eater. In my 6502 code, I have implemented support to load images, write text, and draw lines and rectangles. I am hoping to implement a solution that allows pixel-level control and foundational elements such as text, shapes, and images via the FPGA.
My thought process so far is to use my Arty A7-100T with a VGA Pmod.
To get information from the 6502 to the FPGA, I can bit bang it or leverage my 6502 SPI circuit. Once information is at the FPGA (whether per-pixel data, text data, etc.), I'll need to process it; this will likely include storing the screen image/buffer to the DDR3 RAM on the Arty. The Arty can then constantly redraw the screen based on RAM contents, much like how it's being done on the 6502. I'm wondering the best way to manage this. What I am currently researching:
RAM access: I will need to utilize RAM for the video memory. From my research so far, utilizing the RAM on the Arty doesn't seem to be straightforward. Are there any good resources or recommendations for utilizing DDR3 RAM on the Arty? Example thread: How to use DDR3 on Xilinx Arty board? - FPGA - Digilent Forum (digilentinc.com).
VHDL code: I have reviewed the sample VGA solution from Digilent. It seems fairly straightforward; however, it's a VHDL-only solution. Are there MicroBlaze examples for VGA output available anywhere, and possibly a foundational text and graphics library? My current 6502 code can generate pixels, characters, lines, rectangles, and images, so I could leverage that, but I think it would be better to handle this in the FPGA. For example, rather than sending the individual pixel data for a line of text from the 6502 to the FPGA, I'd like to just send the text and screen location.
If I can get a working solution on the Arty A7, I then would like to migrate that solution to a Cmod A7. I might then spin a new 6502 PCB that includes the Cmod instead of the current VGA circuit.
Any and all suggestions / guidance are greatly appreciated! I will continue researching and will start testing some ideas this month. Thank you in advance!
I have DRAM read/writes working from MicroBlaze. It was much less painful than I was expecting. I have an initial approach for handling pixel position and color for the pixel. I still need to figure out how to access DRAM from VHDL.
I have VGA output working now, too. Outputting 1920x1080 @ 60Hz.
Next, I plan to use the FPGA UART and a Winforms app to test sending in text and drawing commands (and of course, I need to start building the text and graphics rendering support on the FPGA). Once that's all working, I'll replace the UART connectivity with connectivity to the 6502 VIA through a couple of LVLSHFT Pmods.