WEBVTT

00:00.440 --> 00:01.200
Hello everyone.

00:01.240 --> 00:05.480
I'm Tiffany and in this lecture we are about to explore one of the most essential operations that a

00:05.480 --> 00:09.400
CPU performs, which is the addition of binary values.

00:09.400 --> 00:13.080
And specifically we want to add two n bit binary numbers.

00:13.080 --> 00:16.480
And to begin, let's quickly revisit how binary numbers are structured.

00:16.880 --> 00:17.160
Now.

00:17.160 --> 00:25.560
As you might recall from earlier lessons, the bits in a binary number are numbered from right to left,

00:26.400 --> 00:28.520
starting with the bit position zero.

00:28.840 --> 00:39.880
So this means the rightmost bit is the least significant bit, and as you move left, the bit becomes

00:39.920 --> 00:42.040
more significant.

00:42.880 --> 00:49.320
And our approach starts with understanding how to add two individual bits at the same bit position,

00:49.320 --> 00:53.240
which we will then expand into adding multi bit binary numbers.

00:53.280 --> 00:59.840
Now we will begin by examining a simple component called the half adder, and then build up to a more

00:59.840 --> 01:03.280
complete solution using a full adder.

01:04.200 --> 01:08.440
So now we will create our truth table.

01:09.480 --> 01:15.000
Now in digital circuits we can perform binary addition using various building blocks.

01:15.000 --> 01:18.560
And one of the most basic is the half adder which you will learn here.

01:18.680 --> 01:26.200
So a half adder adds two single bit binary values, typically taken from the same position in two different

01:26.200 --> 01:27.240
binary numbers.

01:27.440 --> 01:33.960
So here we have, let's say x I y I.

01:35.200 --> 01:42.200
We will also have carry I plus one and we will also have some.

01:43.160 --> 01:47.680
You have learned what does cavalry does from previous lectures.

01:48.320 --> 01:57.360
If you have forgot it I strongly suggest go watch that lecture and if you have forgotten it again I

01:57.400 --> 02:00.070
strongly suggest go to a doctor.

02:00.950 --> 02:01.710
And, uh.

02:01.750 --> 02:02.190
Yeah.

02:03.470 --> 02:10.190
So here we will build our blocks here in the half order zero zero.

02:10.710 --> 02:11.790
Again, carry is zero.

02:11.830 --> 02:13.510
The sum is going to be zero.

02:14.550 --> 02:19.390
So and one of the most basic here this this is one of the most basic errors here.

02:19.390 --> 02:27.030
The half adder adds two single byte binary values and which is taken from the their position in the

02:27.030 --> 02:27.870
binary numbers.

02:28.310 --> 02:31.270
And this sum sum I.

02:31.310 --> 02:31.830
Here.

02:32.950 --> 02:37.350
This is the result of the addition at this bit position.

02:37.350 --> 02:40.110
So this is result.

02:41.030 --> 02:49.070
And we have the carry I plus one which is the carry out bit that will be forwarded to the next higher

02:49.070 --> 02:52.230
position or higher bit position.

02:53.190 --> 02:57.310
Now here Zero one.

02:57.510 --> 02:58.390
What carry?

02:58.430 --> 03:01.750
We will have zero and the sum is going to be one again.

03:01.990 --> 03:03.310
One zero.

03:03.350 --> 03:04.790
We have learned that in previous lectures.

03:04.790 --> 03:08.670
If you remember, if you don't go to a doctor.

03:09.230 --> 03:12.710
So one one carry is going to be one of course.

03:12.710 --> 03:14.750
So it will move to one higher bit.

03:14.830 --> 03:16.910
The one higher bit is going to be one zero.

03:16.910 --> 03:18.830
And here this is the zero here.

03:18.830 --> 03:21.670
So this is the sum is going to be zero.

03:22.750 --> 03:23.430
And yeah.

03:23.830 --> 03:34.390
And from this truth table you can see that a sum is the result of an XOR operation between x I and x

03:35.390 --> 03:35.550
I.

03:35.990 --> 03:40.670
And the carry is the result of an operation between x I and y I.

03:40.950 --> 03:45.190
Let's see 000.

03:45.190 --> 03:46.430
Now here one one.

03:46.430 --> 03:47.550
And this is one again.

03:47.550 --> 03:49.990
So this is basically and operation.

03:49.990 --> 03:50.430
Right.

03:51.710 --> 04:00.390
And here we will also write our design, our logic table for this truth table.

04:00.430 --> 04:02.950
Here it is so hard to say.

04:02.990 --> 04:03.910
Truth table.

04:03.910 --> 04:04.710
I don't know why.

04:05.150 --> 04:05.430
So.

04:05.430 --> 04:05.830
Yeah.

04:06.150 --> 04:11.750
Uh, so we will have this again one.

04:12.750 --> 04:16.630
This is basically some will give us some here.

04:17.590 --> 04:19.750
It will connect to here again.

04:20.190 --> 04:21.830
We will have another one.

04:21.830 --> 04:23.350
It will also connect to here.

04:24.790 --> 04:28.470
And at the bottom we will have a carry.

04:29.430 --> 04:30.030
So what.

04:30.430 --> 04:39.230
This is basically some I and carry I plus one.

04:40.190 --> 04:44.070
This is x I and y I.

04:45.070 --> 04:52.110
So while uh this circuit is simple and functional it has key limitations.

04:52.110 --> 04:59.340
It only handles two input bits only x I and y I, so it does not take into account the carry bit from

