The Wayback Machine - https://web.archive.org/web/20240528144151/https://www.geeksforgeeks.org/4-bit-binary-adder-subtractor/
Open In App

4-bit binary Adder-Subtractor

Last Updated : 16 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In Digital Circuits, A Binary Adder-Subtractor is capable of both the addition and subtraction of binary numbers in one circuit itself. The operation is performed depending on the binary value the control signal holds. It is one of the components of the ALU (Arithmetic Logic Unit). 

This Circuit Requires prerequisite knowledge of Exor Gate, Binary Addition and Subtraction, and Full Adder. 

Let’s consider two 4-bit binary numbers A and B as inputs to the Digital Circuit for the operation with digits 

A0 A1 A2 A3 for A
B0 B1 B2 B3 for B 

The circuit consists of 4 full adders since we are performing operations on 4-bit numbers. There is a control line K that holds a binary value of either 0 or 1 which determines that the operation is carried out is addition or subtraction. 

 

As shown in the figure, the first full adder has a control line directly as its input(input carry Cin), The input A0 (The least significant bit of A) is directly input in the full adder. The third input is the exor of B0 and K. The two outputs produced are Sum/Difference (S0) and Carry (C0). 

If the value of K (Control line) is 1, the output of B0(exor)K=B0′(Complement B0). Thus the operation would be A+(B0′). Now 2’s complement subtraction for two numbers A and B is given by A+B’+Cin. This suggests that when K=1, the operation being performed on the four-bit numbers is subtraction. 

Similarly If the Value of K=0, B0 (exor) K=B0. The operation is A+B which is simple binary addition. This suggests that When K=0, the operation is performed on the four-bit numbers in addition. 

Then C0 is serially passed to the second full adder as one of it’s outputs. The sum/difference S0 is recorded as the least significant bit of the sum/difference. A1, A2, A3 are direct inputs to the second, third and fourth full adders. Then the third input is the B1, B2, B3 EXORed with K to the second, third and fourth full adder respectively. The carry C1, C2 are serially passed to the successive full adder as one of the inputs. C3 becomes the total carry to the sum/difference. S1, S2, S3 are recorded to form the result with S0. 

For an n-bit binary adder-subtractor, we use n number of full adders. 

Example: 

Assume that we have two 3-bit numbers, i.e., X=100 and Y=011, and feed them in Full-Adder as an input.

X0 = 0     X1 = 0     X2 = 1
Y0 = 1     Y1 = 1    & Y2 = 0

For K=0: 
Y0⨁K=Y0 and Cin=K=0
So, from first Full-Adder

S0 = X0+Y0+Cin
S0= 0+1+0
S0=1
C0=0

Similarly,

S1 = X1+Y1+C0
S1 = 0+1+0
S1=1 and C1=0

Similarly,

S2 = X2+Y2+C1
S2 = 1+0+0
S2=1 and C2=0

Thus,

X= 100 =4
Y = 011 = 3
Sum = 0111 = 7

For K=1

Y0⨁K=Y0' and Cin=k=1

So,

S0 = X0+Y0'+Cin
S0 = 0+0+1
S0=1 and C0=0

Similarly,

S1 = X1+Y1'+C0
S1 = 0+0+0
S1=0 and C1=0

Similarly,

S2 = X2+Y2'+C1
S2 = 1+1+0
S2=0 and C2=0

Thus,

X = 010 = 4
Y = 011 = 3

Difference = 001 = 1

Similar Reads

Size of ROM for n-bit Adder/Subtractor
ROM is a read-only memory which is used to store the data. The memory in the ROM is organized as a two-dimensional array of memory cells. The memory will read or write the contents of one of the rows of the array. This row is specified by an Address which are bits. The value read or written is called Data. Figure a) shows a memory array with two ad
3 min read
Parallel Adder and Parallel Subtractor
Prerequisite - Full adder, Full Subtractor Parallel Adder - A single full adder performs the addition of two one bit numbers and an input carry. But a Parallel Adder is a digital circuit capable of finding the arithmetic sum of two binary numbers that is greater than one bit in length by operating on corresponding pairs of bits in parallel. It cons
3 min read
Half Adder and Half Subtractor using NAND NOR gates
Introduction:Advantages of using NAND and NOR gates to implement Half Adder and Half Subtractor:Universality: NAND and NOR gates are considered universal gates because they can be used to implement any logical function, including binary arithmetic functions such as addition and subtraction.Cost-effectiveness: NAND and NOR gates are relatively simpl
2 min read
Difference between Serial Adder and Parallel Adder
Addition is a fundamental operation in digital electronics, and is used in a wide range of applications such as arithmetic, data processing, and control systems. There are two main types of adders used in digital circuits: Serial Adder and Parallel Adder. Understanding the differences between these two types of adders is essential to designing and
3 min read
Difference between Half Adder and Full Adder
In this article, we will go through the Difference between the Half adder and Full adder, First, we will briefly describe what is half and full adders with their logical expressions and truth table, and then we will go through their differences between them, At last we will conclude our article with some FAQs. Table of Content What is Half Adder?Wh
4 min read
1 Bit Full Adder using Multiplexer
Prerequisite : Multiplexer, Full adder Introduction : Multiplexer and Full adder are two different Digital Logic circuits. The Multiplexer is a digital switch. It allows digital information from several sources to be routed onto a single output line. On the other hand, the Full adder circuit performs the addition of three bits and produces the Sum
3 min read
Half Subtractor in Digital Logic
A half subtractor is a digital logic circuit that performs binary subtraction of two single-bit binary numbers. It has two inputs, A and B, and two outputs, DIFFERENCE and BORROW. The DIFFERENCE output is the difference between the two input bits, while the BORROW output indicates whether borrowing was necessary during the subtraction. The half sub
3 min read
Full Subtractor in Digital Logic
A full subtractor is a combinational circuit that performs subtraction of two bits, one is minuend and other is subtrahend, taking into account borrow of the previous adjacent lower minuend bit. This circuit has three inputs and two outputs. The three inputs A, B and Bin, denote the minuend, subtrahend, and previous borrow, respectively. The two ou
3 min read
Python program to implement Half Subtractor
Prerequisite: Half Subtractor in Digital Logic Given two inputs of Half Adder A, B. The task is to implement the Half Subtractor circuit and Print output i.e Difference and Borrow of two inputs. 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 si
2 min read
Python Program to implement Full Subtractor
Prerequisite -Full Subtractor in Digital Logic In this, we will discuss the overview of the full subtractor and will implement the full subtractor logic in the python language. Also, we will cover with the help of examples. Let's discuss it one by one. Given three inputs of Full Subtractor A, B, Bin. The task is to implement the Full Subtractor cir
4 min read
Article Tags :