Thursday, January 10, 2019

Progress update on AY-3-8500 emulation

Its been a while since my last post (about two and a half months) and you all are probably wanting an update on my progress. I've been meaning to do one for a while, in fact I have an old draft called "December progress update" that I threw out because it became outdated. If you're reading this, it means procrastination has lost a battle! (although the war rages on.)

To recap, approximately a year ago I started working on reverse-engineering the AY-3-8500 microchip. This chip was the "brains" behind millions of Pong-clone consoles sold in the later 1970s. Sean Riddle had decapped and photographed a specimen in early 2017, revealing the intricate circuits inside. About a month later, I expanded my goals from simply figuring out how it worked, to making a simulation of it. It took a few months to do, as I had to manually mark all the connections on the die images and write a program to process those into a netlist. An initial version was completed in August. Throughout September I participated in the RetroChallenge, making a few posts about how the chip operates, and getting distracted with something else.

In October I set a new multi-month goal, to make a full speed, playable emulation of the AY-3-8500. This would be done not by writing an emulator, but by writing a program to write emulators for me. This program (called DLAET) could be used to help emulate the numerous other discrete game chips out there. It works like a logic synthesizer in reverse, taking a list of transistors and turning them into more abstract components such as gates, shift registers, and counters.

Well, I have good news! A ton of progress has been done since I set out on this quest. I had expected a little more progress by now, however there were plenty of unexpected issues to deal with along with a thing called life. Anyway, DLAET can now (automatically) shrink the list of 972+ different components into a mere 360 components.

Latest debug image


For the curious, here is a list of specific components the circuit is reduced to:

1 NMOS-node (red)
22 IO ports (yellow or grey)
4 Pulse circuits (orange)
41 Flip flops/latches (dark green, dark blue, and sky blue)
20 AND gates
257 OR gates (grey or light green)
1 Shift register (purple)
8 Ripple counters (pink)
6 Counters (turquoise)
-----------------------
360 Total

Whats next


After a little more simplification work, I'll write the code to convert the (simplified) netlist into Verilog. For those unacquainted with EDA (Electrical Design Automation), Verilog is a hardware description language. Instead of a list of instructions for a CPU to execute, a HDL such as Verilog describes a list of physical hardware elements and how they interact. A Verilog description of the circuit could be put onto a FPGA, or be converted into a C code emulator.

The FPGA board I got
A FPGA chip contains thousands of reconfigurable digital building blocks, which can be connected together however the user desires. They can be used to mimic real hardware, including obsolete game systems. Programming a FPGA with the AY-3-8500's description, wiring up a circuit similar to one described in the manual and plugging it into a TV should allow me to play Pong like its 1976. Last November I bought a tinyFPGA board to do just this. Any relevant files will be posted online for anyone who wants to do the same.

My original goal was to create a playable, software-only emulation of the chip. Once a FPGA emulation has been accomplished, I'll work on using Verilator or homebrew software to convert the netlist into specialized C code. This will be then incorporated into a fork of MAME, allowing high-accuracy emulation on a normal computer.

More chips


There are over two dozen different discrete game chips designed and produced for early video game systems. Very few of these have had any attempt at re-creation, and for many of them datasheets or even play footage cannot be found online.  Normal emulation is not possible for the specialized circuitry inside them. Hopefully these 1st generation games will be emulated in the near future by me or by other people interested in them. The tools being worked on here are not specific to the AY-3-8500, they can be reused on other chips provided annotated images or netlist data is available.

The 4004 anniversary and visual ARM projects managed to obtain layout files from the companies behind their respective chips. Mask art (among other things) of discrete game chips might be in the archives of the manufacturers. Last week, I contacted Microchip Technology and Mitsubishi Electronics requesting any related files or documentation still available. Microchip technology is the descent of GI's semiconductor business, which designed many many chips after the successful AY-3-8500, some of which may be unreleased. Mitsubishi Electronics produced a few different chips used most notably in Nintendo's first consoles, the Color-TV game series.

So far nothing has been obtained. The email I received from Mitsubishi stated that they were "unable to provide (me) with information that is not available to the public via our website or publication." Microchip Technology has yet to respond to my email. I'll continue to attempt to obtain any manufacturer resources related to discrete game ICs.

Closeup of AY-3-8606 "wipeout" die
(Sean Riddle)
It is also very likely that layout/mask files have been lost or will not be released. In these cases the normal method of acquiring a specimen, decapping it, photographing it, then highlighting it will be needed. This is a chance for you to contribute! Any photographed chips have to have their components highlighted before being converted into a netlist. Highlighting a chip doesn't require you to know how the circuits are formed, it only requires you to identify different components on the basis of appearance. I believe the visual6502 team's tools worked on vector images, allowing people to highlight the images in a program like Photoshop or Inkscape. Alternatively the program I made works on raster images, which can be highlighted in MSPaint. Examples of highlighted images can be found here, here, and here. If anyone is willing to help annotate, I'll be happy to help guide and answer any questions.

Currently (to the best of my knowledge) die photos of five other discrete game chips exist. All of them can be found here. Other chips will have to be acquired and decapped (which you can help with too.) An (incomplete) list of game chips is here. If you have any that you can donate to preservation (nonfunctional ones included) that have not yet had internals photographed, one of the "acidbenders" could be contacted about decapping them.

To be continued


It seems like I don't have a thing for small, quick posts. Hopefully I'll write about many more accomplishments in the months ahead. Aside from this project, I have two other things I might sometime reverse-engineer and write about sometime. I also need to finish cleaning up and release my image processing tool. The next project update will be planned for February, although if you want the latest news I might post an occasional teaser on Twitter. In the meantime, I'll be happy to answer any questions you have in the comments below.

2 comments:

  1. I want to contribute to the project like I said earlier, if you have plans to obtain and decap Color-TV Series / or know someone who can and need funds let me know. Are you on Patreon or anything?

    ReplyDelete
    Replies
    1. I don't have a Patreon account, although I might make one sometime. The Color TV Game series is definitely on my radar for decapping/emulation given their spot as Nintendo's first consoles. (Fun fact: The TV game 6 and TV game 15 use the exact same chip, 9 of the games are locked out the lower-end model) I don't actually decap the chips, there are a few other people on the internet with the proper equipment to do it. If you come across any consoles/chips (including non-functional ones) that need to be decapped I'd be happy to arrange for someone to do so.

      Delete