September 18, 2020
Quarantine Arts and Crafts: A Brief Case Study of CPU Design Patterns from the Disco Era
Here's one that's been sitting on my desk all summer. Back in April I had some time in between projects for paying clients, and I found myself buying and selling vintage computer memory chips just to pass the time. (Are you a TRS-80 collector in need of DRAM chips? I still have some left!)
Sometimes the chips come in estate lots, and you just get a whole bunch of random whatever. I got my hands on one lot that I'm guessing was from a gentleman who fixed up TVs all through the seventies and began dabbling in computers in the early eighties: it was a mix of television circuits, logic circuits, and some chips that appeared to be harvested from TRS-80 machines.
But, in this lot I found something I truly wasn't expecting: a Sylvania ECG74181 ... a 74181! From...Sylvania ECG? (Read to the end for why that's weird.) But nonetheless, an actual 74181! The chip that is probably the most fascinating and historically significant computer chip to ever come out of the TTL computer era.
The 74181 is a TTL-based design for an Arithmetic Logic Unit, and there is plenty that has been written about this chip so I won't re-hash any of it. But all you need to know is that this chip does math!
It's significance comes from being one of the first ALU designs that was produced on a single chip. It wasn't like that before. A CPU used to be built out of circuit boards packed with individual discrete components, all wired up together in massive cabinets. Before "Intel Inside," it was more like "inside your entire building." You know how your boomer parents complain about how BACK IN THEIR DAY! the computers they used in college used to be as big as refrigerators? They aren't exaggerating!
Let's Sim It!
So I spent the rest of the month digging into how this ALU works. Hey, what else was I going to do with my time during this past April?
I threw together a Fedora VM and put KTechlab on it, and began to stumble my way through digital electronics design and simulation. Why KTechlab? Because I don't know any better! I didn't study electrical engineering and I do absolutely no hardware design for a living. This is all new land for me.
So How Was KTechlab?
Awful. Crashed all the time, on what seemed like completely random click sequences. Probably not the best tool out there. But I didn't feel like going too nuts over my tool of choice for a screw-around project that I wasn't going to work on for longer than a few weekend afternoons.
But nonetheless, here is my simulated 74181! KTechlab's digital simulator makes it act close enough to the real chip for my purposes.
Let's Do, Like, Some Math or Something
So let's design and simulate an 8 bit ALU. This is something that you would have commonly seen in minicomputer designs of the seventies and into the early eighties.
There's a problem: the 74181 only works on 4 bits at a time, emitting a carry signal when it overflows. There are two design challenges we need to overcome: we need a way of separating the 8 bit inputs into 4 upper bits and 4 lower bits. And then, we need a way of taking the outputted 4 bit sub-results, and recombining them into the final 8 bit answer.
And you know what, let's be properly mental about it: let's only use 1970s TTL technology to solve these problems. You know, for fun or whatever.
We can craft a reader circuit out of 74x50 dual AND-OR-Invert logic chips. We would need two chips: each chip would be responsible for 4 bits of data. By wiring up a control line to the AND inputs of the chips, we can choose whether we want to output the upper 4 bits (high signal), or the lower 4 bits (low signal). One chip will receive this signal through an inverter in order to make this possible.
It is important to note: in the full ALU design we will need TWO of these circuits: one for each of the two data inputs into the ALU!
To recombine the 4 bit sub-results, we will need to build a register. The register can be built out of 74x75 4 bit bistable latches. This design will use two control lines: one line as a slice selector like in the input reader circuit, and one line that acts as a write enable line: data will only be written to the latches if this control line is high.
Will It Add? That Is The Question!
So let's make it all work. Our finished design includes a reader circuit for each of the two inputs into the 74181, and one output register circuit for recombining the 4 bit sub-results.
Let's test it by doing a little bit of adding. Can it tell us that 1 plus 3 equals 4? We set the op lines to 1001 - this is the 74181 command to add. We set our A input to 00000001 (one), and our B input to 00000011 (three). And our output register is showing us 00000100 (four). Neat!
But what about adding an 8 bit value with a 4 bit ALU? This will give us a nice demo of the carry bit. Let's try adding 15 plus 1. How do we get to 16?
Performing this operation will take two "cycles" - one for each 4 bit slice of the input data. The first cycle will calculate the lower 4 bits, and hey look at that! We can see that the 74181 is emitting a high carry signal! So for the second cycle, when we process the upper 4 bits, we will set the 74181's carryin line to high. And look at our register: after these two cycles, it is reading 00010000 (16). Great!
Some will argue that the seventies were the enlightenment age of silicon fabrication: this was when we were taking the first practical steps away from building computers with discrete components, moving instead towards fabricating entire logic structures completely on silicon. The 4004 and 8008 microprocessors were introduced around this time, paving the way to a single wafer of silicon holding an entire CPU and all of its supporting structures. No discrete components, no more refrigerator computers!
The 74181 is very famous in the history of computer design: it can be argued that it was the first major stepping stone towards modern computer hardware design. If the entire ALU can be baked onto a single chip, why not the registers? Why not the control logic? Why not the entire damn CPU?
And also, my ECG74181 is for sale! It's a weird chp because Sylvania ECG was primarily focused on marketing parts for television and radio repair. I didn't think Sylvania ECG even marketed any computer chip designs beyond the most basic of logic gates. Or maybe I'm entirely misinformed and I just sound like a stupid ass right now. That's always likely with me.
But, if you're a chip collector and you want it (or just want more info), then get in touch.