(formerly at George Teston's Harvard account: http://people.fas.harvard.edu/~gteston)
I programmed these applets in Java to
demonstrate the "science behind the machine," or rather
the seminal concepts of computer science. Most of my Information
Technology students approach the computer from a very
application-driven perspective, leaving the theoretical
constructs to the field of computer science. But, a solid
understanding of these concepts will transform you from simply
knowing what the computer can do, to knowing how it
is able to do it.
| Do you Speak Binary? |
Computers, despite their apparent complexity, are only really able to understand two things: whether electricity is on or whether it is off. Since it is only able to process these 2 states, the Binary (Base-2) number system is used to represent computer logic. Unlike the Base-10 number system we use (10 digits), computers operate with only 2 digits: 0 (off) or 1 (on). Each of these numbers is called a Bit (Binary digIT). The computer understands these 1's and 0's as a pattern, which represents ordinary data to us. A block of 8 bits is known as a byte, and can represent letters. For example, an S entered from the keyboard is actually understood as 01010011 to the computer. Every letter, color, sound and decision the computer makes is really these on or off patterns, which we represent as 1's and 0's for our convenience. In fact, the page you are reading right now is being displayed because the processor understands the electrical pattern for all of the text and images I've presented here. Further, your latest e-mail, favorite MP3, even the last DVD you watched are all simply stored versions of this on-off pattern. If you use a cell phone, even your conversation is "digital" (1's and 0's).
To better understand how a computer's processor functions, let's examine a rather "simple" task: addition. In the Decimal number system, you can count until you've exhausted all of the digits, then you start over with the lowest digit while holding place value by adding a new digit to the left. Computers count in binary the same way, only with 2 numbers. For example: 0, 1, 10, 11, 100, 101, 110, 111, etc. Once you can effectively count in Binary, you can perform Binary addition. Just as 1+1=2 in Decimal, 1+1=10 in Binary. What? Look at the counting series above and count 1 position from 1 (i.e. 1+1). In Decimal 1+1+1=3, but in Binary 1+1+1=11. The rest is elementary; you simply add and carry for place-value as you would with any number.
| 1011011 +100111 -------- 10000010 |
1 + 1 = 0 (carry
one) 1 + 1 (+ the carry) = 1 (carry one) 0 + 1 (+ the carry) = 0 (carry one) 1 + 0 (+ the carry) = 0 (carry one) 1 + 0 (+ the carry) = 0 (carry one) 0 + 1 (+ the carry) = 0 (carry one) 1 + 0 (+ the carry) = 0 (carry one) |
|
| I programmed a game to the right on which you can practice your Binary Addition skills. The game will generate random binary numbers and help coach your addition skills by showing you the correct sum should you answer incorrectly. Once you've become good at this, you should note the binary values for 2,4,8,16,32, etc. You'll notice a pattern of 10,100,1000,10000,100000. Why? These are...21,22,23,24,25, etc. (the multiples of the binary system). | ||
Whether processing addition or calculus,
the operational unit for the computer will always be a 1 or 0.
(We've simply programmed it to show us the results in
Base-10, because that is what we are taught to understand. Even
you alarm clock counts in binary...it simply displays base-10
digits for our convenience!
| How do you make electricity do arithmetic? |
Remember creating a simple circuit in
elementary school...with just a battery, bulb, and enough wire to
construct a loop of current? The presence or lack of electricity
controlled the "output" (the bulb's light).
Let's examine a simple integrated circuit capable of addition.
Every computer circuit can be represented by logic gates. The
more complex the circuit, the more logic gates it contains. The
logic behind electricity is simple: either you have it or you
don't. If it has current, we represent the state with 1 or True.
If it lacks current, the state is 0 or False. (Actually it is
based on threshold voltage levels where below the minimum is
considered off and above the minimum is considered on.)
Let's consider the building blocks of Digital Logic. Consider
these "truth tables" and evaluate the 1's as True and
the 0's as False. If A is true AND B is false, then A AND B
aren't both true (remember the "and") so the result is
False. The logic of AND and OR computer gates is the same as
regular language logic.
and| 0 | 1 |
AND Output: 1 only when both inputs are 1 |
or |
0 | 1 |
OR Output: 1 when either or both are 1 |
not|
0 | 1 |
NOT Output: 1 when 0 or 0 when 1 |
nand|
0 | 1 |
NAND Output: Negation of AND |
nor|
0 | 1 |
NOR Output: Negation of OR |
xor|
0 | 1 |
XOR Output: 1 when either is 1, but not when both arguments are 1 |
Remember, the point of these symbols is to represent the logic that allows us to control the flow of electricity...whereby the computer will have different outputs. We can combine them to control the electricity in a more complex ways...to achieve a greater variety of outputs. In fact, we simply keep combining them until we construct integrated circuits, whole mother boards, and processors. Just consider our Addition Task...
| STEP 1. Combine 3 AND gates, 2 NOT gates and an OR gate. This circuit is able to Add 2 binary numbers! How? The 2 points at the top are where current can be supplied. In this example, both points are ON. (1 + 1). Recall that 1+1 in binary is (0, carry the 1). In fact, the circuit has produced just that. Our outputs are: a OFF at the bottom and the left point was turned ON (the carry forward bit). This is known as a "Half Adder." STEP 2. STEP 3. |
screen-capture from X-LogicCircuits |
| Try Digital Logic Gates Yourself |
| To the right is a "4-Bit
Adder" circuit. The Integrated Circuit in the center
holds the internal complexity that we discussed above in
Step 3. Within it are 24 AND gates, 16 NOT gates, and 12
OR gates - all working in concert to control the flow of
electricity such that the resulting current (or lack of)
can represent our previous "additions" of
electricity. Click the green box to use the virtual circuit I created for you in Java. (Requires Java-enabled browser.) I programmed this "4-Bit Adder" circuit using Java. You can control the inputs at the top by clicking to turn the electricity on or off. The results will appear at the bottom and any possible carry-forward output will appear in the lower right corner. Compare what you enter to the Binary addition skills you practiced above. Notice how the circuit is indeed able to add the Binary numbers! Why the XOR gates and the top left input? You'll notice where I'm expanding this 4-bit adder with XOR gates and an input that will act as a "switch." While I currently have this layer of the circuit disabled, it will eventually use the 4-bit Adder to do Subtraction. Since you already know that repeated subtraction can yield division, our little Circuit can continue to grow with additional logic gates to do even division, multiplication, quadratic equations, etc. What if a speaker or printer were interfaced to the output points? Would be eventually be able to make music or pictures? You Bet! |
Provide input at the top. Results appear at the bottom. |
| Layered Complexity Makes it Possible |
![]() |
You can see that the complexity
has grown already and this circuit can only add two 4-bit
numbers. Now imagine
shrinking that circuit so that hundreds are compacting
into a single transistor. Now consider that Intel is able
to pack over 400 million transistors onto a single chip
the size of your small fingernail! The photo to the left
shows the complexity of the Pentium chip. Despite its
staggering complexity, the essence of how it operates is
simply by layering circuits upon circuits for specialized
functions - all differentiating the flow of electricity
millions of times each second. |
Sources: Leitner, H and Malan, D., (2006). Harvard University Dept. of Computer Science
Gaddis, T. (2005). "Java 5 Early Objects"
Zhang, J. (2006). TAMS: Technische Aspekte Multimodaler Systeme
Eck, D. (1997). "The Most Complex Machine."
Intel Corp. image library