But How Do It Know? - the Basic Principles of Computers for Everyone (5 page)

BOOK: But How Do It Know? - the Basic Principles of Computers for Everyone
9.73Mb size Format: txt, pdf, ePub

I hope you followed the wires and the ons and offs in this chapter. Once you see exactly how this thing works, you will know that these simple NAND gates can create a memory bit, and I assure you that you will never wonder about it again.

Now that we know how this thing works, we no longer need to look at that tricky internal wiring of this combination. We have seen how it works, and from now on, we will just use this diagram to represent it:

‘I’ is the input bit that you want to save. ‘S’ is the input that allows ‘i’ into the memory bit when ‘s’ is on, and locks it in place or ‘sets’ it when ‘s’ goes off. ‘O’ is the output of the current or saved data. ‘M’ stands for Memory. Pretty simple, eh?

Let’s go back to our room with the funny light switches. It had a NAND gate hooked up in it. Let’s take the NAND gate out and replace it with this new memory bit. We’ll connect the left switch to the ‘i’ wire, the right switch to the ‘s’ wire, and the ceiling light to the ‘o’ wire. We could start out with everything looking the same, that is, the light is on, but both switches are off. That would mean that at some point in the past, both ‘i’ and ‘s’ were on, and ‘s’ got turned off first, locking the then state of ‘i’ into our memory bit, which then comes out at ‘o.’ Then ‘i’ could have been switched off without affecting anything. So if we walked in and decided that we wanted to turn the light off, we would first try the ‘i’ switch, turn it on and off, and nothing would happen. Then we would try the ‘s’ switch. When we turn it on, the light would go off. Aha we say, the ‘s’ switch controls the light, but it is installed up-side-down! So then we turn the ‘s’ switch back off, expecting the light to come back on, but the light remains off. Now the switches are in the same position as they were when we entered the room, they’re both off, but now the light is off as well, boy is this confusing. Now I don’t want to speculate on how much cursing would go on before someone figured this out, but in the end they would find that when ‘s’ was on, the light went on and off with ‘i,’ and when ‘s’ was off, the light would stay the way it was just before ‘s’ got turned off.

 

What Can We Do With A Bit?

Now we have described a bit, we have shown how to build one, how to remember over time what state a bit was in at an earlier instant in time, now what? What do we do with it?

Since a bit is actually nothing more than the electricity being on or off, the only actual, real thing we can do with a bit is to turn lights on or off, or toasters or whatever.

But we can also use a bit to represent something else in our lives. We can take a bit, and connect it to a red light, and say that when this bit is on, it means stop, and when this bit is off, you may go. Or if a particular bit is on, you want fries with your burger; if it is off, you want the burger only.

This is the action of using a code. What is a code? A code is something that tells you what something else means. When something is supposed to mean something, somewhere someone has to make a list of all of the states of the ‘thing,’ and the meanings associated with each of those states. When it comes to a bit, since it only can be in two different states, then a bit can only mean one of two things. A code for a bit would only need two meanings, and one of those meanings would be associated with the bit being off, and the other meaning would be associated with the bit being on.

This is how you assign meaning to a bit. The bit does not contain any meaning in and of itself; there is no room in a bit for anything other than the presence or absence of electricity. Meaning is assigned to a bit by something external to the bit. There is nothing about traffic or French fries in a bit, we are just saying that for this bit in this place, connected to a red light hanging over an intersection, when it is on, you must stop, when it is off, you may go. Another bit, in a cash register in a fast food restaurant, means put fries in the bag when the bit is on, or no fries when it is off.

These are two cases of someone inventing a simple two-item code. In one case, the code is: bit on means fries, bit off means no fries, in the other case, bit off means go, bit on means stop. These two bits are the same, they are just used for different purposes, and someone decides what the meaning of these two bits will be. The code is written down somewhere in the law books, or in the restaurant manager’s handbook, but the code is not in the bit. The state of the bit merely tells someone which line of the code they are supposed to believe is true at the current moment. That’s what a code is.

Like the spies who pass messages by using a secret code, the message may be seen by other people, but those other people don’t have the code, so they don’t know what the message means. Maybe one spy has a flowerpot sitting on the sill in the front window of his apartment. When the pot is on the left side of the sill, it means “Meet me at the train station at 1:30.” And when the flowerpot is on the right side of the sill, it means “No meeting today.” Every day, the other spy walks down the street and glances up at that window to see whether he needs to go to the train station today. Everyone else who walks down that street can just as easily see this message, but they don’t have the code, so it means nothing to them. Then when the two spies do meet, they can pass a piece of paper that is written in another secret code. They encode and decode the message using a codebook that they do not carry when they meet. So if their message is intercepted by anyone else, it won’t mean anything to that someone else. Someone who doesn’t have the codebook won’t have the proper meanings for the symbols on the sheet of paper.

A computer bit is still, and will always be, nothing more than a place where there is or is not electricity, but when we, as a society of human beings, use a bit for a certain purpose, we give meaning to the bit. When we connect a bit to a red light and hang it over an intersection, and make people study driver’s handbooks before giving them driver’s licenses, we have given meaning to that bit. Red means ‘stop,’ not because the bit is capable of doing anything to a vehicle traveling on the road, but because we as people agree that red means stop, and we, seeing that bit on, will stop our car in order to avoid being hit by a car traveling on the cross street, and we hope that everyone else will do the same so that we may be assured that no one will hit us when it is our turn to cross the intersection.

