Online Book Reader

Home Category

Code_ The Hidden Language of Computer Hardware and Software - Charles Petzold [39]

By Root 1508 0
you are a strange kid.) Little do you realize that you're about to make a crucial conceptual breakthrough. You're about to perform some experiments that will unite the algebra of George Boole with electrical circuitry and thus make possible the design and construction of computers that work with binary numbers. But don't let that intimidate you.

To begin your experiment, you connect a lightbulb and battery as you would normally, but you use two switches instead of one:

Switches connected in this way—one right after the other—are said to be wired in series. If you close the left switch, nothing happens:

Similarly, if you leave the left switch open and close the right switch, nothing happens. The lightbulb lights up only if both the left switch and the right switch are closed, as shown on the next page.

The key word here is and. Both the left switch and the right switch must be closed for the current to flow through the circuit.

This circuit is performing a little exercise in logic. In effect, the lightbulb is answering the question "Are both switches closed?" We can summarize the workings of this circuit in the following table:

Left Switch

Right Switch

Lightbulb

Open

Open

Not lit

Open

Closed

Not lit

Closed

Open

Not lit

Closed

Closed

Lit

In the preceding chapter, we saw how binary digits, or bits, can represent information—everything from numbers to the direction of Roger Ebert's thumb. We were able to say that a 0 bit means "Ebert's thumb points down" and a 1 bit means "Ebert's thumb points up." A switch has two positions, so it can represent a bit. We can say that a 0 means "switch is open" and a 1 means "switch is closed." A lightbulb has two states; hence it too can represent a bit. We can say that a 0 means "lightbulb is not lit" and a 1 means "lightbulb is lit." Now we simply rewrite the table:

Left Switch

Right Switch

Lightbulb

0

0

0

0

1

0

1

0

0

1

1

1

Notice that if we swap the left switch and the right switch, the results are the same. We really don't have to identify which switch is which. So the table can be rewritten to resemble the AND and OR tables that were shown earlier:

Switches in Series

0

1

0

0

0

1

0

1

And indeed, this is the same as the AND table. Check it out:

AND

0

1

0

0

0

1

0

1

This simple circuit is actually performing an AND operation in Boolean algebra.

Now try connecting the two switches a little differently:

These switches are said to be connected in parallel. The difference between this and the preceding connection is that this lightbulb will light if you close the top switch:

or close the bottom switch:

or close both switches:

The lightbulb lights if the top switch or the bottom switch is closed. The key word here is or.

Again, the circuit is performing an exercise in logic. The lightbulb answers the question, "Is either switch closed?" The following table summarizes how this circuit works:

Left Switch

Right Switch

Lightbulb

Open

Open

Not lit

Open

Closed

Lit

Closed

Open

Lit

Closed

Closed

Lit

Again, using 0 to mean an open switch or an unlit lightbulb and 1 to mean a closed switch or a lit lightbulb, this table can be rewritten this way:

Left Switch

Right Switch

Lightbulb

0

0

0

0

1

1

1

0

1

1

1

1

Again it doesn't matter if the two switches are swapped, so the table can also be rewritten like this:

Switches in Parallel

0

1

0

0

1

1

1

1

And you've probably already guessed that this is the same as the Boolean OR:

OR

0

1

0

0

1

1

1

1

which means that two switches in parallel are performing the equivalent of a Boolean OR operation.

When you originally entered the pet shop, you told the salesperson, "I want a male cat, neutered, either white or tan; or a female cat, neutered, any color but white; or I'll take any cat you have as long as it's black," and the salesperson developed this expression:

(M x N x (W + T)) + (F x N x (1 – W)) + B

Now that you know that two switches wired in series perform a logical AND (which

Return Main Page Previous Page Next Page

®Online Book Reader