Computers operate by Boolean logic, invented by the 19th century English mathematician George Boole. Everything is done with base 2, so there are only the numerals one and zero, or true and false. The three basic operations are invert (the output is the opposite of the input), AND (true only if all inputs are true), and OR (true if any input is true). It’s possible to express any arithmetic function in terms of Boolean logic, and to translate back and forth from base two to base ten. From the biggest computer to the smallest calculator, this is what’s happening behind the scenes.

The distinction between AND and OR is very important in this scheme. For example, if you were to send a computer to the supermarket to fetch cans of peas and corn and carrots, it would look for all three in one can. You would have to say you wanted cans of peas or corn or carrots to get them in separate cans, and it might come back with only one or two types.

Another example: If you had a gate secured with a chain and three locks, you could have the locks in series, in which case opening any one lock would release the chain (an OR function), or you could have the locks in parallel, in which case you would need to open all three locks to release the chain (an AND function).

The most common type of digital (that is, computer) chip is called CMOS, for Complimentary Metal Oxide Semiconductor. The important part to understand is “complementary,” that is, both positive (P-channel) and negative (N-channel) transistors are used. Since opposite electrical or magnetic charges attract, P-channel transistor switches are turned on by a negative (zero) voltage on the control, and N-channel transistor switches are turned on by a positive voltage on the control. Think of the positive and negative as one and zero, true and false, or as the positive and negative terminals of an ordinary battery.

The simplest structure of computer logic in CMOS is the inverter, which consists of a P-channel and an N-channel transistor in series between the positive and negative terminals of the battery, and with their controls (or “gates”) connected together. The same control voltage that turns the top transistor on turns the bottom transistor off, and vice-versa. That’s the “complementary” part. So the result, taken at the point in the middle where the two switches meet, is that the output is connected to the positive of the battery through the P-channel, or to the negative of the battery through the N-channel. There’s never a time when both switches are on or off. Now, since the switches are turned on or off by the opposite charge, having the P-channel switch on top means that when the input is false, the output is true. In other words, the input gets inverted.

That’s useful, but not sufficient. We need more. The next simplest structure is NAND, which is the AND function with the output inverted (in other words, false only if all inputs are true). For a two input NAND, add to the inverter a P-channel transistor in parallel with the existing P-channel, and an N-channel in series with the existing N-channel, with the gates of both new transistors connected together to form the second input. The output can connect to zero only with both N’s on and both P’s off. With any other combination, at least one N will be off and at least one P will be on. For a NOR, put the P’s in series and the N’s in parallel.

At its heart, the design of digital circuits is simply connecting lots of copies of these basic functions together.

Advertisements