Hello everyone.
I'm Tiffany and in this lecture we are about to explore one of the most essential operations that a
CPU performs, which is the addition of binary values.
And specifically we want to add two n bit binary numbers.
And to begin, let's quickly revisit how binary numbers are structured.
Now.
As you might recall from earlier lessons, the bits in a binary number are numbered from right to left,
starting with the bit position zero.
So this means the rightmost bit is the least significant bit, and as you move left, the bit becomes
more significant.
And our approach starts with understanding how to add two individual bits at the same bit position,
which we will then expand into adding multi bit binary numbers.
Now we will begin by examining a simple component called the half adder, and then build up to a more
complete solution using a full adder.
So now we will create our truth table.
Now in digital circuits we can perform binary addition using various building blocks.
And one of the most basic is the half adder which you will learn here.
So a half adder adds two single bit binary values, typically taken from the same position in two different
binary numbers.
So here we have, let's say x I y I.
We will also have carry I plus one and we will also have some.
You have learned what does cavalry does from previous lectures.
If you have forgot it I strongly suggest go watch that lecture and if you have forgotten it again I
strongly suggest go to a doctor.
And, uh.
Yeah.
So here we will build our blocks here in the half order zero zero.
Again, carry is zero.
The sum is going to be zero.
So and one of the most basic here this this is one of the most basic errors here.
The half adder adds two single byte binary values and which is taken from the their position in the
binary numbers.
And this sum sum I.
Here.
This is the result of the addition at this bit position.
So this is result.
And we have the carry I plus one which is the carry out bit that will be forwarded to the next higher
position or higher bit position.
Now here Zero one.
What carry?
We will have zero and the sum is going to be one again.
One zero.
We have learned that in previous lectures.
If you remember, if you don't go to a doctor.
So one one carry is going to be one of course.
So it will move to one higher bit.
The one higher bit is going to be one zero.
And here this is the zero here.
So this is the sum is going to be zero.
And yeah.
And from this truth table you can see that a sum is the result of an XOR operation between x I and x
I.
And the carry is the result of an operation between x I and y I.
Let's see 000.
Now here one one.
And this is one again.
So this is basically and operation.
Right.
And here we will also write our design, our logic table for this truth table.
Here it is so hard to say.
Truth table.
I don't know why.
So.
Yeah.
Uh, so we will have this again one.
This is basically some will give us some here.
It will connect to here again.
We will have another one.
It will also connect to here.
And at the bottom we will have a carry.
So what.
This is basically some I and carry I plus one.
This is x I and y I.
So while uh this circuit is simple and functional it has key limitations.
It only handles two input bits only x I and y I, so it does not take into account the carry bit from
our previous lower bit position.
You remember if it was one and one we will as a carry we will get one, but the sum is going to be zero,
so it does not take into account the carry bit from a previous which is lower bit position.
And this is where full adder comes into play.
So a full adder what is the full adder?
A full adder extends the concept of the half adder by introducing a third input, the carry bit from
the previous stage and a full adder.
Is a full adder is a digital circuit that extends the functionality of the half adder, so it takes
into account not only the two bits being added to the circuit in a current position, but also carry
from the previous edition.
So to clarify.
Suppose you are adding two multi-bit binary numbers.
So when you add the bits in position zero, a carry out might be produced like this one, right?
We have the carry out one here.
So this carry must then be included in the addition at the position first.
In this case the position first is this one.
And so on so forth.
It will go on like goes on like that.
So basically the full adder makes this possible.
So the full adder has three inputs.
Let's actually instead of x and y because I hate saying x and y.
Let's just say a and b I.
We will have a carry at the right.
The left carry I on the right.
We will have carry I plus one and some I.
Yeah, basically.
Basically that's it.
Now let's draw the line.
1234.
So it basically has two outputs.
The sum I which is the result of adding carry I, I and by and we also have the carry I plus one which
is the carry out bit which will be used in the next higher order addition.
Now let's actually calculate that right.
So if we have a and I b I we will here have again zero.
Sum is zero and the carry is zero.
If you add zero one it will have zero.
Sum is going to be one.
Because of this one here.
And then the carry I we will have zero again.
If we add one and zero the result is will be pretty same.
And if we add one and one we will have carry one.
We will have some one.
And yeah we have carry plus r.
So we will add one bit to the left.
And yeah in the carry we will have uh zero.
And if in the carry which is the second, if in the carry if we have one and in X we have zero zero
which is the addition.
After this again in the carry we will have one.
So what we will have here is what 011.
So some some.
Yeah.
Sorry.
This should be zero.
And here we will have one.
And if we add like zero one and we have the carry my one here again here what we will have, it's one.
And again here we will basically have the one.
We will have zero of the sum.
And here if we have we have 10001.
Now we one zero carry is going to be one because of this.
And here we will again have 00110 and 1111.
Again here in the Caribbean will have one in a carry I we will have one.
and in the sum we will have one.
So this table shows all possible input combinations.
And as you can see, when 1 or 3 of the inputs are one, the sum is one.
When exactly two of the inputs are one a carry here is generated here.
So here.
Now from this we derive a logical equation.
So sum equation is basically sum I equals carry I xor.
You will learn XOR later.
X a and xor b I.
So this equation here basically shows the sum of sum is one.
If an odd number of the inputs are one.