Okay, yes, I know some of you think it's been quite a wait, but it last we are getting close to how computers actually work.
Computers work by logic.
Some of you may be thinking that I have promised to tell you how computers work, and I have broken my promise. I tell you that computers work by logic, and you have possibly heard that before, that computers work by logic, or that computers are logic, or that computers run by logic circuits. And you think that just by saying logic I'm not explaining anything to you.
Well, that's maybe because you don't know what logic actually is.
Actually, logic does come in a variety of forms, but very few people actually use pure logic, at least not on a daily basis. To be quite honest, most people probably never do use pure logic, or don't realize it if they are using it. All logic does come from the same place, and it does work out in much the same way. But you have to get a lot of complications out of the way before you can actually see what pure logic is.
The type of logic that computers actually use is best illustrated in the form of truth tables.
(I should note that, a lot of this next bit is going to be illustrated. That is, the best way that I can explain it is with a diagram. And, generally speaking, I don't do graphics. So I have gone out to the Internet and looked for images and diagrams that I think illustrate what I am talking about, but I haven't been too terribly careful about anybody's intellectual property rights. So the illustrations and diagrams that I am using here very possibly belong to somebody else, and I can only apologize if they felt that I had to ask permission before I use them to illustrate the points that I'm trying to make.)
When you want a computer to do something, you have to build a circuit to perform that function. In order to design and build a circuit to perform that function, you first have to figure out a truth table for the function. A truth table is a table that lets you specify what output you would expect from this function, for a given input, or set of inputs.
Now, I am not going to go through all the possible basic logic circuits. For the purposes of this initial illustration of how logic works, I am going to show you a circuit for an AND gate. (We'll go into more detail about different logic circuits a little bit later.)
So we are building the logic circuit and the truth table for an AND gate. We want a circuit that will tell us that both the inputs for this and gate are true. And, actually, since everything, in terms of computers, is either one or zero, we can say that one is true, and zero is false. Or, since we are dealing with electricity, we can say that on is one or true, and that off is zero or false. And the gate that we want to make with will tell us if the first input AND the second input are both true, or on, or one. (For the purposes of this discussion of logic gates, on, one, and true are all interchangeable.)
So the first thing that we do is to build the truth table such that if the first input is false, and the second input is false, the output is false. If the first input is true, and the second input is false, the output is false. If the first input is false, and the second input is true, the output is also false. But if the first input is true, AND the second input is also true, then the output is true. This is the truth table for an AND logic gate.
The illustration here shows that truth table. It also shows the symbol for having an AND gate in a circuit. It also shows how you use a electrical components, including a couple of transistors, in order to build an actual AND gate. This is how you build a computer. You figure out the functions that you need, and the truth tables for those functions, and using electronic components you actually build that function.
As the functions get more complicated, you build on the simpler functions, and use the basic logic gates to create the functions that you need. In order to build somewhat more complicated functions, you can use something called Boolean algebra. This is a useful tool for getting from the very simple logic gate circuits to more complicated functions that you may need.
Okay, now you've got truth tables, logic gates, and Boolean algebra. I'm not going to go very much further in telling you how to design circuits. If you want to design more complicated circuits, these are the terms that you should plug into a search engine, and the internet will provide you with illustrations, diagrams, courses, writeups, and even videos to teach you how to use these and, if you wish, how to start designing and building your own computer.
Once you have figured out the truth table for the function that you want, then you have to build some kind of physical device that will actually do it.
As previously mentioned, the device that you build doesn't require that it be electronic. It doesn't have to use diodes or transistors. There are many ways to make a device that will accomplish the function that you have figured out from your truth table. Charles Babbage did it with gears, for the most part. There are many ways to do it. And, just like with the Boolean algebra, you can plug a query such as "making an AND gate circuit" into a search engine, and get an awful lot of results. You might want to specify strings and pulleys, or columns of water, or some other variation, in order to see how to make a particular logic circuit using physical devices. (You also may wish to request image results for your search, so that you can quickly, and at a glance, see which ones might be most informative to you.) An awful lot of these results that you get from the search engine might be videos, and a lot of people find those very helpful.
I will give you one example here. I am going to stick with the AND gate, since we have already talked about it, and given you an image of how it looks in an electronic circuit. For this example, I found some pictures of leavers and sticks, in a setup that will give you an AND logic gate result.
Our first image, here, gives you the kind of resting state. Both of the inputs are zero, or off, or false. You will note that, over to the right, the result is zero, or off, or false.
In the next image, one of the inputs has been set to one, or true. Because the other input is still zero, the result is zero.
The third image is pretty similar, except that is the *other* input that has been set to one. The result is still zero.
In our final image, both inputs have been set to one. And, over to the right, you will note that the result is, finally, one.
So, here we have a physical device that will give us the results that we want for an AND gate, or an AND logic circuit. At the moment this may not seem too terribly useful. We need to get more and different types of logic circuits that we can use, and start using those very basic logic circuits to build more functional logics circuits that will do what we want them to do.
So we will start with some other logic basic logic circuits which will do some other logic for us. Here is a table of the symbols for those logic circuits, and I'll explain what they do.
The first one might not seem to be too terribly useful. It is known, in this table, simply as YES. It has one input, and one output. When you put an input of zero, the output is zero. When you put in an input of one, the output is one. You could be forgiven for thinking that, particularly in an electronic circuit, this particular logic gate could simply be replaced by a piece of wire.
The second one is possibly a little bit more useful. It is known as NOT. If you put in an input of zero, the output is one. If you put in an input of one, the output is zero. This is also known as an inverter. It's mostly useful in forming some of the other basic logic circuits which we will be covering in a moment.
We've already covered the AND gate, so I won't repeat that again.
The OR gate will give us an output of one if either of the inputs is one. So if both inputs are zero, the output is zero. If the first input is one, then the output is one. The same thing happens for the second input. And if both inputs are one then the output is one.
But there is another version of OR, known as XOR, or exclusive OR. For this gate, if either of the inputs is one, then the output is one. But if *both* inputs are one, then the output is zero. The operation of this gate may be a bit weird, but it is very useful. It is particularly useful in cryptography, which is why I love this particular logic circuit so much.
The remaining logic gates, NOR, XNOR, and NAND, we have, in a sense, already covered. All three of them are simply existing gates, that we have already described, with an inverter added to the end of them. It's simply the opposite of the AND, OR, and XOR for which we have already described the truth tables. The inverter simply switches the result from the gate to the opposite of what it was would be ordinarily. So, having an OR gate, and then adding a NOT after it, is exactly equivalent to a NOR gate.
The NAND gate may seem to be just a variation on this theme, but it's actually pretty special. You can use NAND Gates to build any other logic circuit. The NAND gate is, therefore, a sort of a universal component. Whatever you want to build, you can build it with a sufficient number of NAND gates. It is possible to build an entire computer, or an entire integrated chip, using only NAND functions in a variety of ways. Here is a diagram that illustrates this. You will notice that all of the basic logic gates that are used here are all, and only, NAND gates, yet we have been able to build AND, OR, and NOR circuits, using combinations of NAND gates.
Introduction and ToC: https://fibrecookery.blogspot.com/2025/12/how-computers-work-from-ground-up.html







No comments:
Post a Comment