Ricochet is the best place on the internet to discuss the issues of the day, either through commenting on posts or writing your own for our active and dynamic community in a fully moderated environment. In addition, the Ricochet Audio Network offers over 50 original podcasts with new episodes released every day.
Welcome back to How to Build a Computer. You recall where we’re at, right? Hah! Trick question. As if I’d stick to a rational sequence. Today we’re going over some of the details in how you go from electrical circuits doing whatever it is that electrical circuits do and turn that into logic. We’re talking Logical Gates
Logic gates are transistor circuits that you can use to modify a signal. Let’s take the NOT gate as an example. If the input is on, the output is off. If the input is off, the output turns on. Whatever you put in, you get not-that coming out. Simple enough. Except the part where you’re creating energy out of nothing; what’s up with that? Well, not pictured you’ve got a five-volt source and a grounded drain. When you’re creating energy out of nothing you’re actually stealing it from that source. Those details make laying out your circuits more complicated but can generally be ignored when you’re drawing logic gates. Heck, as long as I’m recycling my drawings have another:
There are eight basic logic gates. To keep track of them you use something called a truth table. It’s a collection describing what you put in and what you get out. The NOT gate is easiest to understand. Here’s it’s truth table:
Actually, there’s one gate that’s simpler. It’s called a buffer. You ready for it?
So, a wire, right? I mean, if the output is off when the input is off then why the fancy symbol and all? Actually it’s not just a wire; typically these are built by sequencing two not gates together. The old double-negative. Fiendish! Why? It’s in the name ‘buffer’. It isolates one circuit from another. Keeps pesky physics things from interfering with your neat and clean logic. Speaking of which, let’s go over the other gates.
The rest of the gates transform two input signals into one output signal. Makes things more complicated. We’ll try an AND gate next:
Because you’ve got two input wires, each one which could be on (1) or off (0), you’ve got four possible combinations of ons and offs. An AND gate, as the name implies, only works when input A is on and input B is on. Makes sense. Slap a NOT gate on the end of that and you get a NAND gate (“not and” in case you hadn’t figured that part out.)
As long as both inputs aren’t on at the same time the output will be on. I think you’re getting this, so I’m going to do the remaining four all at once.
If you tum either input on in an OR gate you’ll get the output on. It’s not picky. The XOR gate is on a diet; it’ll take either input, but if you offer it both it’s out. And again if you slap a not gate on the front of either of those you get the opposite effect. Matter of fact, if you want to get the opposite effect on any of those gates you put one of those stylish little circles on the front.
Okay, we’ve got all eight logic gates. Could we make more? Sure. These are either useless (two entry wires, whatever combination of on and off they are the output is always off. Dead end.) or they’re redundant. Lemme draw you a quick truth table:
That one’s different, right? No, not really. Actually, only the one input matters; when the second input is on the result is on, and when the second input is off both are off. What you’re actually looking at here is a digital buffer on the second gate and never mind the first. This one is a combination of redundant and useless, much like some people I could name.
Okay, the eight gates though. We can see how you’d be able to run electricity through them, and hey, we’re probably also good with actually figuring out the transistors for these gates. Just one thing; how do we actually get logic out? Join us next week when we cover that in “Crazy Eights and Even Crazier Eights” or “The Eights are on Prozac Now, They’re Feeling Much Better.”
This is part nineteen of my ongoing series on building a computer, the brandy old-fashioned way. You may find previous parts under the tag How to Build a Computer. This week’s post has been brought to you by Sam Elliot. Sometimes you eat the bar, and sometimes the bar, well, he eats you.