The Graphics Gremlin is an FPGA-based ISA video card specifically designed to emulate certain old video standards. This initial release emulates the original IBM PC monochrome graphics adapter (MDA) as well as the original IBM color graphics adapter (CGA). Since the logic is defined by the bitstream loaded into the FPGA, new emulations may be available in the future to support other video standards.
But why emulate an old video card when they are still fairly easy to find online? Cards aren't hard to find, but monitors that can sync to the unusual frequencies used by MDA (18KHz) and CGA (15KHz) are much harder to find, and these frequencies are rarely supported by modern LCD monitors or video capture hardware.
For both MDA and CGA, the Graphics Gremlin has a VGA port that can deliver video running at standard (31KHz) frequencies that are well supported by LCD monitors, VGA-to-HDMI converters, and USB capture devices.
Here are the design files. The BOM includes Mouser Electronics parts numbers for everything except for the 0.1" headers which are typically cut to length anyway.
The circuit board is a 2-layer board, 4.19 x 4.2 inches (106 x 95mm). No special edge connector bevel is required, but you may want to specify at least ENIG plating. If you are rich then you could spend the extra money and get hard gold plated edge fingers. Order the boards with a fancy soldermask color so you can show off, or stick with a plain green to blend in.
You probably shouldn't attempt this project if you've never soldered surface mount components before. It'll lead to a lot of frustration and potentially damaged boards and parts.
There are two main methods you can use to assemble the board: reflow and hand soldering. Using the reflow method means that you'll need to order the solder stencil for the top side (there are no parts on the bottom of the board), and be sure to have fresh solder paste and some sort of vacuum pick-and-place tool. This method can be very quick but does require some skill and practice.
Hand soldering is good when you only want to assemble a single board. This board has no BGA or leadless components which makes hand soldering possible. Some components have a very fine lead pitch (0.5mm) so only attempt this if you are comfortable with your soldering skills.
No matter which method you use, I recommend inspecting every solder joint very carefully under a microscope to make sure there are no solder bridges. If there are, clean them out with some solder braid.
Be careful not to mix up the two voltage regulators: they provide different voltages!
R11 should not be stuffed. By default this means that the 14.318MHz clock is generated on board. If you move R25 to R11, then the 14.318MHz clock comes from the ISA bus. The motherboard's 14.318MHz oscillator isn't always accurate enough for CGA color composite video.
Header J6 is optional. If you want to install it, remove pin 2 for keying.
Before plugging the card into a PC, it is wise to use a multimeter to verify that there are no short circuits between the +5V line (ISA bus pin B3) and ground or between the +12V line (ISA bus pin B9) and ground.
A separate document discusses the Verilog code.
Programming the FPGA is fairly easy and can be done with an FTDI FT2232H Mini Module datasheet here.
Wiring for the FT2232H mini module is as follows:
Point 1 | Point 2 | Description |
---|---|---|
CN2 pin 1 | CN2 pin 11 | V3V3 to VIO strap |
CN3 pin 1 | CN3 pin 3 | VBUS to VCC strap |
CN2 pin 3 | CN3 pin 12 | V3V3 to VIO strap (2) |
CN2 pin 14 | SPI cable pin 1 | CS |
CN2 pin 16 | SPI cable pin 2 | CDONE |
CN2 pin 7 | SPI cable pin 3 | SCK (serial clock) |
CN2 pin 15 | SPI cable pin 4 | CRESET |
CN2 pin 9 | SPI cable pin 5 | CIPO (controller in, peripheral out) |
CN2 pin 2 | SPI cable pin 6 | GND |
CN2 pin 10 | SPI cable pin 7 | COPI (controller out, peripheral in) |
n/a | SPI cable pin 8 | not used |
To program the FPGA, power needs to be applied. The simplest way to do this is to drop it in a nearby PC and turn it on. With the cable plugged in to a USB port, you can use the Project IceStorm tool "iceprog" to program the SPI flash memory.
iceprog -p isavideo.binm
Once the SPI flash has been programmed, iceprog toggles the reset line so that the FPGA loads the new bitstream. At this point it will be active on the ISA bus, but the PC's BIOS doesn't know about it. Reboot the computer and it should find it.
Note that leaving the programming cable plugged in can sometimes cause issues with the FPGA being held in reset when the PC powers up. In that case, simply unplug the cable and reboot the PC.
The red switch bank on the top right of the card controls two things: the bitstream selected by the FPGA when it powers up and specific settings for the selected bitstream.
The bitstream is selected using switches 3 and 4:
3 | 4 | Description | Default |
---|---|---|---|
open | open | Bitstream 0 | MDA (VGA compatible signal) |
open | closed | Bitstream 1 | MDA (MDA monitors only) |
closed | open | Bitstream 2 | CGA (both VGA and CGA compatible signals) |
closed | closed | Bitstream 3 | Not used |
For example, if you want to use MDA with a VGA monitor, set switches 3 and 4 to the open (up) position. (CGA has support for both VGA and CGA monitors built in since it implements a line doubler.)
The remaining two switches have a function that is bitstream-dependent.
Switch | MDA (VGA comp.) | MDA | CGA |
---|---|---|---|
1 | Not used | Not used | closed=composite mode. open=VGA mode |
2 | Not used | Not used | closed=thin font. open=normal font |
The Graphics Gremlin provides both a 9-pin RGBI connector and a 15-pin VGA connector. The 9-pin connector is designed for use with digital monitors such as the IBM 5151, 5153, or a variety of older multisync monitors.
The RCA jack is used for CGA composite video when that bitstream is selected (see the previous section). Note that the signal for the RCA jack is also used as the green channel for the VGA connector so they cannot both be used at the same time.
Connector J6 is for compatibility with IBM CGA cards which provide the composite signal for RF modulators. This connector is really only useful if you want to use the card with an IBM 5155 Portable PC (the internal monitor has a cable that plugs into this connector).
This is a complex card with many fine-pitch components, so most likely any issues you run into will be caused by a solder bridge or broken connection. Go back and check each solder joint using a microscope. Make sure you didn't install any chips or the clock oscillators the wrong way around.
A few things to confirm for basic operation include:
- Are the 3.3V and 1.2V regulators putting out those voltages?
- Are the two clock oscillators generating 10MHz and 14.318MHz?
- Can the SPI flash get programmed by the FTDI board and verified?
Unlike the namesake video cards of old, the FPGA comes up with the internal card registers fully programmed and the card should generate video even if the ISA bus interface isn't working at all. A simple check involves configuring the switch bank for CGA and confirming that it produces a video signal. You can even flip to composite mode to make sure that works as well.
Checking these first can help you narrow down the source of the problem.
To confirm proper operation on the ISA bus, it's helpful to set up a PC with a VGA card (or CGA card) and the Graphics Gremlin configured for MDA. These can coexist on the same PC.
Boot up the PC and run the DOS DEBUG program. Then see if you can access the CRTC registers. Unlike the original MDA card, these can be read back. Note: if you use the VGA compatible MDA mode, then these registers cannot be written to.
o 3b4 0
i 3b5
This should return a number that is not 0 or FF. (The exact number depends on which MDA bitstream you are using).
If that works, then check to see if you can read and write the MDA video memory area:
e b000:0000 55 aa 55 aa
...
and to check what you just wrote
d b000:0000
This will exercise the connections to the SRAM.
Other strange things that can happen:
- If the PC just beeps out an error code during startup, check for motherboard jumpers or switches that have to be set. You might also try a dual video card setup with a VGA card.
- If the PC never boots at all, it could be that the IO_READY pin (A10) on the ISA bus is stuck low. Also check for any short circuits on the address, data, or control lines.
- If the PC power supply refuses to start or if there is smoke, then you probably have a short circuit on the +5V or +12V line on the card. Check for things like solder paste smeared underneath capacitors or traces shorted to the ground plane.
In general, use a logical process of elimination to find where the fault (or faults!) lurks.
The logic for both the MDA and CGA cards is as close as I could get it to match the schematics available in the technical reference manuals, with two exceptions. The VRAM interface is specific to the 8-bit SRAM chip that I am using instead of the 16-bit SRAM on the original MDA or the 16-bit DRAM used on the CGA, so it had to be quite different from the originals. As a result, the sequencer state machine had to be designed from scratch. There are some other minor differences mostly to support the nonstandard VGA-compatible signal outputs.
Accuracy is a work in progress. Certain demos, like 8088MPH, that require cycle-accurate operation on a 4.77MHz PC, don't work 100% correctly. The causes of this aren't yet fully understood.
Although the card supports just MDA and CGA, I'd like to support other video standards in the future. EGA and even VGA would be nice, but there are two huge challenges associated with that: they use custom gate array chips and they also use a 32-bit memory bus. This means I would need to quadruple the pixel clock to produce four 8-bit fetches from the SRAM. Due to this bus bandwidth limitation, Super VGAs are totally off the table.
Other people have requested support for Hercules, Tandy, and PCjr graphics, which I might get around to implementing someday.
There are also some neat non-graphics uses for the card. With some clever programming, the card could be turned into a memory card to extend the RAM in some of the older IBM PC and XT machines (XMS RAM). It could also emulate an expanded memory card for machines that can't run EMM386. BIOS extension ROMs stored in the NOR flash chip could also be mapped to ROM areas in the PC memory map, which might also be useful.
The card could act as a fancy POST card, perhaps even with a mini bus analyzer built in (using a connected VGA monitor).
It's even theoretically possible to implement a sound card using the composite video jack (and 7-bit resistor DAC) as the sound output.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. See https://creativecommons.org/licenses/by-sa/4.0/.