Sunday 28 February 2016

Half adder and Half subtractor explained

Addition and subtraction are two very basic operations. In digital systems the data path and sometimes the control path contains both adder and subtractor. In this article I'll try to clearly explain their operation, design and where do we use them.

Half adder

There are basically two types of adders viz. half adder and full adder same is the case with subtractors. Half adder takes two single bits as input and produces a sum and a carry output. In the below figure we show the truth table that clearly explains the operation of half adder.

From the truth table we can clearly understand that the sum output is "XOR" of inputs and the carry function is "AND" of inputs. The half adder shown here is a binary half adder as it takes only 1-bit binary values as inputs. In figure-1 we show the logic gate implementation of half adder. The sum output is "XOR" of inputs A and B, we'll also see how an XOR gate is implemented using smallest possible number of NAND gates. Try to implement XOR in a better way than this and if u succeed I'm sure you will get a Ph.D on it. Until then this is the best implementation.
The sum output of Half adder is sometimes called as quarter adder. Half adder is used to construct a full adder and it is also used in parallel adder. 

Half subtractor

Basically subtraction can also be considered as addition with one of the input being 2's-complemented. because of this similarity the truth table and equations for subtraction show a resemblance to the half adder. Half subtractor accepts two 1-Bit inputs and produces a difference and borrow outputs. The below figure shows the truth table and block diagram of half subtractor.
As said above we can see that the Difference output is same as the Sum output of half adder. But the Borrow is different from Carry of half adder. In figure-2 we'll see the implementation of half subtractor using logic gates.
The Difference output of half subtractor is called a Quarter subtractor. Half subtractor is used to construct a full subtractor. Mostly in digital circuits the subtractors are replaced with adders and one of the inputs being 2's-complemented. Subtractors are rarely used in digital circuit design.

1 comment: