VGA1306 (VGA-out for DIY Arduboys implemented on an FPGA!)

Ah it’s an array of bits. I got it now. The 640x320 code is a little clearer than the others also.

All you need per iteration is a single subtraction to go back a row and switch to the next bit position.

if(c_col == 639 && c_row+1 is divisible by 5) begin
              raddr_temp <= raddr_temp - 1024 - 1;

c_row can be replaced with a modulus check also, but I’m not sure how to code that in FPGA. In C it would look like if ((c_row+1) % 5 == 0)

That would remove all that repeated code with a single conditional with some simple math.

I can see how that would work for the first 8 rows, but then what happens when you get to row 9 of 64 and you have an address of -1 when you want 1031?

OK, so you may also need a “every 8 rows, increment by 1032” or something. :slight_smile:

Or actually if you don’t do the subtraction it should already be perfectly lined up, no? So in that case you’d just check for every 8th row and do nothing at all.

Basically you want to use math to write “for every row, do this” and “for every 8 rows, do this”. So then you describe only 2 conditions, not 64.

What’s great about FPGAs though is that those extra 62 conditions aren’t going to slow you down any… because the comparisons are all happening simultaneously, not sequentially!

Getting close to having boards available for sale now, and I look forward to seeing how far the community will optimise / ‘bum’ down my imperfect / ‘не слишком изящным’ Verilog! :smiley:

I hope you’ll break out unused GPIO’s too for future additions (Kind of thinking (S)NES controller to parallel buttons? push button for mode selection? :smiley: )

Also got this crazy idea for my pro micro that serves as (S)NES controller:
Compress the VGA1306 firmware and store it in the pro micro so it can uploaded (and be updated) to the VGA1306 board. One more project on the heap :stuck_out_tongue:

Sorry, that may have to wait for version 2.0! :flushed:

Yes, the FPGA can receive its firmware directly in ‘SPI Slave Mode’ (here is a Raspberry Pi script I have used for this purpose if it helps).

Here is a nice flowchart illustrating the process:

Taken from the iCE40 Programming and Configuration Technical Note (details are in Section 13, from page 25 onwards).

You will need to level-shift down to 3.3V to use the FPGA SPI pins directly though!

Thanks for the info and links. Looks like I have something nice to play with this weekend :slight_smile:

Enjoy! :smile:

(Note: Regarding the RESET and DONE pins on their separate two-pin header. RESET has a pull-up resistor attached, so you don’t need to drive it high - you can just release it. And DONE has an internal “weak pull-up resistor”, but you may be able to disregard the DONE pin anyway - I don’t pay any attention to it when using that Raspberry Pi script and have not had any problems…)

Did some more experimenting with different applications of the VGA1306 board over the long weekend… took an Arduino-based VT100 terminal emulator from here, and refactored from 32 columns by 10 rows up to 80 columns by 60 rows. Then had it feed the character buffer into the VGA1306 running VGA ‘character-mode’ firmware adapted from here / here! The Arduino sketch is running on an old Duemilanove board with a ATmega1284-based ‘UNO*Pro’ expansion plugged in…


So from there, with the Arduino plugged into my laptop’s USB port, I can just run a Linux command like:

ping 0 | tee /dev/ttyUSB0

for example, and have the ping command’s output automatically redirected to the VGA1306 ‘terminal’! :grinning:

Here’s all the code:


Very happy to finally announce that boards are now up for sale :smiley: at:

…manufactured, assembled and tested on-site by matt of kitsch bent, and branded as ‘easy_VGA’.

Note: to order a board with the SSD1306 to VGA firmware, and the 6-pin header soldered on, you need to add three separate items to your shopping cart:

  • main board
  • IC for SSD1306 VGA
  • header assembly service

PS. Just as a heads-up to those who are in possession of the ‘prototype’ version of the board (@filmote @Mr.Blinky @Keyboard_Camper @eried @JayGarcia @sjm4306 @CRImier) take note that the pinout for the 6-pin header is flipped / inverted on this revised design, if you end up buying one! :wink:


Digging further down the rabbit-hole of VGA1306 as a sort of ‘80x60 character mode’ video card, I have made a fork of ArduinoBASIC:


(brought over a separate 5V supply for the keyboard - sticker on the back of this keyboard says 200mA, so I didn’t want to overload the Arduino)

Happily, there were not a lot of modifications necessary to refactor the code for 80x60 characters at 640x480 resolution! I added in a COLOR command for selectable foreground / background colours (all 8 glorious colours of the 3-bit RGB rainbow! :rainbow: ) and also added a #define to optionally use Serial for keyboard input (instead of a physical PS/2 keyboard) if desired…

(I am using the ‘serial keyboard’ in this video for the sake of easily cutting & pasting the program listing)


Now that is pretty cool!

1 Like

Have been working on a version using NTSC composite video (yes, the little yellow RCA jack :smile:) outputting 4-level greyscale! Loving the way it looks on my TV:



Dude, making a consolized composite video output gameboy would be awesome! Pretty please release the code and schematic for this once you are done!!!

1 Like

…have been playing with this some more on a giant 68cm CRT! :tv: :upside_down_face:


this is a really cool project excellent job on this, I had just bought an easy_VGA off of Kitsch-bent about a month ago and installed it on a DMG that had a broken LCD. this thing works really well. Would love to see a version of this device that can swap color palettes. Also, I think the current color palette is somewhat inverted, I think it would look better if the colors were rearranged. (black should be cyan) (blue should be black) (green should be blue) (cyan should be green).

Current color scheme

1 Like

rearraged color scheme

1 Like

although replacing cyan with white might be more ideal

I’ll be testing this out for my self, I ordered a programmer so I will be attempting to edit the code a bit and re-imaging the eeprom.

1 Like

I like your thinking - I just recently assisted another user in customising the colour scheme to their own liking:

The 3-bit RGB palette gives you 8 colours to choose from, so don’t feel like you need to stick to the lower four that I chose either:

Changing the colours in the source code is pretty straight-forward - here is the part you will need to edit (around line 187 in the code):

        if(dout == 3) begin //check pixel buffer data
          vga_r_r <= 0;
          vga_g_r <= 0;
          vga_b_r <= 1; // BLUE
        else if(dout == 2) begin
          vga_r_r <= 0;
          vga_g_r <= 1; // GREEN
          vga_b_r <= 0;
        else if(dout == 1) begin
          vga_r_r <= 0;
          vga_g_r <= 1; //  GREEN
          vga_b_r <= 1; // + BLUE = CYAN
        else begin
          vga_r_r <= 0; // BLACK
          vga_g_r <= 0;
          vga_b_r <= 0;

The process for then compiling the firmware is not too difficult - just means installing ‘apio’ using the ‘pip’ Python package manager, at the command line (assuming Windows) type:

pip install apio

and then, to download all the apio packages:

apio install -a

Afterwards, from the working directory (where you have both the DMG1306.v & DMG1306.pcf files) the command to compile is:

apio build --size 1k --type hx --pack vq100

This will produce a ‘hardware.bin’ file, which is only around 32K in size - so depending on your IC programmer you may or may not need to pad this file out to fill the whole 1MB chip (and be careful to take note of the orientation for the IC in its socket when removing from / inserting in to the easy_VGA board!), good luck! :slight_smile:

EDIT: I quietly love the idea that this kind of customisation encourages others to enthusiastically start digging down the same rabbit-hole of FPGAs that I fell in to! :smile: