Binary Subtractor | It’s 3 types and important applications

Points of Discussions

• Definition and Overview of Binary Subtractor
• Half Subtractor
• Full Subtractor
• N -bit Subtractor
• Applications of binary subtractor
• VHDL implementation of half subtractor and full subtractor

Definition and Overview

A subtractor is a device that subtracts two numbers and produces the result. A digital or binary subtractor is something that deals with the Subtraction of binary digits.

A binary subtractor is needed for digital computation inside a digital device or a digital computer. The most convenient way of Subtraction unsigned binary numbers is the method of complements. There are rules for binary Subtraction.

The binary subtraction rules are stated as follows. Here 0 is logic low, and one is logic high. A and B are two inputs.

Example of subtraction operations:

1101 – 1011

1101

– 1011

= 0010

Methods of complements can alternatively carry out binary subtractions for binary subtractors. There are two types of complement methods that are generally used.

A.  1’s Complement

B. 2’s Complement

Steps for performing 1’s complement:

1. Find out the 1’s complement of the number that is to be subtracted.
2. Now the 1’s complement is added to the number from which the Subtraction is desired.
3. Where there is one carry in the last position, of the result of the addition in step 2, the carrier is removed and added to the product without the carry to obtain the final result.

Let us take an example – 1101 – 1011

1’s complement of 1011 = 0100

1101

+ 0100

= 1 0001

As we can see, there is one as a carry, so we remove the carry and add the carry again with the obtained result.

0001

+    1

= 0010

So, the answer to the Subtraction is 0010

For 2’s complement method

1. Calculate the 2’s complement.
2. The complement is now added with another number.
3. The carry is rejected.

Let us take an example – 1101 – 1011

2’s complement of any number is calculated by performing 1’s complement and adding 1 to it.

2’s complement of

1101

+ 0100

= 1 0001

As we can see, there is one as a carry, so we remove the carry and add the carry again with the obtained result.

0001

+    1

= 0010

So, the answer to the Subtraction is 0010

Digital computers use the 2’s complement method for calculations as it requires less carry.

The complement methods in the decimal number system are known as 9’s and 10’s complement method.

Various digital circuitries implement this subtraction operation. They are –

• Half Subtractor
• Full Subtractor

A binary subtractor not only performs addition operations but also used in digital applications. Decoding and encoding of values, calculation of the index is a few of its applications.

Half subtractor

A half binary subtractor is a binary subtractor that subtracts one bit of data and produces the result. It has two input sides through which we supply the digital logic values, and it has two outputs through which we receive the impact of the operation. The result can be shown in a single digit. The work shows the number in the Subtraction that has the same significance as the individual digits subtracted. The other output shows the borrow bit.

The half subtractor truth table

The working of the half binary subtractor is shown in the following truth table.

Half Subtractor circuit

From the truth table, we can conclude that the first three rows can represent the result using a single digit. In the second row, the work is described using two numbers as it has borrowed as 1.

Difference = A′B + AB′

Borrow = A′B

So,

Difference = A XOR B

Borrow = A′ AND B

We need one XOR gate, one NOT gate, and one AND gate to implement the logic. XOR gate, NOT gate, an AND gate can also be made using universal gates like NAND and NOR. So, a half subtractor can be designed using only universal gates.

The following image shows A and B as the input and D as the difference, and C as they borrow.

Full Subtractor

Full Binary Subtractor is another kind of binary Subtractor which provides the result of a binary subtraction operation. When two binary numbers are subtracted, except for the least significant digit, there is a borrow-in as Bi-1 and borrow out as Bi. The full Subtractor is designed to handle a borrow-in for each stage. That is how an entire order overcomes the shortcoming of half Subtractor of running borrow-in.

A full subtractor truth table

Full subtractor circuit

Difference = A′ B′ Bin + A B′ Bin′ + A′ B Bin′ + A B Bin

Borrow = A′ Bin + A′ B + B Bin

To implement the expression using logical gates, we need to simplify the word further.

Difference = A′ B′ Bin + A B′ Bin′ + A′ B Bin′ + A B Bin

Or, Difference = Bin (A′B′ + AB) + Bin ′ (AB′ + A′B)

Or, Difference = Bin (A XNOR B) + Bin ′ (A XOR B)

Or, Difference = Bin (A XOR B) ′ + Bin ′ (A XOR B)

Or, Difference = Bin XOR (A XOR B)

Or, Difference = (A XOR B) XOR Bin

Borrow = A′ B′ Bin + A B′ Bin′ + A′ B Bin′ + A B Bin

Or, Borrow = A′ B′ Bin +A′ B Bin ′ + A′ B Bin + A′ B Bin + A′ B Bin + A B Bin

Or, Borrow = A′ Bin (B + B′) + A′B (Bin + Bin ′) + B Bin (A + A′)

Or, Borrow = A′ Bin + A′B + B Bin

The expression can be written in another way –

Bout = A′ B′ Bin + A′ B Bin′ + A′ B Bin + A B Bin

Or, Borrow = Bin (AB + A′ B′) + A′ B (Bin + Bin′)

Or, Borrow = Bin (A XNOR B) + A′ B

Or, Borrow = Bin (A XOR B) ′ + A′ B

As the circuit diagram shows, A, B, and Bin. The circuit gives two output as difference output and borrows output. The Bin is set to 1 whenever there is borrow in input A. Bin is then subtracted from A and Y.

The general expression can be written as D = A – B – Bin + 2 Bout.

Full subtractors can also be implemented using half subtractors.

N bit Subtractor

In a single bit binary subtractor, Subtraction of only 1 bit can be performed. If we need to perform Subtraction of n -bit, then a n bit binary subtractor is required. An n-bit subtractor can be implemented similarly using subtractors in a cascaded form.

Applications of Subtractors

• Subtractors are often used with adders. Whenever an adder is needed for a circuit, a subtractor is also required.
• ALU, which is responsible for the calculation, and stays inside a microprocessor, also needs subtractors. CPUs also need subtractors for operation.
• Microcontrollers also use subtractors for performing the digital computation.
• Subtractors are also used in Digital Signal Processing Domain.
• Digital computers use a lot of subtractors.

How an Adder works? Truth Tables and Circuit Diagrams! Click to know!

VHDL Implementation of Half Subtractors & Full Subtractors

Half Subtractor Dataflow Modelling

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

entity ENTITY_NAME is

Port ( A : in  STD_LOGIC;

B : in  STD_LOGIC;

IB : in  STD_LOGIC;

Diff : out  STD_LOGIC;

Borr : out  STD_LOGIC);

end ENTITY_NAME;

Architecture Dataflow

architecture Dataflow of ENTITY_NAME is

begin

Diff <= (A xor B) xor IB;

Borr <= ((not A) and (B or IB)) or (B and IB);

end dataflow;

Full Subtractor Dataflow Modelling

entity ENTITY_NAME  is

Port ( A : in  STD_LOGIC;

B : in  STD_LOGIC;

IB : in  STD_LOGIC;

Borr : out  STD_LOGIC;

Diff : out  STD_LOGIC);

end ENTITY_NAME;

Architecture dataflow

architecture Behavioral of ENTITY_NAME is

begin

process(A,B,IB)

begin

if(A=’0′ and B=’0′ and IB=’0′ )then

Diff<=’0′;

Borr<=’0′;

elsif(A=’0′ and B=’0′ and IB=’1′ )then

Borr<=’1′;

Diff<=’1′;

elsif(A=’0′ and B=’1′ and IB=’0′ )then

Borr<=’1′;

Diff<=’1′;

elsif(A=’0′ and B=’1′ and IB=’1′ )then

Borr<=’0′;

Diff<=’1′;

elsif(A=’1′ and B=’0′ and IB=’0′ )then

Borr<=’1′;

Diff<=’0′;

elsif(A=’1′ and B=’0′ and IB=’1′ )then

Borr<=’0′;

Diff<=’0′;

elsif(A=’1′ and B=’1′ and IB=’0′ )then

Borr<=’0′;

Diff<=’0′;

else

Borr<=’1′;

Diff<=’1′;

end if;

end process;

end Behavioral;