04:59.380 --> 05:02.660
our previous lower bit position.

05:02.660 --> 05:10.940
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,

05:11.380 --> 05:17.460
so it does not take into account the carry bit from a previous which is lower bit position.

05:17.460 --> 05:21.700
And this is where full adder comes into play.

05:22.740 --> 05:25.180
So a full adder what is the full adder?

05:25.620 --> 05:34.820
A full adder extends the concept of the half adder by introducing a third input, the carry bit from

05:34.820 --> 05:39.060
the previous stage and a full adder.

05:41.260 --> 05:46.780
Is a full adder is a digital circuit that extends the functionality of the half adder, so it takes

05:46.780 --> 05:53.780
into account not only the two bits being added to the circuit in a current position, but also carry

05:53.820 --> 05:55.620
from the previous edition.

05:55.620 --> 05:56.860
So to clarify.

05:56.900 --> 06:00.260
Suppose you are adding two multi-bit binary numbers.

06:01.980 --> 06:11.660
So when you add the bits in position zero, a carry out might be produced like this one, right?

06:11.860 --> 06:13.700
We have the carry out one here.

06:14.380 --> 06:18.620
So this carry must then be included in the addition at the position first.

06:18.940 --> 06:21.060
In this case the position first is this one.

06:21.860 --> 06:23.300
And so on so forth.

06:23.660 --> 06:25.780
It will go on like goes on like that.

06:25.820 --> 06:30.540
So basically the full adder makes this possible.

06:31.260 --> 06:34.100
So the full adder has three inputs.

06:34.100 --> 06:38.780
Let's actually instead of x and y because I hate saying x and y.

06:39.220 --> 06:44.100
Let's just say a and b I.

06:45.260 --> 06:50.260
We will have a carry at the right.

06:50.300 --> 06:54.930
The left carry I on the right.

06:54.930 --> 07:03.530
We will have carry I plus one and some I.

07:04.450 --> 07:04.650
Yeah.

07:04.690 --> 07:05.050
Basically.

07:05.090 --> 07:05.570
Basically.

07:05.570 --> 07:06.210
That's it.

07:07.130 --> 07:10.130
Now let's draw the line.

07:11.050 --> 07:14.450
1234.

07:15.610 --> 07:17.730
So it basically has two outputs.

07:18.290 --> 07:26.090
The sum I which is the result of adding carry I I and b I.

07:27.210 --> 07:38.130
And we also have the carry I plus one which is the carry out bit which will be used in the next higher

07:38.170 --> 07:39.530
order addition.

07:40.370 --> 07:43.010
Now let's actually calculate that right.

07:43.130 --> 07:49.450
So if we have a and I b I we will here have again zero.

07:49.490 --> 07:52.050
Sum is zero and the carry is zero.

07:53.130 --> 07:58.210
If you add zero one it will have zero.

07:58.530 --> 08:00.490
Sum is going to be one.

08:01.410 --> 08:02.730
Because of this one here.

08:02.730 --> 08:05.490
And then the carry I we will have zero again.

08:06.210 --> 08:10.730
If we add one and zero the result is will be pretty same.

08:11.810 --> 08:17.690
And if we add one and one we will have carry one.

08:18.050 --> 08:20.010
We will have some one.

08:20.490 --> 08:23.890
And yeah we have carry plus r.

08:23.930 --> 08:26.330
So we will add one bit to the left.

08:27.290 --> 08:31.810
And yeah in the carry we will have uh zero.

08:32.850 --> 08:40.130
And if in the carry which is the second, if in the carry if we have one and in X we have zero zero

08:40.530 --> 08:41.570
which is the addition.

08:41.570 --> 08:46.370
After this again in the carry we will have one.

08:46.530 --> 08:51.010
So what we will have here is what 011.

08:52.050 --> 08:52.890
So some some.

08:52.930 --> 08:53.290
Yeah.

08:53.330 --> 08:53.810
Sorry.

08:54.370 --> 08:55.530
This should be zero.

08:55.770 --> 08:57.250
And here we will have one.

08:58.170 --> 09:09.810
And if we add like zero one and we have the carry my one here again here what we will have, it's one.

09:10.730 --> 09:16.690
And again here we will basically have the one.

09:16.730 --> 09:18.450
We will have zero of the sum.

09:19.450 --> 09:24.050
And here if we have we have 10001.

09:24.090 --> 09:29.850
Now we one zero carry is going to be one because of this.

09:30.570 --> 09:39.530
And here we will again have 00110 and 1111.

09:40.210 --> 09:47.010
Again here in the carry will have one in the carry I we will have one.

09:47.480 --> 09:50.240
and in the sum we will have one.

09:50.520 --> 09:54.680
So this table shows all possible input combinations.

09:54.680 --> 10:02.200
And as you can see, when 1 or 3 of the inputs are one, the sum is one.

10:02.920 --> 10:10.440
When exactly two of the inputs are one a carry here is generated here.

10:11.640 --> 10:12.120
So here.

10:13.400 --> 10:16.360
Now from this we derive a logical equation.

10:17.000 --> 10:25.480
So sum equation is basically sum I equals carry I xor.

10:26.400 --> 10:28.160
You will learn XOR later.

10:29.120 --> 10:34.920
X a and xor b I.

10:35.960 --> 10:42.280
So this equation here basically shows the sum of sum is one.

10:42.280 --> 10:46.520
If an odd number of the three inputs are one.
