 So this time we're going to be doing about the same thing we did before but this time we'll build our adder so that it takes three inputs. We'll have the same A and B that we did before but we'll also have a carry-in bit. That way we'll be able to stack several of these adders and any carrying that happens will just ripple through the various adders so that we do get the right result in the end. This means that our adder needs to take three inputs. So we'll need to start with the truth table that has three inputs. So we'll have say A, B, and a carry-in. And we will be interested in calculating A plus B plus carry-in line. This time I have three different inputs each of which has two possible values. So I have two to the third entries in my table. So I have eight entries in my table and adding these all up, zero plus zero plus zero, zero, one, one. I'm doing binary addition so I don't have two, I have ten. So I also need to go back and add something in the tens position for the others. Now I have one, ten, ten, and eleven. So that's what I would like to get as the result of my adder. This time I'm going to have three inputs coming in and I'm going to have to use those to choose between zero or one for each of these two columns. So this will be trickier than what we had before. Again, our tens column is relatively straightforward. One way we could do is just notice that this is only ever true if at least two of the input bits are also true. This seems reasonable. We need at least two ones coming in to be able to get to ten. So one thing we can do is just find all the cases where two of these input bits are true and set the result to be one. We can basically do that using a set of AND gates. So I could have A and B. That would produce ten. And then I wouldn't care what carry-in is. It wouldn't matter if it's zero or one. My tens bit will be one either way. And I could also have A and carry-in. That's true. And I would also have a one in my tens bit. Or I could have B and carry-in. Same thing. But since I don't care which of these three is true, I'm just going to use OR gates to connect them. And if it turns out all three of them are true, then the results will be true as well. We'd have this case. And that's great. So for the first case, all of my inputs are zero. So none of these three propositions will be true. So the results will also be zero. Here I've got one bit that's a one, but that's not enough to satisfy any of the conjunctions. Again, only one input is one. Here I have one and one. So B and carry-in are true. This proposition is true. And since we're just ORing all of them together, the entire proposition will be true. Back down to one input. I've got two A and carry-in. Here I've got A and B. So that will also be one. And here all three are true. So all three of these conjunctions would be true. But the result is still just true. I can look zero, zero, zero, one, zero, one, one, one. This line matches up with this column. So I can say that these two are logically equivalent. Which is great. I found a way to do one of my two columns. I could actually do the same thing for the ones column as well. That would also be ugly. I would be looking for things where say carry-in is true, B is false, and A is false. Or A is false, B is true, and carry-in is false. I would have to find all of those four cases and design a conjunction that represents that specific case. I can do that, but in this case there's a better way. One thing that our XOR gates do is they tell us if our inputs are the same. They have the same parity. Really that's the sort of thing we're interested in here. We're interested in the parity. This is kind of a parity bit here. It's telling us whether our output is even or odd. So our XOR gate is actually relevant to that sort of operation. That was easy to see when we only had two input bits. But with three input bits, that's not quite so obvious. So I'll start by seeing what happens when I have A XOR B. We had this before, but we'll bring this back. So zero XOR zero is zero, one, one, one, zero, zero. Now I'm just missing the carry-in bit. So I'm going to want to see... So let's look at what we've got for A XOR B, carry-in, and what I should get for a result. So here I've got zero and zero and I get zero out. I have zero and one and I get one out. So this so far kind of looks like an OR operation. Zero or one gives me one. Now I have one and one and I get zero out. So this is clearly not going to be an OR operation. It's not an AND operation because of these two lines. But it kind of looks like an XOR again. Now I have zero and one and that gives me one. Okay, it's still an XOR. One and one gives me zero. Zero and zero gives me zero. One and zero gives me one. So this looks like an XOR. So I'll take my A XOR B and I will XOR that with my carry-in bit. So now I have zero, XOR zero, gives me zero. Zero XOR one gives me one. One XOR zero gives me one. One XOR one gives me zero. One XOR zero gives me one. One XOR one gives me zero. Zero XOR zero gives me zero. And zero XOR one gives me one. So if I compare this to my result, zero, one, one, zero, one, zero, zero, zero, one, which is exactly what we saw a minute ago. So these two columns are logically equivalent as well. So that means that we can use this expression to solve the tens column and this one to solve the ones column. Next we're actually going to have to assemble some logic dates to implement these two expressions. So now I just need to connect all the logic dates to implement these two expressions. I'll have my A, my B, and some carry-in. I'll start with the XORs. There's one XOR gate. It will feed into a second XOR gate. Since I've got my carry-in up here anyway, I'll just feed it into the first one. It doesn't actually matter which order we do these in. So there's my result. There's the A, XOR, B, XOR, carry-in. The order that you do the two XORs in doesn't actually matter. It could have done A, XOR, B first and then carry-in afterwards the way we did previously, but this works as well. So now I just need the A and B and carry-in or B and carry-in. So that will be three AND gates. And all of those will feed into one large OR gate, which will ultimately be our carry-out line. So here I have A. I'll hook up the carry-in in a moment. Here's the other A line. So now we have A and B. That will be the B and carry-in. So now I have A and carry-in, A and B, and then B and carry-in. So there we are. There's both parts of that. We have the result bit and the carry-out bit. Once we have the AND gates, all we needed to do was connect all of our inputs to those AND gates so that they could get to the outputs. And then if I draw a nice box around this, I've got a one-bit adder. And this one, I can stack because I have a carry-in and a carry-out. So my carry-out of this one can connect to the carry-in of the next one. If I want to take a step back, I'm not interested in the guts of how this is working, then I would just draw my adder. This little box with a plus in it has result bit, carry-out bit, as well as an A input and a B input. So this works fine for one. If I've got several, then I'll just want to stack these all out. So if I'm interested in building a 32-bit multiplexer, for example, I will need to stack up 32 of these one-bit adders. The top will have result bit zero. And then its carry would feed into the one's position. So this one will be result one, result bit two, all the way up to result bit 31. Those will each take a different bit from A and from B. So now this would give me a 32-bit adder. And again, I'm probably going to take a step back. I'm not interested in the fact that this is a ripple carry adder. Chances are, after this, I'm just going to be interested in having an adder. So I can just have a box with a plus in it. I can still have the A, the B. And I'm probably actually going to be interested in some other things. I might still have the carry in. I might still have the carry out. These can be useful for other operations. I might want to look at the result bit. I can use this for things like overflow. But now I've got a 32-bit adder here. This thing just adds 32 bits from A to 32 bits from B and tells me what the result is. So most of these lines are 32 bits, A, B, and result. But the carry in and the carry out would only be one bit. Those are just one-bit inputs and outputs. So there is our 32-bit adder. We built an adder that had three inputs instead of two and then just connected them together.