*52*

# Half Subtractor

The half subtractor is also a building block for subtracting two binary numbers. It has two inputs and two outputs. This circuit is used to subtract two single bit binary numbers A and B. The **â€˜diff**â€˜ and **â€˜borrowâ€™** are two output states of the half subtractor.

### Block diagram

### Truth Table

The SOP form of the **Diff** and **Borrow** is as follows:

Diff= Aâ€™B+ABâ€™

Borrow = Aâ€™B

In the above table,

- â€˜Aâ€™ and â€˜Bâ€™ are the input variables whose values are going to be subtracted.
- The â€˜Diffâ€™ and â€˜Borrowâ€™ are the variables whose values define the subtraction result, i.e., difference and borrow.
- The first two rows and the last row, the difference is 1, but the â€˜Borrowâ€™ variable is 0.
- The third row is different from the remaining one. When we subtract the bit 1 from the bit 0, the borrow bit is produced.

## Construction of Half Subtractor Circuit

In the block diagram, we have seen that it contains two inputs and two outputs. The **carry** and **sum** are the output states of the half subtractor. The half subtractor is designed with the help of the following logic gates:

- 2-input AND gate.
- 2-input Exclusive-OR Gate or Ex-OR Gate
- NOT or inverter Gate

### 1. 2-input Exclusive-OR Gate or Ex-OR Gate

The **Diff** bit is generated with the help of the **Exclusive-OR** or **Ex-OR** gate.

The above is the symbol of the **EX-OR** gate. In the above diagram, â€˜Aâ€™ and â€˜Bâ€™ are the inputs, and **â€˜Diffâ€™** is the final outcome after performing the XOR operation of both numbers.

The truth table of the EX-OR gate is as follows:

From the above table, it is clear that the XOR gate gives the result 1 when both of the inputs are different. When both of the inputs are the same, the XOR gives the result 0. To learn more about the XOR gate, click here.

### 2. 2-input AND gate:

The XOR gate is unable to generate the carry bit. For this purpose, we use another gate called AND gate. The AND gate is not enough to give the correct result of **â€˜Borrowâ€™**. We will use the NOT gate with the â€˜ANDâ€™ gate to get the correct result.

The above is the symbol of the **AND** gate. In the above diagram, â€˜Aâ€™ and â€˜Bâ€™ are the inputs, and â€˜OUTâ€™ is the final outcome after performing AND operation of both numbers.

There is the following truth table of AND gate:

From the above table, it is clear that the AND gate gives the result 1 when both of the inputs are 1. When both of the inputs are different and 0, the AND gates gives the result 0. To learn more about the AND gate, click here.

### 3. NOT or Inverter Gate:

The NOT gate is used to get the inverse output. We can combine the â€˜ANDâ€™ and â€˜NOTâ€™ gates in order to get the combinational gate â€˜NANDâ€™. By inverting the input â€˜Aâ€™ using â€˜NOTâ€™ gate and then use the output of the â€˜NOTâ€™ gate as the input of the â€˜ANDâ€™ gate, we can get the â€˜Borrowâ€™ bit.

### Half-Subtractor logical circuit

So, the Half Subtractor is designed by combining the â€˜XORâ€™, â€˜ANDâ€™, and â€˜NOTâ€™ gates and provide the Diff and Borrow.

The **Boolean expression** of the **Half Adder circuit** is given below:

**Diff= A XOR B (AâŠ•B)**

**Borrow= not-A AND B (Aâ€™.B)**