Tuesday, September 21, 2010

Unrelated Circuit - 4 Bit Adding Machine

So this is a little unrelated to music, but a friend of mine today asked me how hard it would be to make a computer. Not buy a motherboard, processor, hard drive, and memory and put it together, but to actually solder components together. At first, I laughed, but when we talked about how complicated a processor alone was, I realized in theory, they aren't too complicated. Transistors basically work as electronic logic gates, were "true" is a current flowing and "false" is not. We decided something simple, like a four bit addition "processor" (not really a processor, more like an adding machine) would be theoretically possible to build, even if it was incredibly large (compared to modern processors). I quickly started drawing up schematics.

We started with truth tables for binary addition:

0101 -(binary of 5)
0110 -(binary of 6)
+____
1011 -(binary of 11)

We found that each column works like XOR, except if A and B are both 1, you have to carry a digit (like above), which makes things a little nasty. My friend stumbled upon half adder logic, which instantly un-stumped the problem. You do an XOR for the sum of A and B, but you also AND A and B and store it to C, your carry variable. Then you have to repeat the process between [the sum of A and B] and C (explaining the other "half"). Then you send that sum to the output, and carry the C to the next column.
From RabidAudio
Another EE major helped me out a little bit. He reminded me of the basic transistor circuit, which turns out to be equivalent to a NOT gate. He then showed me that if you add another transistor, it becomes a NAND gate. Wikipedia revealed a way to make XOR gates out of 4 NAND gates, and you can make AND gates by using NAND and then inverting them with NOT. The only other logic operator used is OR, which is simply a Y-connection, which means all we had left to do was substitute logic gates with transistor circuits. Below is the processor, which in total uses 76 (I think) NPN transistors, and below that is the whole circuit. Notice that it is a) very sloppy; b) has no units; c) is probably at least a little bit wrong. I found out later that there are guides for making these out there, so if you want to make one, I don't recommend using my schematic. It's here if you want it though.

From RabidAudio

From RabidAudio