The TinyFPGA boards (available on Tindie) let you get started quickly and inexpensively with FPGAs and hardware description languages. The A1 and A2 boards are particularly cheap easy to use, so I decided to build a simple game console around them. The scarce resources on these devices (especially the A1) make coding a video game quite challenging, which some people may find entertaining. The console will feature VGA graphics and line-level audio output and use Wii-style connectors for a number of compatible I2C-based game controllers.
This project is a work-in-progress.
The description above pretty much says it all. I'll fill this in once things are further along. Check the logs for progress.
The devices on the A1 and A2 boards are tiny. Just to set expectations about the class of games you might be able to fit on them: think Pong.
The mechanical drawing of the VGA connector included on the datasheet left me a bit puzzled, so I decided to mock-up the PCB to double-check the footprint before sending out the gerbers. I made a cardboard mock-up of the board to check things.
I printed out an image of the layout, glued it to a piece of cardboard from the back of a legal pad, then poked holes for the pins with a sewing needle held in a pin vise. I used a paper punch to make the mounting holes for the connector. The result: a perfect fit. I had properly deciphered the datasheet.
I used to make these a lot more often, especially when I used to etch my own boards. There are two gotchas - first, printers are typically more dimensionally accurate in the horizontal than vertical directions. This is caused by paper slippage and eccentricity of the rollers. So, the spacing may not be very accurate in one dimension. The second problem is caused by the paper warping when saturated with glue. I previously used white glue for these, but have found warping to be much less of an issue with a glue stick.
Here's the first cut at a schematic for the game console.
The PCB will have a socket to accept either an A1 or A2 TinyFPGA board. There are sites on the PCB for either an 8- or 14-pin metal can crystal oscillator. I chose a through-hole oscillator since 25.175 MHz oscillators (640x480 @60Hz VGA) don't seem to be widely available in SMT. Additionally, when using an A2 board as brains, you are free to choose a different oscillator frequency from your junk bin and use the internal PLL to synthesize the correct dot clock. I've experimentally used 640x480, 800x600, 1024x768, and 1280x1024 with the internal oscillator on the A1, and would have gone higher except that's the maximum resolution of my test monitor.
Since most metal can oscillators are 5V, a 74LVC1T45 level translator provides a 3.3V output. I didn't see the point in messing with resistive dividers at 25+ MHz.
The VGA output uses three 3-bit weighted resistor DACs. I used similar 2-bit DACs on #PIC Graphics Demo last year, and figured I'd try to push it a little. This will give a 512 color display. The resistance values are chosen to weight the bits correctly, produce a full-scale 0.7V output, and present a 75-ohm output impedance. Similarly, the two sync lines are back-terminated in 75-ohms to damp reflections on the cable.
Audio output is PWM, but there are left and right channels. In #Oscilloscope Vector Game Display I had a look at the output produced by the Raspberry Pi's PWM audio, and it wasn't pretty. It is cheap and easy, however, so I'll take two out of three. Again, the resistors are chosen to produce line-level output (0.894V peak) and 100-ohm output impedance (not critical).
The controllers use Wii nunchuck connectors. A wide variety of retro-style controllers are available for this interface, which uses I2C communication. The MachXO2 devices on the Ax boards have a hard IP I2C port which might make a single-player game possible on the A1, which otherwise would probably be too small. I don't know if the I2C lines are pulled-up in the controllers, so I'll add sites for pull-ups on the PCB, which can go unpopulated if needed.
The PCB is waiting until I receive the parts. The mechanical drawing on the VGA connector datasheet was confusing, and I'm not sure I got it right. I'd rather not add to my collection of coaster PCBs.
Will you be able to program complex games on this? No. The challenge will be coming up with something that fits.