Inside a computer, you'll find a motherboard.
The motherboard acts like the chassis
inside a car, giving all the components something to connect to. On the motherboard
is the microprocessor. Most microprocessors have some jagged metal on top called a
heat sink to prevent overheating. If you remove the microprocessor and look
underneath, you'll see a lot of wires sticking out that connect from the holes on
the motherboard to the main part of the microprocessor.
The microprocessor is made up of different areas that do different things, such as
adding or storing numbers. These areas are mostly made up of one thing though, the
transistor. Here is a 3 d view of 1. The transistor's base is a semiconductor,
which sometimes conducts electricity and sometimes does not. The semiconductor has
positively charged areas and negatively charged areas.
Electricity will not flow between the 2 yellow areas unless a conducting channel is
opened up in the green area. A conducting channel is opened up in the semiconductor
when a conductor, such as metal, is placed above the gap, wrapped in an insulator
like glass, and electrified. For electricity to flow through the conducting channel
between the yellow areas, there must be a source and a drain. In other words, an
input and an output. These are both made from conductors as well, like metal.
If the input is charged, it cannot flow to the output unless the gate, which is the
piece of metal in the middle, is also charged. When the gate is charged, it opens
up the conducting channel in the semiconductor, allowing electricity to flow down
through the source, over to the other side of the semiconductor, and back up out
the drain. The neat thing about this setup is that there are no moving parts, and
you are using electricity alone to turn on and off other electricity. The
breakthrough idea with this technology was using it to form logic gates. For
instance, if you have 2 transistors, and you add power to the inputs of each
transistor, and then add switches to each of the gates, and allow the outputs to
both flow directly to a light bulb, you have created an OR gate, which has this
symbol.
Turn the left switch on, or the right switch on, or even both switches on, and the
light bulb turns on. If you change the wiring so that the output wire of the first
transistor runs to the input wire of the second transistor, then you've created an
AND gate, which has this symbol. With an AND gate, if you only turn the left switch
on, then the light bulb is not on, because the electricity coming from the first
transistor is stopped at the second transistor. If you only turn the right switch
on, the light bulb is not on because there is no electricity flowing through the
first transistor to reach the input of the second transistor, so the light bulb
does not turn on. Both switches must be on in an AND gate for the output to be on
as well.
On and off can be represented in the case of the switches as 0, off, and 1, on.
Same with the light bulbs, off or on, 0 or 1. Zeros and ones are the language of
computers, and they make up their own numbering system called binary. Let's start
counting in our normal decimal system, and make a note of any binary numbers that
we run across. In other words, any numbers that only have 1s and 0s in them.
So to begin, we record 0, because it only has 1s and 0s in it. Same with 1. We have
to wait to record another number in binary until we get to number 10. Then 11
works, 12 does not, 13 no, 14 no. In fact, we can count by 10s at this point,
because we won't see another number with only 1s and 0s until we get to 100.
But then 101 works, and then nothing again until 110 and 111. And we won't see all
1s and 0s again until we get all the way up to 1,000. Well, let's move that 1,000
over and down, and keep counting up in binary. To do this, all we have to do is
just repeat the numbers from the right column into the left column, except for the
first digit, to see all the numbers above 1,000 in binary. So 1,001, 1010,
1011,1100, 1101, 1110, 1111.
Now, let's move those numbers back up, and then into the middle of the screen,
where we can spread them out and add light bulbs underneath them. If you'll
remember from earlier, we can represent binary numbers with light bulbs that are 0
if off, and 1 if on. So we start with all 0s, or all light bulbs off, then move to
1, where only the light bulb on the far right is on, and then 10, which is the same
as the number 2 in decimal. Remember, we only have 2 symbols to use in binary, 10.
This means that we have to count up a little differently than we do when we use
decimal numbers.
11 is 3 in decimal, because it's the 3rd binary number. 100 is 4, and on, and on,
and on. In fact, let's make this easier. When only one light bulb is on, let's
write the decimal number that it represents on the light bulb itself. For instance,
1 in binary is also 1 in decimal, so we'll write that on that light bulb.
10 in binary is 2 in decimal. 100 in binary is 4 in decimal. And 1000 in binary is
8 in decimal. From here, you just have to add up the numbers in the light bulbs
that are lit to find the equivalent number in decimal. So for instance, 1001 is the
8 light bulb plus the 1 light bulb, which means it's 9 in decimal.
One010 is the 8 light bulb, plus the 2 light bulb, which is 10 in decimal. And
finally, 1011 is the 8 light bulb, plus the 2 light bulb, plus the 1 light bulb,
which is 11 in decimal. So 1+1 in binary equals 10, which is 2 in decimal. Since
switches can also represent 1s and 0s, let's put 2 switches on the left and then an
adding machine in the middle to see how we can do this with the logic gates we made
earlier. This adding machine is called a full adder, because it's made up of 2 half
adders, and we'll see why in just a minute.
Now inside the half adder, it's easy to hook up the switches to the left light
bulb. All we have to do is use an and gate. Both switches then have to be on for
the left light bulb to be on. Now to turn on the right light bulb, we'll use what's
called an exclusive OR gate, which is represented by the letters XOR. The exclusive
OR gate acts just the way you would expect.
Either one switch or the other switch has to be on exclusively for the output to be
on as well. If both switches are on, or if both switches are off, the output will
be off. Now, what makes up this exclusive OR gate? Well, it's an OR gate, a NAND
gate, and an AND gate. Well, what's a NAND gate?
That's just an AND gate with a NOT gate on the back end. A NOT gate just flips
whatever the output is to its opposite. In other words, the NAND gate is only off
if both inputs are on, the exact opposite of the AND gate. This is the key part of
the exclusive OR gate. Now let's see how this works when we turn just the top
switch on.
The OR output in the exclusive OR gate is on, and the NAND output is on, so the AND
output is on as well, and therefore the right light bulb is on. Now if we turn the
top switch off and the bottom switch on, we'll get the exact same result. If both
switches are on though, the exclusive OR gate is off, but the separate AND gate
below it is on, causing the left light bulb to be on. In other words, 1 plus 1
equals 10. In reality though, when you add decimal numbers, such as 7 and 7 to get
14, the 1 is considered the number that has to be carried to the next column.
And in fact, that's just how it works with binary as well. Normally you would have
several full adders right next to each other. The left light bulb next to our full
adder would actually be the number that carries to the next full adder. So let's
remove the left light bulb and run that wire down to the next full adder as the
carry out, while at the same time accepting a carry in wire from the previous full
adder. This carry in wire is why we need another half adder in order to make our
full adder.
The 2 separate and gates in our half adders connect to an additional or gate at the
bottom right, which then powers our carry out wire. So here, our 2 switches are
already on. And if the carry in wire from the previous adder is also turned on,
then we are essentially adding 1 plus 1 on our 2 switches, plus the 1 on the carry
in wire, or 1 plus 1 plus 1, which in binary equals 11, or 3 in decimal. The 11 can
be seen here because our light bulb is on and our carry out wire is on as well. If
we turn off the carry in wire and turn off our 2 switches, then our output wires
are off as well.
Now let's just focus on the full adder as a unit, which we'll just call an adder
from this point on, and let's label the wires. We'll use A and B to represent the
input from our 2 switches, and some to represent the wire to the light bulb. Now,
let's remove the switches and the light bulb, turn the adder on its side, rearrange
our labels, and then zoom out. Now we have 8 adders next to each other, and let's
label them from right to left with letters, so that we can talk about them
separately. We'll add 2 switches above each of our adders to represent our A and B
inputs, and then we'll connect a light bulb to each of our sum outputs.
The light bulbs again can be labeled with their decimal equivalents: 1, 2, 4, 8,
and then you just keep multiplying by 2. 8 times 2 is 16, times 2 is 32, 64, and
128. Let's now add an area on the left to see what we're doing. We'll first put the
binary numbers that our switches and light bulbs represent, and then a plus sign to
represent the adders, and then we'll add the equivalent numbers in decimal form.
Finally, we'll put numbers on the adders themselves, showing the current state of
each wire coming into the adder and going out, 0 or 1, off or on.
Now let's see what happens when we add 1+1. Well, in adder A, the A and B inputs
are both 1, and the carry in wire is off. So it's 1 plus 1 plus 0, which in binary
equals 10, causing the carry out wire to be on and the sum wire to be off. So then
in adder B, the A and B inputs are 0, but the carry in input is 1. So the sum line
on adder B is on, causing the 2 light bulb to light up.
So 1 plus 1 equals 2. You'll begin to see a little bit more about how this works as
we do some more examples. Let's look at 2+2. In adder A, none of the inputs are on
in this case, so neither the sum nor the carryout wire is on. Adder B though, has
inputs A and B on, so the carryout wire from adder B is on, which then becomes the
carry in wire to adder C, causing the 4 light bulb to light up, showing that 2 plus
2 equals 4.
3 plus 3 causes adder A on the far right to carry out a 1, which then causes adder
B to have to add 1 plus 1 plus 1, which in binary equals 11. So both the sum wire
of adder B and the carry out wire of adder B are on, causing the light bulbs under
adder B and under adder C to both be on. So 3 plus 3 equals 6. Let's look at a few
more examples for you to consider on your own. We won't talk through these, but
feel free to pause the video and take a longer look if you'd like.
Here is 10 plus 10. Now let's look at 15 +12, and finally 219 +36, which adds up to
the maximum of our light bulbs, 255. Now this kind of thing happens millions of
times a second inside of the microprocessor that fits on the motherboard inside of
your computer. So now you've seen how computers add numbers in one lesson.