Placeholder Image

Subtitles section Play video

  • So if we want to add 28 plus 22 it's pretty simple.

  • Eight plus two is 10.

  • So we put zero down here, carry the +11 plus two plus two is 5 50 Okay, simple enough.

  • Now, if we want to do that with binary, it actually works pretty much the same way.

  • So we line up all of our columns and 28 in buying areas.

  • 11100 22 is 10110 So we've got that converted.

  • We lined up.

  • The columns were just go column by column.

  • So zero plus zero is zero zero plus one is one.

  • One plus one in buying areas is too.

  • But we don't have to invite Mary, so it's we write it is 10 So the same thing we did here with the 10 here we do it the same thing.

  • So we put a zero down here and carry a one, and that's how we write to here again.

  • We got one plus one plus zero, which is to s o.

  • We write that in binary again by carrying the one and putting the zero down here on then Finally, one plus one plus one is three.

  • And in binary, the three is 11 Um, and here we we end up with the binary representation of 50.

  • So this the same algorithm works in any base kind of cool.

  • And so if we want to build ah, you know, a circuit that does this for us, Really?

  • There's only it's actually a lot easier, I think.

  • Then then regular arithmetic, because you only need to know a couple of facts on this is everything you need to know.

  • And so, if you could build a circuit that does all of this, um, then you can add a single column because you've got the A and B, which is the just the first number in the second number.

  • And then you might also have this this one, that sort of Carrie's in from the previous.

  • So if you've got all that, then uh, then we should be able to to add some numbers.

  • So let's think about how we would build a circuit that it kind of does this and one way to do it is just kind of break down.

  • Um, you know, inputs and outputs.

  • So we have the inputs A and B.

  • Um And then we have these two outputs, which are the sum that you put down here at the bottom and then the Kerry.

  • So we'll call this the carry bit because you would carry that bit over to the next column.

  • So if we look just at the case here where we've got two numbers that we're adding, so we haven't carried something in from a previous column and we look just at the number that we're putting down the bottom here, um, this actually looks a lot like an exclusive or right, Because if a or B is a one, then this last bit here is a one.

  • If a war P is a one, but not both.

  • So we can actually start to build this right?

  • We could have exclusive or gate here.

  • This is how you draw an exclusive or and we have our A and R B coming in and coming out is gonna be this right here.

  • Now, what about the second bit?

  • The carry bit here?

  • Well, this is also pretty simple, because it's always gonna be zero and less A and B are one, and so That's just an and gate.

  • So I could have an and gate here, hand gate and just take this same A and B input that we had over here.

  • Bring it into the end gate.

  • And this will be this.

  • Ah, this bit here that we would potentially carry over into the next column.

  • And so this actually is enough to add two numbers.

  • This this covers all of these cases here because we have our A and R B importer, two inputs and we have our two outputs here.

  • This is the first output, and then this here is the the second output.

  • It gets a little bit more complicated now if we have a carry coming in from a previous column, because it's not enough to just be able to add two digits because as soon as we could to this one plus one, Then we have to carry a one to the next column.

  • And in the next column, we have to deal with three numbers.

  • So, um, let's just gonna add this case where we have to carry that might be a one.

  • Well, in that case again, if we look at the last column here um, it's it's actually the inverse of the case here.

  • So really, what we want to do is we want to invert, um, this output here, whenever the Kerry bit is set in.

  • A clever way of doing that is with another ex or gate, because when you x or something with a one it has, it will invert it.

  • So if we have our carry coming in here, we send that into the X or gate.

  • On this will be the some that we put it.

  • The bottom here because what happens is if if this is a one, um, then you know a zero x or one is gonna be 11 x a war One is a zero a one x or ah, one again is a zero.

  • And then here we have a zero x or a one is one.

  • So this this will give us this this last column Now for this first column, which is the Kerry bit, that we're the Carrie, you know, that we might put into the next column.

  • Um, we've got these cases covered, right, Cause if a and B is the one, then we get our one and we even have this case covered here because of a N B is a one.

  • Um, then we have a one here is well, but we don't have covered.

  • Is these two cases here where A or B, um is a one.

  • And we have this Carrie.

  • And so what we can do is we can actually say, Well, if we have the carry exclusive or A or B, we haven't already have that exclusive or A and B A or B is a one.

  • And we have the Carrie that we want this one.

  • So we can actually just and the A or B So this is this Is this this A or B?

  • We already have, and the Kerry bit is set.

  • Then we get this one here.

  • So now we have this case.

  • Now we have this these two cases covered by this output of this and gay troops.

  • We want to bring the carry fit in there as well.

  • Um, and we have these two cases where it's one covered by this and gate.

  • And so really, what we want to do is we want to say that this bitch is gonna be a one either time this condition or this condition is met so we can use an or gate.

  • This is an or gate.

  • This is an and gate.

  • This is an ex or so you guys don't get confused here.

  • Um and then this is the Kerry.

  • And so this actually is what is called a full adder because we have A and B So we have two numbers that were trying to add.

  • We potentially have a Carrie from a previous addition on, and then we get a sum out, which is the number we put here at the bottom.

  • Plus, we get to carry that goes into next column.

  • And so, with this sort of simple circuit, if we build one of these circuits for each column, we can add, you know is as large numbers we like a long as we keep building, you know, as many of these circuits as we like.

  • And so, for example, have drawn up this diagram here which shows that same circuit sort of replicated four times.

  • And in this case, you have an A and A B coming in here.

  • Um, and the Kerry coming out goes into the Kerry of the next circuit.

  • So this is sort of like you know, when you're actually doing the the arithmetic.

  • Here you have a one plus the one you have to carry.

  • It goes in as an input to the next edition and so that Kerry comes into here along with a new way and a newbie, which is gonna be the A and B for this column for the second column, and then you have a some coming out, which would be the number down here.

  • And then you have that carry going over which goes into the next column, plus the new A.

  • And to be for that column, Carrie comes out and so forth, and so here have drawn four of them, so we can add to four bit numbers.

  • But we we could keep building more and more of these if we wanted to.

  • So actually build this.

  • Um, we can use some some pretty simple components because we have X or Gates and these these chips here actually implement x or gates.

  • And here is the data sheet for them.

  • And so you can see from this data shoot.

  • Basically, each of these chips has four x or gates built onto it.

  • And so, you know, to build a four bit at her like I've drawn out here, you need 12345678 X or gates.

  • So we have two of these chips.

  • Each one has four.

  • Um, we also need some and gates.

  • And so there's another chip that has end gates.

  • We need eight of those.

  • So each of these chips has four.

  • And gates, as you can see on the data sheets.

  • So we got those.

  • We also need some or gates here.

  • We just need four of those.

  • So there's another chip that has four or gates.

  • So we got that, um, and then a couple other things that we that we need to we need, ah, bread board to build this on.

  • So we're gonna build us on this bread board here.

  • Ah, and, ah, for the inputs.

  • I have these little little dip switches, so each of these has four little switches on it, and that will let us set the four.

  • You have a zero a one, a two and a three for the one number that we want to add.

  • And then another one for the B 012 and three for the other number.

  • It won't add together, and then finally, Ah, a couple of things we need are some kind of outputs here.

  • So we have our our sums coming out here.

  • And so I just have similar led is that'll light up for each of these digits on.

  • And I have five of them because there's four outputs plus the final carry, which is, you know, because if you're adding to four bit numbers, you might end up with a five bid output so that last Carrie will will have another led for that.

  • And then I'm just gonna power with a little bit of, ah, little USB.

  • Um, this is just a standard USB charger that I've kind of had the end off of and just taking the red and black wires out of there, and that'll give us five volts.

  • So I'm gonna go ahead and start getting this thing built on this on this little bread board here, and I'll just start by sticking this stuff onto the onto the bread board.

  • Okay, at this point, I've got everything on the board and all the chips air powered, so each of these chips has ah vcc, which is the positive voltage and then the ground so that each of those is connected for each of these chips, everything's on the board.

  • So we'll go ahead and just, uh, actually just wire up the first of the ADDers and we play with that one first, and then we'll do the rest.

  • Okay, so I've got the first stage of this wired up.

  • Um, I think we'll see.

  • We'll powered up and see what happens, but, ah, this Ah, some using the one refusing to the x or gates on this chip.

  • Two of the and gates on this chip on and then the or gate is over here.

  • So I got some kind of wires running back and forth.

  • But I guess as I as I do the additional bits, hopefully the wires get a little shorter.

  • Hopeful it'll fit.

  • But anything this these this is the sum of the first to bits over here.

  • And this will be the carry.

  • So let's get the power on already plugged in.

  • So gonna just hook this up here and see what happens, and that's not good.

  • I'm not done yet.

  • Okay, now I think I'm done.

  • I just had to hook up a couple extra connections because the switches weren't fully wired in.

  • Okay, now we had power, and everything is off because these 1st 2 bits are off.

  • And if I, um, toggle either of these on hopefully, yes, we see zero plus one equals one.

  • So this is a binary 01 So this is the answer there.

  • If we turn this off and turn the other one on, we see again.

  • One plus zero also equals one.

  • That's good.

  • And if we turn both of them on, we get one plus one equals two.

  • So it looks like this is working s So now we'll go ahead and just wire up.

  • I'll actually wire up the remaining three atter the reigning three hours for the remaining three bits here.

  • Okay, so I just finished this.

  • So let's see if it works.

  • I've been testing it as I as I go, but I haven't tested the whole thing all together, but let's let's see how it does.

  • If we plug this in, we got zeros and zero.

  • So we've got all zeros on the output there, So let's see if we want to do some some arithmetic here with this, Let's imagine we want to add 10 plus seven and get 17.

  • So in binary, this is 10.

  • This is seven, eh?

  • So we would add zero and one when we get one.

  • And we had one and one and that's too.

  • So that zero carry a one won and won again is to says zero carry 11 on one again is ah is too.

  • So that's Ah, 10 in binary.

  • So this is what we would expect.

  • So let's go ahead and give it a try.

  • So 10 is 1010 so we could do one 010 And already you see, the output is 1010 because we're adding that to zero, So 10 plus zero zero.

  • So so far so good on.

  • And then seven weaken do +0111 So if we do +0111 There we go.

So if we want to add 28 plus 22 it's pretty simple.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it