Building a simple VGA-adapter for 8-bit self made computer
(Update 2014-10-30: Due to some interest in this project, I added schematics for the GALs)
How to build your own VGA-adapter
My lifetime project: building an 8-bit computer using Z80 CPU. This week I had a bad flu and could not do anything useful so I decided to dig up my old plans for this project. I first re-designed many things, like power, CPU-board, IO-board and so on (my old plans were around 10 to 15 years old). After some thought I realized: When I get even the CPU-board working, I want to display some stuff! So why not build the display adapter first. Plus I planned to build the adapter in a way that it can be used separately from the computer itself. Easy thing to start with.
VGA as a standard was quite obvious choice. Composite-connection is getting quite old and there ain’t especially many monitors (or none?) supporting it anymore. VGA is old too, but it will still be around many years. Though VGA is bit too recent to be used in an 8-bit old-school computer, I decided that it is a good trade off between old and something still around. And I also decided to cheat a little bit on this part of my totally old-school computer.
Next thing was to find out about signalling. There are many resolutions and frequencies that can be used. After a lot of thought, 640 * 480 @ 60 Hz seemed the best as it is kind of a industry standard and uses the lowest pixel clock frequency, 25.175 MHz, supported by standard VGA resolutions. After looking around and thinking of ways to implement the adapter, I dug up some old GAL re-programmable logic IC’s which I got from an old Cisco(?) router/switch/whatever it was and some that I had bought from ebay. They seemed a very nice solution for this project because of their speed and flexibility, plus they are old going back to mid 1980 (they are based on PAL’s which are from late 1970).
Then came probably the biggest problem: Memory amount needed to display picture with 640*480 resolution. Monochrome picture would take 38400 bytes and 16 color (4-bit) image would take 153600 bytes. The monochrome picture would be ok, but the memory required for a 16 colors was just too much. I still wanted to be able to display 16 colors, but not with that amount of memory. I had some 128 kB SRAM’s lying around which was about the maximum I wanted this thing to have. Even that 128 kB is almost too much for a thing that is supposed to be old-school. But still, 16 colors would be nice.. So, thinking and thinking some more. Ping! I realized, I don’t have to draw all the pixel data from the memory. After some calculations I ended up with 512 * 384 resolution. Both numbers are nice round numbers in base-2 space. This leaves 128 horizontal pixels and 96 vertical lines empty, which means 64 pixels on right and left and 48 lines on top and bottom. Remember that quite large border in old computer screens on which there was no graphics? Heh, some accidents are nice. 512 * 384 resolution needs 98304 bytes when using 16 colors per pixel which fits nicely into 128 kB (24576 bytes for monochrome). I was kinda hoping to use 64 kB or less memory in this adapter but sometimes compromises are required.
Well, now for part 1: Creating the right signals for a VGA-display.
Part 1 – VGA-output signals
After getting the synchronization signals right, this was the first kind-of-image I got on the screen:
This was the first actual monochrome image displayed:
The breadboard was really easy to use for testing a thing running at 25.175MHz (the schematics later is different what is shown here):
Finalized schematic of hsync, vsync and color generation circuit (no memory or anything else like that included, just outputting of the signals plus kind-of-ramdac). Unfortunately this image does not tell much, since I used GAL16V8, GAL20V8 and GAL22V10 programmable logic circuits for this project. Building this thing with only discrete logic would have been a fun but too big project.
Waiting for the PCB to etch:
VGA-output circuit assembled and running:
I ran into something that got me laughing a lot when testing this hardware. I noticed that after few minutes image on the display started jiggling around. I got frustrated thinking that the problem was in the logic I had programmed into the chips or in the circuit itself. It had done the same in the breadboard and I hoped I would get rid of this problem when the device was assembled in PCB. Well, doing this, thinking that and with a blank stare at my face, I put my hand on the IC’s. They seemed quite hot and after few seconds picture on the display stopped jiggling. No.. No way.. Well, can’t hurt to test. I put few small PC graphics display card memory heat sinks onto the IC’s and would you believe it? The picture stopped jiggling and didn’t start again until after several minutes. I added small fan on top of the heat sinks and even after tens of minutes there were no problems. I laughed, my 16 color, 512 * 384 resolution simple VGA-card needed COOLING! Have to remember that next time when using those GAL-devices in high frequencies. They should be able to handle even higher frequencies without problems according to their datasheets. Side note: this circuit contains 6 GAL’s and not much anything else that would draw current. The whole thing draws around 0.6 A at 5 V, that is 3 W. This is only the output portion of the display card. And only one card in the whole computer. I’m gonna really need that big 10 A at 5 V power unit I was designing mostly just for the heck of it.
Schematics for GALs
Counter for horizontal sync (U1)
Counter for vertical sync (U2)
Horizontal sync generation (U3)
Vertical sync generation (U4)
Memory data to pixel data decoder (U6)
Color coder i.e. “RAMDAC” (U9)