VGA pattern generator using A1


I’ve made a VGA pattern generator using a TinyFPGA A1 and a 25.175MHz crystal oscillator. Verilog source here:

Here are the connections for the VGA socket:

(Sorry that’s so big!)

Things I might try next:
Use the A1’s internal clock. I don’t think it can get within 1MHz of 25.175MHz but that might still work.
Buy an A2 and use its PLL.
2 bits each for red, green and blue (6 resistors instead of 3 :slight_smile:).
Use an A2 to produce a text display for a microprocessor. (640x480 with a character set stored in Flash.)
Snow :slight_smile: using a feedback shift register.


Nice! Getting a VGA pattern generator to work opens up so many possibilities. It really brings a little breadboard circuit to life.

I like your ideas for further things to try. You’ve inspired me to think up some more:

  • Things that could work on an A1 (if you order an A2 you can try this out while you wait for delivery :laughing:):
    • Try displaying a simple fixed bitmap image. Would have to be pretty small, maybe start with 8x8 in size. You could try doing it in black and white first, then in color. After that, you could try moving the image around on screen or maybe moving multiple copies of the image around on the screen. (flying toasters?)
    • Try implementing a simple game like pong. Here’s another one for inspiration:
    • Try implementing a simple 7-segment display…or maybe even multiple 7-segment digits, or even a clock!
    • The A1 has up to 2kbits of distributed RAM. You could try implementing a very small bitmap display with changing bits. See what interesting things you can do with that.
  • Things that may require the A2:
    • Like you mentioned, a text console for a microcontroller.
    • A graphics controller for a microcontroller. Use some memory for sprites, and registers that the microcontroller can access to write them and move them around. Add a tile memory and tilemap for a background. Heck, you may even be able to fit a 6502 CPU on the FPGA and use that:
    • The A-series has limited IO on its pins, try using PWM with a low-pass RC filter on the RGB pins to generate 2-bit color per channel or more. You’ll have to tune the RC filter to filter signals above 25MHz. Then you can run your internal circuit at ~100MHz and use PWM on the pins. For even more resolution and quality you could try using the DDR IOs on the FPGA.

Have fun Bruce and keep on posting! :smile:


Thanks for the ideas, Luke.
My Verilog file is based on that page on fpga4fun. (I hope the author doesn’t mind.)
The Pong code uses a quadrature decoder to move the game’s paddle.
Funnily enough, one of the programs I wrote for my early '90s VGA pattern generator (based on a Lattice ispLSI1016) used 2 quadrature decoders to let me move a crosshair around the screen with a trackball.

In odd moments over the past few days I’ve been pondering more interesting things to display using my circuit. My current pattern is a bit unimpressive since the blocks of colour are 32 pixels on a side, and the same signal could be generated with a clock 1/16th of the frequency. A TinyFPGA logo might be a good pattern :slight_smile: . The top of the ‘T’ could be something like CounterX>=10 && CounterX<=80 && CounterY==140. I don’t know how many 10-bit magnitude comparators would squeeze into an A1.
I also thought of dividing vsync by 60 and displaying a 2-digit count.

A 640x480 8 bits per pixel display for my 68010 homebrew has been on my to-do list for a year or 2. I had in mind using 4 256Ki*4 VRAMs. I don’t know if I’d use a TinyFPGA for that since there’d be 18 address bits in from the MPU and 9 out to the VRAMs. (Of course, I could use external multiplexers to route the MPU address bits to the VRAMs, so the FPGA wouldn’t need those 18 inputs.)
I might make myself a breakout board for 1 of my VRAMs, put that on a breadboard with my A1 and drive the monitor directly (except for resistors) from the VRAM’s serial outputs. Its minimum voltage in is 2.4V so the A1 should be able to drive it directly (per your suggestion).

I’ve programmed several microprocessors in assembly over the decades, but the 6502 isn’t one of them. I’m busy enough learning Verilog!


I’ve FINALLY managed (with my negligible understanding of Verilog) to get my A1 to display a 20x15 1 bit/pixel image:
TinyFPGA text
Source files:
For my next trick… get the text to cycle through different colours.


Ha! That’s awesome :smile::+1:t2:


@BruceMardle, what crystal/clock are you using for your VGA pixel clock? I’m designing a couple of TinyFPGA project board kits with VGA output and am looking at parts. If you could upload a schematic or photo of your setup that would be great.


It’s a Kyocera KC7050A25.1750C30E00 (with wires cruelly soldered to its pads in order to stuff it in a breadboard).
It’d probably make more sense to use an A2 since that has a PLL and (presumably) can get closer to 27.175MHz using its internal oscillator. An understanding monitor might even cope with the closest the A1’s internal oscillator can get.
The circuit’s really simple: pins used as per the Verilog source with red, green and blue connected via 270-ohm resistors, everything else directly.
I’ll try to remember to take a photo or 2 tomorrow when a) there’s more light, and b) I’m less sleepy!


I probably ought to have a non-electrolytic capacitor or 2 on the 3.3V supply but it seems happy enough at the moment.


Nice. Looks like you already have an output capacitor right by the voltage regulator. The TinyFPGA board has some bulk capacitance as well.

@Xark had tried using the onboard oscillator and PLL for VGA on an A2, but he seemed to have ran into issues with the accuracy and stability of the internal oscillator. The internal oscillator has no crystal reference so it can vary quite a bit.


@lukevalenty Right, my flat-screen monitor didn’t like the internal oscillator for VGA. I even had a bit of trouble getting reliable 9600 baud UART with the internal oscillator (that wouldn’t be gibberish to PC). It worked on some boards, but not on others (too much variance). I ended up adding a simple “auto-baud” feature (which would calibrate the output serial bit-time based on input).


That auto-baud feature sounds slick. Some of the inexpensive PIC microcontroller with USB have a similar feature where they calibrate their internal oscillator based on the host controllers transmissions. It completely eliminates the need for an external oscillator.


Thanks. It worked nicely for serial (which can stand for ~2% error and jitter). There is a VHDL implementation of this transmit only UART (with receive input for calibration) for TinyFPGA-A2 in my BenEater example CPU (written in VHDL).


Sounds like I was lucky using an external crystal oscillator, then!
That’s an electrolytic capacitor. They’re not very good vs. high-frequency spikes. I dunno why I included it; possibly because the last linear regulator I used was an LM2940 and they don’t work at all without one.

My FPGA is currently outputting “Tiny FPGA” in a colour which changes once a second. It’s fine with 2 monitors, fine with another on a good day (that monitor is quirky) and with 1 it only works while the text is in green! Weird!
I wonder if it’d be happier if blank was “blacker than black”.


What resistor values are you using for your red, blue, and green signals? VGA expects 0.7 volts to be full brightness and 0.0 volts to be complete darkness. The monitor end has a 75ohm resistance. You just need to put resistors on the output of the FPGA pins to drop the voltage down from 3.3v to 0.7v. H-sync and v-sync are fine at 3.3v.

Maybe the issues on the monitors you are running into are due to voltage levels?


270 ohms. (As the caption on my photo says, they’re hiding under the Dupont connector.) 3.3*75/(75+270)=0.72. For a 2-bit output, I’m planning to use 470R and 1k resistors, which should make the signals a bit smaller.
When I built a VGA pattern generator in the '90s, I put 75R resistors to ground on ‘my’ end of the lines too.


That’s prettty much perfect. I wonder what’s up with those other monitors.


Well, the quirky one is quirky with other signal sources too. It has a habit of suddenly announcing that it’ll only work at 1280x1024. The last time it did, I plugged it into a PC set to 1366x768, it was happy with that(!), and then it was happy with the FPGA again! There’s a video on Youtube about soldering a 47R resistor inside it to fix this but I’ve got monitors aplenty so can’t be bothered!