VGA driver for arduinos

Projects you are planning or working on with the Mojo
Buton
Posts: 2
Joined: March 24th, 2013, 11:13 pm

VGA driver for arduinos

Post by Buton » May 7th, 2013, 3:08 pm

FPGAs are fast and a project i would like to do with the mojo could be to use the mojo as a driver for a VGA display for arduino or other microncontroller via serial spi or i2c.

it would be nice to connect an arduino a monitor and have some functions programmed on the mojo to display stuff.

Xark
Posts: 14
Joined: May 6th, 2013, 8:29 pm

Re: VGA driver for arduinos

Post by Xark » May 14th, 2013, 2:29 am

Nice! Sounds like something the Mojo should excel at.

Have you heard of the Gameduino? It is basically a less powerful FPGA than the one in the Mojo and pre-programmed to generate a VGA display (using SPI).
http://excamera.com/sphinx/gameduino/

It is also GPL licensed, so might be worth taking a look at the Verilog code (which includes a small processor even).
http://excamera.com/sphinx/gameduino/making.html

There is also another project called "YaGraphCon" http://www.frank-buss.de/yagraphcon/index.html that you might find interesting. This is less "game" oriented and perhaps easier to understand (but in VHDL).

markhu
Posts: 12
Joined: August 8th, 2013, 12:53 am

Re: VGA driver for arduinos

Post by markhu » August 23rd, 2013, 11:50 am

Have you found/made your VGA connector yet?

I'm about to order the VGA module from http://xess.com/ to use with my Mojo v2 board.
It comes with choice of pinouts for either PMOD or Papilio-Wing, neither of which Mojo supports directly. But the "wing" pinouts are very easy to adapt, requiring only a couple of flying jumper wires for ground and power. There are a number of VGA examples out there in both Verilog and VHDL. Then the fun starts: adapting the .UCF constraints file for the correct pin assignments.

Xark
Posts: 14
Joined: May 6th, 2013, 8:29 pm

Re: VGA driver for arduinos

Post by Xark » August 23rd, 2013, 3:50 pm

Hello,

Yes, the Xess VGA 2.0 is exactly what I have purchased also, and it works nicely (14-bit color with 4 red, 5 green, 5 blue bits) . As you mention, just don't add the "power pins" to the Papilio Wing (the dual 4-pin header row) and you can stick it right into Mojo (with just a GND jumper).

I didn't have much trouble modifying the UCF pins, however I will mention that on the Xess SVG file showing the VGA 2.0 pinouts the HSYNC and VSYNC Papilio pins are mis-marked (reversed). This caused me a bit of grief until I used my scope and could see VSYNC changing much faster than HSYNC.

Lots of VGA designs around the net to learn from (I am partial to VHDL, and it seems there are a lot of VHDL resources on the Internet). I especially like http://hamsterworks.co.nz and http://opencores.org (both of which have some VGA controller examples). This design was also helpful to learn from http://www.frank-buss.de/yagraphcon/. With Mojo and no external memory, the VGA needs to be either low-ish resolution or character/tiled graphics based (~64KB on chip BRAM IIRC).

markhu
Posts: 12
Joined: August 8th, 2013, 12:53 am

Re: VGA driver for arduinos

Post by markhu » August 30th, 2013, 10:40 pm

Could we use an SDram card like this to overcome the lack of memory?
http://papilio.cc/index.php?n=Papilio.MicroSDWing
Or would VGA need "real" memory to display a picture?

Xark
Posts: 14
Joined: May 6th, 2013, 8:29 pm

Re: VGA driver for arduinos

Post by Xark » August 31st, 2013, 2:04 am

Nope sorry. That wing would be useful for loading an image, but it is not nearly fast enough to be frame-buffer memory. I really haven't seen any memory wings or PMODs with either SRAM, or SDRAM (or even quad-SPI SRAM). It would be nice if someone made an add-on board for the Mojo ("Mojo rider"?) similar to the Papilio Arcade Megawing with VGA, some SRAM (or maybe SDRAM, it is more difficult to use, but generally larger), PS/2, joystick, SD-card (etc.).

