Pages

April 17, 2011

Binary Subtraction


          Half subtractors and full subtractors will be explained in this section. The rules for the binary subtraction of two bits are given in Fig. 1. The top number in a subtraction problem is called the minuend. The bottom number is called the subtrahend, and the answer is called the difference. Rule 1 in Fig. 1 is obvious. Rule 2 (Fig. 1) concerns 1 being subtracted from the smaller number 0. In Fig. 2, note that, in the Is column of the binary number, 1 is subtracted from 0. A 1 must be borrowed from the binary 2s column, leaving a 0 in that column. Now the subtrahend 1 is subtracted from the minuend 10 (decimal 2). This leaves a difference of 1 in the Is column. The binary 2s column uses rule 1 (0-0) and is equal to 0. Therefore, rule 2 is 0 - 1 = 1 with a borrow of 1. Rules 3 and 4 are also rather obvious.



          The subtraction rules given in Fig. 1  look somewhat like a truth table. These rules have been reproduced in truth table form in Fig. 3. Consider the difference (Di) output in the truth table. Note that this output represents the XOR function. The logic function for the difference output in a subtractor is the same as that for the sum output in a half adder circuit. Now consider the borrow (Bo) column in the truth table. The logic function for this column can be represented by the Boolean expression A’ • B = Y. It can be implemented by using an inverter and a 2-input AND gate.


          The truth table in Fig. 3 represents a logic circuit called a half subtractor. The Boolean expression for the difference output is A(xor)B = Di. The Boolean expression for the borrow (Bo) output is A’ • B = Bo. A half subtractor would be wired from logic gates as shown in Fig. 4a. Input A is the minuend and B is the subtrahend. The Di output is the difference; Bo is the borrow. A simplified block diagram for a half subtractor is in Fig. 4b.

          Compare the half subtractor logic diagram in Fig. 4a with the half adder (in figure in the previous post). The only difference in the logic circuits is that the half subtractor has one added inverter at the A input of the AND gate.
          Consider the subtraction problem in Fig. 5. Several borrows are evident in this problem. If six subtractor circuits are used for the six binary places, the borrows must be considered. A half subtractor may be used for the Is place. Full subtractors must be used in the 2s. 4s. 8s. 16s. and 32s columns of this problem.



          A block diagram of a full subtractor (FS) is in Fig. 6. The inputs are A (minuend). B (subtrahend), and Bin (borrow input). The outputs are Di (difference) and Bo (borrow output). The Bo and Bin lines are connected from subtractor to subtractor to keep track of the borrows.



          The diagram in Fig. 6b shows how to wire two half subtractors (HS) and an OR gate together to form a full subtractor (FS) circuit. Note that the wiring pattern is similar to that used for adders. Finally, Fig. 7 shows how gates could be wired to form a full subtractor circuit. Remember that full subtractors must be used to subtract all columns except the Is column in binary subtraction. 
          The truth table for the full subtractor is in Fig. 8. The inputs are labeled as minuend (A), subtrahend (B), and borrow in (Bin). The outputs are the customary difference (Di) and borrow out (Bo).


          The binary subtraction problem in Fig. 9 will aid understanding of the full subtractor truth table. Follow as this problem is solved, using only the truth tables in Figs. 3 and 8. Look at the Is column of the problem in Fig. 9. The Is place uses a half subtractor. Find this situation in the truth table in Fig. 3. You find that line 3 of the half subtractor truth table gives an output of 1 for Di (difference) and 0 for borrow out (Bo). This is recorded below the Is column in Fig. 9.


          Consider the 2s column in Fig. 9. The 2s column uses a full subtractor. On the full subtractor truth table, look for the situation where A = 0, B = 0, and Bin = 0. This is line 1 in Fig. 8. According to the truth table, both outputs (Di and Bo) are 0. This is recorded below the 2s column in Fig. 9.
          Next consider the 4s column in Fig. 9. The inputs to this full subtractor will be A = 1, B = 1, and Bin = 0. Looking at the input side of the truth table in Fig. 8, it appears that line 7 shows this situation. The outputs (Di and Bo) are both 0 according to the truth table and are written as such on Fig. 9 under the 4s column.
          Look at the 8s column in Fig. 9. The inputs to the full subtractor will be A = 0, B = 1, and Bin = 0. Line 3 of the truth table (Fig. 8) shows this situation. The outputs (Di and Bo) in line 3 are both Is and are recorded in the 8s column in Fig. 9. 
          The 16s column in Fig. 9 has inputs of A = 1, B = 1, and Bin = 1. This corresponds with line 8 in the truth table. Line 8 generates an output of Di = 1 and Bo = 1. These Is are recorded under the 16s column in the problem.   
          The 32s column has inputs of A = 1, B = 0, and Bin = 1. This corresponds to line 6 in the truth table in Fig. 8. Line 6 generates outputs of Di = 0 and Bo = 0. These 0s are recorded in the 32s column of the problem. 
          Finally consider the 64s column in Fig. 9. The inputs to the full subtractor are A = 1, B = 0, and Bin = 0. This input combination is shown in line 5 in the truth table. Line 5 generates an output of Di = 1 and Bo = 0. Figure 9 illustrates how binary 11100 is subtracted from binary 1110101 using truth tables. The borrows are shown below the problem. This procedure is quite cumbersome for humans, but electronic circuits can accurately perform this subtraction in microseconds.




4 comments:

  1. Thank you Sir... It really helped me a lot to understand...:)

    ReplyDelete
    Replies
    1. You're welcome Sourabh.. :) glad to helping you.. keep reading, learning and practice..

      Delete
  2. Thank you sir, i have an upcoming test and i am really happy to tell you that this is very useful and well-explained, thank you!

    ReplyDelete
  3. very awesome sir..... Thanks a lot....Really awesome explanation...

    ReplyDelete