Transcript for:
Understanding Half and Full Subtractors

Hey, friends welcome to the YouTube channel ALL ABOUT ELECTRONICS. So in the previous videos, we learned about the different adder circuits. So similarly, now let us see the digital circuit for the subtraction. And first let us start with the half subtractor. So this half subtractor, is the combinational circuit which subtracts the two bits. And as a result, it gives the difference and the borrow output. So now let's see, what is inside this half subtractor. And for that, first of all, let us see the truth table of this half subtractor. So since there are two inputs, so there are total four possibilities. So whenever both inputs A and B are zero, then this difference and the borrow output will be equal to zero. Similarly, in the next case, when this A is zero, and B is 1, then this 0 minus 1 is equal to 1. While the borrow will be equal to 1. Likewise in the third case, this 1 minus 0 is equal to 1. That means the difference is equal to 1, while the borrow is equal to zero. And similarly in the fourth case, this one minus one is equal to zero. That means both difference and the borrow outputs are zero. So this is the truth table of the half subtractor. So as you can see, this difference output is one only for the two input combinations. That is when A is zero and B is one, or when A is one and B is zero. So algebraically, we can say that, this D is equal to A bar dot B, plus A dot B bar. Or equivalently we can say that, it is equal to A ⊕ B. Likewise this borrow output is 1, when this A is 0, and B is 1. Or algebraically, we can say that this B out is equal to A bar dot B. So in this way, we got the Boolean expressions, for this difference as well as the borrow output. So based on this Boolean expressions, now let us see the logic circuit of this half subtractor. So this is the logic circuit of the half subtractor. So as you can see, this A ⊕ B, is implemented using this XOR gate. And to generate this A bar dot B signal, this A is inverted using the NOT gate. And then the output is given to this AND gate. That means, the output of this AND gate, is equal to A bar dot B. So in this way, we can design this half subtractor. Now this half subtractor circuit, is good for doing the subtraction of the LSBs. Because during the subtraction of the LSBs there is no incoming borrow. For example let's say, we want to do the subtraction of these two numbers. So while subtracting these LSBs, we can use this half subtractor. So in that case, this A is 0 and B is 1. So once we give this input to this half subtractor, then this difference output is equal to 1, while the borrow is equal to 1. So now, in the next stage if you see, then the inputs are 1 and 0, while the borrow input is also equal to 1. So now, if you want to do the subtraction of this next column, then we cannot do using this half subtractor. Because there is no provision for this borrow input. So whenever we want to do the subtraction along with the borrow input, then we can use this full subtractor. So this full subtractor, is the combinational circuit, which subtracts one bit from the another one including this borrow input. So to understand the internal circuit of this full subtractor, first of all let us see the truth table of this full subtractor. So here, for the three inputs, we have total eight different combinations. right? So whenever all the three inputs are zero, then this difference and the borrow outputs will be equal to 0. Then in the next case, this 0 minus 0 is equal to 0. And this 0 minus 1 is equal to 1, with 1 as a borrow. That means in the next row, this difference output and the borrow output both are 1. Likewise, in the third case, this 0 minus 1 is equal to 1, with 1 as a borrow. And then this 1 minus 0 is equal to 1. That means in this case also, this difference and the borrow outputs are 1. Then if we move to the next case, then this 0 minus 1 is equal to 1, with 1 as a borrow. And this 1 minus 1 is equal to 0. That means in this fourth case, this difference output is equal to 0, while the borrow is equal to 1. Similarly, if we move to the next case, then this 1 minus 0 is equal to 1. And then after this 1 minus 0 is also equal to 1. That means in this fifth row, this difference output is equal to 1, while the borrow is equal to 0. Likewise in the sixth row, these 1 minus 0 is equal to 1, while these 1 minus 1 is equal to 0. That means both difference and the borrow outputs are 0. Similarly, for the next case, this 1 minus 1 is equal to 0, while this 0 minus 0 is equal to 0. That means, in the seventh row also this difference and the borrow outputs are zero. Likewise in the last row, this one minus one is equal to zero, and this zero minus one is equal to one. But in this case, we will also have a borrow. That means in the last case, both difference and the borrow outputs are 1. So in this way, we got our truth table for this full subtractor. So as you can see from the truth table, the difference output is one for the four different input combinations. So now for this difference output, let's write down the Boolean expression. So the Boolean expression of this difference output, can be written like this. That is A bar dot B bar dot Bin, plus A bar dot B dot Bin bar. And likewise, for this 1 0 0 and the 1 1 1, we will have this A dot B bar dot Bin bar, plus A dot B dot Bin. So this is the Boolean expression of this difference output. So now let us try to simplify it. So if you see these first two terms, then this A bar is common in both terms. So if we take this A bar common, then we will have, this B bar dot Bin, plus B dot Bin bar. Similarly in the last two terms, this A is common. So in the bracket, we will have this B bar dot Bin bar, plus B dot Bin. That means, once we take this A bar and A common, then we will have this expression. So as you can see, this term is equal to B (XOR) Bin. Likewise this term is equal to B (XOR) Bin whole bar. That means, we will have this A bar dot B (XOR) Bin, plus A dot B (XOR) Bin whole bar. So let's say this B (XOR) Bin, is equal to X. That means, the expression will be equal to A bar dot X plus A dot X bar. And that is equal to A (XOR) X. So if you put the value of this B (XOR) Bin, then this difference output can be written as A (XOR) B (XOR) Bin. So in this way, we got the expression for this difference output. Similarly now let's find the expression for this borrow output. So as you can see, this borrow output is also equal to 1 for the four different input combinations. That means, this borrow output is equal to 1, when the input combinations are 0 0 1 0 1 0 0 1 1 and 1 1 1. So in the sum of product form, if we see the Boolean expression of this Bout, then from the truth table, it can be written like this. So now let us try to simplify it. So in this expression, if you see the second and the third term, then this A bar dot B is common. And likewise in the first and the fourth term this Bin is common. So if you take this A bar dot B common, then in the bracket we will have this Bin plus Bin bar. And likewise, once we take this Bin common, then in the bracket, we will have this A dot B, plus A bar dot B bar. So here, in the first term this Bin plus Bin bar is equal to 1. And this A dot B plus, A bar dot B bar is nothing but A (XOR) B whole bar. That means, we can write this Bout as A bar dot B plus, Bin dot A (XOR) B whole bar. So in this way, we also got the expression for this borrow output. And as we have seen, this difference output is equal to A (XOR) B (XOR) Bin. So in this way, we got the Boolean expression for this difference as well as the borrow output. So based on this Boolean expression, let us see the logic circuit for this difference as well as the borrow output. So since the difference output is equal to A(XOR) B(XOR) Bin. So it can be implemented using the two XOR gates. So for the first XOR gates, the input can be A and b. So its output will be equal to A(XOR) B. And this output we can give to the second XOR gate. And the second input to the second XOR gate will be equal to Bin. That means if we see the oral output then it is equal to A (XOR) B(XOR) Bin. So this is how we can implement this difference output. Similarly, let's see the logic circuit of this Bout. So here to implement this A bar dot B, first of all we need to invert this A. So using the NOT gate, we will get the A bar. And once it is passed through the AND gate, then we will have this A bar dot B. Similarly we will get this A(XOR)B, using this XOR gate. And once it is passed through the NOT gate, then we will have this A (XOR) B whole bar. And using one AND gate, we will get this Bin dot A (XOR) B whole bar. So once we get these two terms, then using the OR gate, we will get the Bout. So this is the logic circuit of the Bout. Now in the same circuit, if we use one more XOR gate, then we can also generate this difference output. So this is the overall circuit, of this full subtractor. So as you can see, using these two XOR gates, this difference output is generated. And using this NOT gate, and the AND gate, this A bar dot B is generated. Similarly, using this NOT gate and the AND gate, we will get this Bin dot A (XOR) B. And once we give these two outputs to the OR gate, then we will get this borrow output. So this is the overall logic circuit of the full subtractor. Now if you closely observe, then this portion of the circuit is nothing but the half subtractor. And likewise, this is the another half subtractor. That means using the two half subtractors, along with the OR gate, we can design this full subtractor. So let us see the same thing in little different perspective. So we know that, this is the logic circuit of the half subtractor. So for a time being, let us represent it with this block. That means, whenever this A and B are the input to the half subtractor, then its borrow output will be equal to A bar dot B, while its difference output will be equal to A (XOR) B. So now, let us give this difference output as an input to the next half subtractor. And the second input to the second half subtractor is equal to Bin. So based on these two inputs, the difference output of the second half subtractor, is equal to A (XOR) B (XOR) Bin. And similar to the A bar dot B, the borrow output, will be equal to this Bin dot A (XOR) B whole bar. Because here, instead of A the one of the input to this half subtractor, is equal to A (XOR) B. That means this borrow output will be equal to, Bin dot A (XOR) B whole bar. So if you see this expression, then using the two half subtractors, we already got this A bar dot B, and this Bin dot A (XOR) B whole bar. So now, using just one OR gate, we can perform the logical OR operation, of these two terms. And at the output we will get this borrow output. So in this way, using the two half subtractors, we can design the full subtractor. So using this one full subtractor block, we can do the subtraction of the two one bit numbers, along with the borrow input. But if you want to perform the subtraction of two N bit numbers, then we require N such full subtractor blocks. So in the next video, we will see that by combining N such blocks, how we can design the N bit subtractor. And we will also see that, using the adder circuit itself how we can perform the subtraction. But I hope, in this video you understood about this half subtractor, and the full subtractor. So if you have any question or suggestion, then do let me know here in the comment section below. If you like this video, hit the like button, and subscribe to the channel for more such videos.