However, 64K is still enough to do some interesting things with, just not a full-color high-resolution bitmap (you can get up to around 320x200 @ 256 colors). You would need sprites, tiles, run-length compression (etc.) for higher resolutions or more colors. The internal 64KB BRAM is also very fast and can be dual ported (two different locations can be accessed simultaneously).

For example the Gameduino (http://excamera.com/sphinx/gameduino/) is on a smaller, older FPGA that has only ~24KB BRAM (Spartan 3 XC3S200).

markhu
Posts: 12
Joined: August 8th, 2013, 12:53 am

Re: VGA driver for arduinos

Post by markhu » August 31st, 2013, 2:38 am

Is it possible to program some sort of memory emulator?

Regarding the megawings, the pinout spacing is compatible, so aside from the frame buffer issue, all you'd have to do is figure out the UCF constraints. And you might have to file down some of the through-hole pins protruding from the underneath side of the board, since a few bump into the Mojo's power jack.

Xark
Posts: 14
Joined: May 6th, 2013, 8:29 pm

Re: VGA driver for arduinos

Post by Xark » August 31st, 2013, 2:12 pm

Short of some compression tricks, memory is one thing that you can't really emulate (you need some memory to remember the emulation). :-)

The Papilio Arcade Megawing could (perhaps awkwardly) be interfaced to Mojo but since it still doesn't provide any memory, it may be easier to use the Xess VGA 2.0 (or Papilio VGA wing, if OK with 256 colors) along with a joystick wing (or two) and an audio wing (and optionally perhaps a button/led wing). However, I guess those would add up cost-wise.

There is nothing too difficult about interfacing to any of those components, so it should be fairly easy to mount them directly on a protoboard with headers for the Mojo. Once you are doing this, adding a SRAM is probably very doable too (or quad-SPI SRAM for only a few pins). I'd like to try wiring up an Arcade "Mojo Rider" protoboard at some point, but I am in the middle of another project currently. It would be even better if a hardware person would step-up and design a nice PCB for the Mojo though. :-)

Figure that none of the Papilio One (not the Pro) projects had external memory (and has less internal than Mojo), so all those projects are possible on Mojo with VGA and some input (and optionally audio).

markhu
Posts: 12
Joined: August 8th, 2013, 12:53 am

Re: VGA driver for arduinos

Post by markhu » August 31st, 2013, 2:53 pm

I have the Papilio One (500k) and have loaded bitfiles into it that display a color picture via VGA while playing music.
How are either of these possible without RAM?

MacAttak
Posts: 72
Joined: April 28th, 2013, 1:27 am
Location: Atlanta, GA
Contact:

Re: VGA driver for arduinos

Post by MacAttak » August 31st, 2013, 7:18 pm

VGA is a (relatively) simple serial protocol. My understanding is that it is encoded into scanlines of RGA data with a fourth control signal - with the bitrate and start/stop sequences determining the resolution and frame rate. Depending upon what you are doing, you don't always need a frame buffer (frame buffers are what require memory). Here is an example of driving a VGA port. It uses VHDL instead of Verilog, but the idea can be implemented just the same:

http://www.youtube.com/watch?v=mS0VZwnZssA

Yeah the music is distracting, just ignore it if you can :)

In essence, each pixel is recomputed for each frame on-demand. Since each pixel is computed on-demand, there is no need for intermediate storage between frames. This is of course limited by the amount of computation you can perform in between output clock cycles.

A frame buffer design on the other hand will create a two-dimensional array of data registers (each of which contains a full RBG value), and then your code is segregated into code that computes and generates the buffer data, and driver code that reads that array of data and emits the scanlines. The nice thing about a frame buffer design is that you can drive the output signal on a fast clock (to keep up with high resolution signal clock) while still performing slower computations to generate the data being displayed. And if you have the memory for it, you can even keep multiple buffers around as layers that are then composited during signal generation - which allows for more effects and features.

Post Reply