My 10/05/08 Missoulian column
We say we think logically when we figure out problems step-by-step and by trial and error. If our truck won’t crank over in the morning, before we call the tow truck we might turn the headlights on to see if the battery has a charge. We know that the starter runs off the battery, and if the lights don’t come on we know the battery might be dead and so maybe we can get a jump start from the neighbor.
But if the lights are bright, we know that there’s juice in the battery and we can deduce that the problem might be with the starter. Time for a tow truck. But we might try something like jiggling some loose wires under the dash, and if we find that the truck will crank over, we know that there’s a loose connection in those wires and maybe we can get to work and back a few more times by jiggling the wires.
The digital logic in computers also makes decisions in logical steps, but very simple decisions using only the “ones” and “zeros,” the building blocks of digital information. The “decisions” a computer makes are the result of built-in logic in the form of “gates,” the building blocks of logic. Software tells the gates what to do with ones and zeros – which numbers to add, what to put into memory, what to record on a hard drive – and the logic gates make simple decisions depending on the ones and zeros they are given to work with. All those decisions happen in millionths of a second and result in the Web browser running correctly and giving us the Web page we want to see.
Basic computer logic works with three different kinds of gates, and we can draw a metaphor for how differently they work with light switches and light bulbs. The first type of logic gate needs two different switches thrown at the same time in order to light the room; not one or the other, but both at the same time. The second type of gate needs just one or the other switch thrown to light the room, but is also quirky in that it will also light the room if both switches are on. And the third type of gate has just one switch, but it works in a particular way: the light is on when the switch is off, and the light is off when the switch is on.
These three types are called AND, OR and NOT gates, and from those names it might already be obvious which is which. Now, thinking of the way digital computers work – with ones (the light is on) and zeros (the light is off) – an AND gate looks for ones at both of the inputs; an OR gate looks for a one at either of two inputs; and a NOT gate reverses whatever is at the input. And so each of these gates makes a very simple logical decision based on binary states: one or zero, or, like the lights and switches, on and off.
But with lots of these gates put together in complicated patterns, much more complex decisions can be made, and with those three basic types of gates – and special “hybrids” based on those three – all of the functions of a computer can be made to work. Those hybrids can be NAND or NOR gates, which work like AND or OR gates, but opposite; or they can be “counters” that count in binary, or they can be very simple memory banks called registers. But they all begin with the simple AND, OR and NOT gates. Put hundreds of thousand or millions of gates together and you have a modern microprocessor. Logic gates – Wikipedia.
All of the different kinds of gates come to life in the circuitry of a computer by way of tiny components like transistors and other electronic goodies. Transistors serve as electronic switches like the flipping of light switches on or off. Transistors sense either a one or a zero at the handle of the gate and respond – or not – depending on which kind of gate.
Like anything high-tech, logic gates have shrunk in size over the years. The first logic gates were made from vacuum tubes and took up buildings and used whole power plants of electricity. Then the transistor came in during the 1950s, and gates became smaller and used much less electricity. Then the first integrated circuit – with lots of transistors on one chip – was invented in the late 1950s, and a bunch of gates could fit in half a square inch and run from a battery. Now, the average microprocessor in your PC has hundreds of thousands – or more – gates on one chip. Moore’s Law says that the number of transistors that can be put on an integrated circuit doubles approximately every 18 months, and that is expected to remain true for possibly another decade.
With all those millions of switches making up logical gates, does computer logic make “mistakes”? Yes, if the logic is not correct to begin with. Millions of dollars go into testing microprocessors before they go out into the real world in a PC. But in 1994, Intel shipped a brand-new Pentium processor that had a subtle flaw in the logic of the the chip. Mathematicians soon discovered that in very rare cases, the chip gave wrong results in complex calculations. The flaw was traced to just a few gates on the chip, and while very few people would notice, competition was very real in the growing microprocessor business, so the Pentium chip was recalled and free replacements offered.
And, rarely, cosmic rays and other forms of background radiation can cause logic glitches. Modern logic gates are made of transistors and components so small that a particle of naturally occurring background radiation can “flip” the value of a gate – from one to zero or from zero to one – and result in wrong data or a “freeze up.” But built into many forms of computer logic and memory circuits are other types of logic that perform error correcting, and so when a “check sum” doesn’t add up, the logic “knows” something is wrong and recalculates, or tells you with an error message.
So between the logical complexities and error correcting, sometimes you won’t even know the once-in-a-billion-time that a tiny bit of logic in your PC happens to make a wrong logical decision. But if you deduce wrongly the logical reason why your truck will or won’t start, you’ll know it right away.