So there are many things that can be done with a bit. It can indicate true or false, go or stop. A single yes or no can be a major thing, as in the answer to “Will you marry me?” or an everyday matter such as “Would you like fries with that?”

But still, there are many things that cannot be done with a bit, or seem to be incompatible with the idea of bits altogether. There can be many examples of yes/no things in everyday life, but there are many more things that are not a simple yes or no.

In the case of the telegraph, which was indisputably just one bit, how can there be more than two items in the Morse code? The answer is that the ability to send and receive messages depended on the skills and the memories of the operators at both ends of the wire. In the Morse Code, if the key was pressed for a very short time, that was called a “dot(.),” and if it was pressed for a slightly longer time, that was called a “dash(-).” Each letter of the alphabet was assigned a unique combination of dots and or dashes, and both operators studied the code, memorized it and practiced using it. For instance, the code for the letter ‘N’ was dash dot (-.) and the code for the letter ‘C’ was dash dot dash dot (-.-.). The length of the on times were different to make dots and dashes, and the lengths of the off times were different to distinguish between the time that separates dots and dashes within a letter, the time that separates letters, and the time that separates words. You need a longer off time to keep from confusing a ‘C’ with two ‘N’s. The receiving person had to recognize these as patterns – that is, he had to hear and remember the lengths of several on and off times until he recognized a letter. The telegraph apparatus didn’t have any memory at all, there was never even one whole letter on the wire at any one time, the pieces of letters went down the wire, to be assembled into dots and dashes in the mind of the operator, then into letters, and then into words and sentences written on a sheet of paper. So the telegraph bit achieves more than two meanings by having several individual times when there may be ons or offs.

If a computer were built on the principles of the Morse code, it would just have a light bulb on top of it flashing the code at us. Since we’d rather see whole letters, words and sentences on the screen simultaneously, we need something more than a single bit and this old code.

Even in the examples used in this chapter, real traffic lights actually have three bits, one for red, one for yellow and one for green. If you had only one bit, you could just have a red light at the intersection, and when it was on that would mean stop, and when it was off that would mean go. But when it was off, you might wonder whether it was really off, or whether the bulb had just burned out. So using three bits is a lot more useful in this case.

In the real world, we have already seen that computers can contain letters, words, sentences, entire books, as well as numbers, pictures, sounds and more. And yet, all of this does come down to nothing more than bits.

If we want our computer memory to be able to hold more than an on or off, or yes or no, we will have to have something more than just one bit. Fortunately, we can do something much more useful just by using several bits together, and then making up a code (or maybe several codes) to assign some useful meaning to them.

 

A Rose by Any Other Name

Before we go on, we are going to introduce a change to what we call something. As we know, all of the bits in the computer are places where there is or is not, some electricity. We call these states, “on” and “off,” and that is exactly what they are. Even though these are short words, there are places where it is a lot easier, clearer and simpler to use a single symbol to describe these states. Fortunately, we’re not going to invent anything tricky, we’re just going to use two symbols you already know well, the numbers zero and one. From here on out, we will call off 0, and we will call on 1. And sometimes we will still use on and off.

Thus the chart for our NAND gate will look like this:

 

 

 
a

 

 
b

 

 
c

 

 
0

 

 
0

 

 
1

 

 
0

 

 
1

 

 
1

 

 
1

 

 
0

 

 
1

 

 
1

 

 
1

 

 
0

This is very easy to understand, of course, but the point that needs to be made here, is that the computer parts have not changed, the only thing that has changed is what we, as people looking at the machine, are calling it. Just because we call a bit a zero or one, that doesn’t mean that suddenly numbers have appeared and are running around inside the computer. There are still no numbers (or words or sounds or pictures) in a computer, only bits, exactly as previously described. We could have called them plus and minus, yes and no, true and false, heads and tails, something and nothing, north and south, or even Bert and Ernie. But zero and one will do it. This is a just a simple, two item code. On means 1, and off means 0.

As a comment here, there seems to be a trend among the appliance manufacturers of the world to replace the obsolete and old-fashioned terms of on and off with the modern 0 and 1. On many power switches they put a 0 by the off position, and a 1 by the on position. The first place I saw this was on a personal computer, and I thought that it was a cute novelty, being on a computer, but now this practice has spread to cell phones, coffee makers and automobile dashboards. But I think that this is a mistake. Do you understand that the code could just as easily have been defined as “off means 1 and on means 0?” The computer would work exactly the same way, only the printing in the technical manuals that describe what is happening inside the computer would change.

When you see one of these 0/1 switches, you have to translate it back from this very commonly used computer code into what it really means, on or off. So why bother? You don’t want to turn your coffee machine ‘1’, you want the power ON so you can get your java and wake up already. Imagine putting these symbols on a waffle maker back in 1935. Nobody would have had any idea of what it meant. It is probably just so that manufacturers don’t have to have switches printed in different languages. Or maybe this trend comes from an altruistic desire to educate the public into the modern ‘fact’ that a 1 is the same as on, but it isn’t a fact, it’s an arbitrary code.

Other books

Consumed by Emily Snow
Violet is Blue (Hothouse series) by Stokes, Tawny, Anna, Vivi
Moon Thrall by Donna Grant
Abby the Witch by Odette C. Bell
That Dog Won't Hunt by Lou Allin
A Witch's Fury by Kim Schubert
The Moonstone Castle Mystery by Carolyn G. Keene