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

4-bit binary Adder-Subtractor

Last Updated : 09 Oct, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

In Digital Circuits, A Binary Adder-Subtractor is can do 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). 

What is Binary Adder?

A Binary Adder is an electronic circuit that sums two binary numbers. The most basic types are half adders and full adders. A half adder takes in two one-bit numbers, producing a sum and a carry bit. Full adder have three input bits-two actual bits and an incoming carry from the preceding operation. This makes the Full Adder to add multi-bit binary numbers as the carry can propagate through a number of Full Adders in a ripple-carry adder configuration.

What is Binary Subtractor?

A Binary Subtractor is used to perform the subtraction of two binary numbers. Just as in the case of addition, this also can be done using an array of logic gates. The subtraction is done by using two’s complement, in which the circuit first negates the binary number to obtain its complement and then adds one to the result before imputing it into a binary adder circuit together with the original number. Both addition and subtraction are handled by this type of circuit.

This Circuit Requires prerequisite knowledge of Xor 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. 

4-bit binary Adder-Subtractor

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

Advantage of Binary Adder and Subtractor

  • Low Design Complexity: Both binary adder and subtractor circuits are easy to design using logic gates like XOR, AND, and OR.
  • High-Speed Operations: Binary adders such as parallel adders-and subtractors can do their operations at a high speed.
  • Versatility: It allows the same hardware : to add ,to subtract. Saving on redundancy of separate components and designs for different functions.

Disadvantages of Binary Adder and Subtractor

  • Carry Propagation Delay: In a simple ripple carry adder, the carry has to ripple through all stages of the adder; this increases the computation time as more bits are added. This will be more for a larger number of bits in binary.
  • Hardware Complexity: The more the number of bits, the more complicated the circuit gets due to more gates. To eliminate the problem of delays, higher versions of adders such as carry lookahead adders are included which increases complexity.

Conclusion

In general, the most important of these in binary adders and subtractors is to form the backbone of any arithmetic performed by computers and calculators or any other digital system. The design is relatively easy for small numbers but gets complex as the size of the numbers increases resulting in carry propagation delay.

Considering two’s complement, among other methods, it can be done both addition and subtraction without additional hardware. In Reality, it happens exactly the opposite: designers manage to maintain balance between speed, complexity, and power consumption by not implementing these circuits in real life.

Frequently Asked Questions on 4-Bit Binary Adder-Subtractor – FAQs

Does the Binary Adder-Subtractor consider the sign of the output?

Yes, If result is negative, then circuit outputs it in two’s complement form, so it still in the binary system. There’s also usually a special sign bit that lets you know if the result is positive (0) or negative (1).

What happens if the result of my addition or subtraction is too big for the circuit to handle?

That’s called overflow. If the result can’t fit within the number of bits the circuit is designed for, the Binary Adder-Subtractor will indicate an overflow error.

Can a Binary Adder-Subtractor only work with whole numbers?

Yes, the basic version handles whole binary numbers (integers). If you want to work with fractions or decimals, you’d need more advanced circuits that handle floating-point arithmetic.



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
Half Adder and Half Subtractor using NAND NOR gates
Introduction : A Half Adder is a digital circuit that adds two single-bit binary numbers and outputs the sum and carry. It can be implemented using either NAND gates or with NOR gates. When using NAND gates : The sum output is given by A AND B. The carry output is given by the complement of A AND B. ​ ​W​hen NOR gate is used : The sum output is NOR
5 min read
Parallel Adder and Parallel Subtractor
Adding and Subtracting numbers is very simple in digital electronics. To do this for quickly and efficiently, Most of the for binary numbers (numbers made of 1 and 0), we use circuits like the Parallel Adder and Parallel Subtractor. These types of circuits can handle more than one bit at a time, making the process faster. Binary AdditionBinary addi
6 min read
Difference between Serial Adder and Parallel Adder
A Addition is a fundamental operation in the digital electronics and it is used in a wide range of a applications such as the arithmetic, data processing and control systems. There are the two main types of a adders used in digital circuits are Serial Adder and a Parallel Adder. Understanding the differences between these two types of a adders is e
7 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
6 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
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
C++ program to implement full subtractor
Prerequisite : Full SubtractorGiven three inputs of Full Subtractor A, B, Bin. The task is to implement the Full Subtractor circuit and Print output states difference (D) and Bout of three inputs. Introduction :The full subtractor is used to subtract three 1-bit numbers which are minuend, subtrahend, and borrow, respectively. The full subtractor ha
2 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
Serial Binary Adder in Digital Logic
Serial binary adder is a combinational logic circuit that performs the addition of two binary numbers in serial form. Serial binary adder performs bit by bit addition. Two shift registers are used to store the binary numbers that are to be added. A single full adder is used to add one pair of bits at a time along with the carry. The carry output fr
2 min read
Binary Adder with Logic Gates
Binary Adder and logic gates are important elements in digital logic. Binary adders are circuit which adds two binary numbers and results in the sum of the two binary numbers. Logic gates are the circuit in which a signal can pass through if a logic is applied through it. In this article we will discuss about the binary adder with logic gates, bina
8 min read
Carry Look-Ahead Adder
The adder produce carry propagation delay while performing other arithmetic operations like multiplication and divisions as it uses several additions or subtraction steps. This is a major problem for the adder and hence improving the speed of addition will improve the speed of all other arithmetic operations. Hence reducing the carry propagation de
5 min read
C++ program to implement Half Adder
Prerequisite : Half Adder in Digital Logic We are given with two inputs A and B. Our task is to implement Half Adder circuit and print the outputs sum and carry of two inputs. Introduction : The Half adder is a combinational circuit which add two1-bit binary numbers which are augend and addend to give the output value along with the carry. The half
2 min read
Full Adder Using Demultiplexer
Full Adder is a combinatorial circuit that computes the sum and carries out two input bits and an input carry. So it has three inputs - the two bits A and B, and the input carry Cin, and two outputs - sum S and output carry Cout. Demultiplexer is a combinational circuit which has 1 input, n selection lines and generates 2n outputs. It is the revers
2 min read
Implementation of Full Adder using NOR Gates
In Digital Logic Circuit, Full Adder is a Digital Logic Circuit that can add three inputs and give two outputs. The three inputs A, B, and input carry as Cin. Cout is represented as output carry and Sum is represented as output. We can say Cout is called the majority 1’s detector, when more than one input is high (logic 1) then its output will be h
8 min read
Implementation of Full Adder using NAND Gates
In Digital Logic Circuit, Full Adder is a Digital Logic Circuit that can add three inputs and give two outputs. The three inputs such as A, B, and input carry as Cin. The output carry is represented as Cout and the normal output is represented as S, Sum. The Cout is also known as the majority 1’s detector, whose output goes high when more than one
9 min read
Implementation of Full Adder Using Half Adders
Implementation of full adder from half adders is possible because the half adders add two 1-bit inputs in full adder we add three 1-bit inputs. To obtain a full adder from a half adder we take the first two inputs and add them and use the sum and carry outputs and the third input to get the final sum and carry output of the full adder. In this arti
5 min read
Python program to implement Full Adder
Prerequisite : Full Adder in Digital LogicGiven three inputs of Full Adder A, B,C-IN. The task is to implement the Full Adder circuit and Print output i.e sum and C-Out of three inputs. Full Adder : A Full Adder is a logical circuit that performs an addition operation on three one-bit binary numbers. The full adder produces a sum of the three input
2 min read
BCD Adder in Digital Logic
BCD stands for binary coded decimal. It is used to perform the addition of BCD numbers. A BCD digit can have any of ten possible four-bit representations. Suppose, we have two 4-bit numbers A and B. The value of A and B can vary from 0(0000 in binary) to 9(1001 in binary) because we are considering decimal numbers.  The output will vary from 0 to 1
8 min read
Full Adder in Digital Logic
Full Adder is the adder that adds three inputs and produces two outputs. The first two inputs are A and B and the third input is an input carry as C-IN. The output carry is designated as C-OUT and the normal output is designated as S which is SUM. The C-OUT is also known as the majority 1's detector, whose output goes high when more than one input
5 min read
Full Adder using Verilog HDL
A full adder is a digital circuit in Verilog HDL that adds three binary numbers. It has two inputs for the numbers to be added, A and B, and one Carry-In input, Cin. The outputs are Sum, S, and Carry-Out, Cout. A full adder has been implemented using Verilog as shown in the previously shared code snippet. Problem StatementWrite a Verilog HDL to des
5 min read
Python program to implement Half Adder
Prerequisite: Half Adder in Digital Logic Given two inputs of Half Adder A, B. The task is to implement the Half Adder circuit and Print output i.e sum and carry of two inputs. Half Adder: A half adder is a type of adder, an electronic circuit that performs the addition of numbers. The half adder is able to add two single binary digits and provide
5 min read
Half Adder in Digital Logic
A half adder is a digital logic circuit that performs binary addition of two single-bit binary numbers. It has two inputs, A and B, and two outputs, SUM and CARRY. The SUM output is the least significant bit (LSB) of the result, while the CARRY output is the most significant bit (MSB) of the result, indicating whether there was a carry-over from th
4 min read
Half Adder Using Verilog
A Half Adder is probably one of the simplest digital circuits you can use in addition of two single-bit binary numbers. The circuit has two inputs: the bits A and B, and two outputs: Sum (S) and Carry (C). The sum represents the addition of the two bits; carry shows the overflow into the next higher bit. The Half Adder used XOR gate for Sum and AND
6 min read
Difference Between 8 Bit and 16 Bit Music
Music is described in the form of waves. By varying the amplitude periodically, it can generate a frequency which is called a tone. It is just a sound effect. It has an amplitude and generates a frequency. It has 8-bit music and 16-bit music. 8 - Bit MusicIt refers to any number in the form of a binary from 0 to 255. It is used to create tracks for
4 min read
Difference Between 8 Bit and 16 Bit Microcontroller
Microcontrollers are small, low-power computers designed for specific tasks. They are widely used in embedded systems such as household appliances, automotive systems, medical devices, and industrial control systems. Microcontrollers are available in various configurations and architectures, and they differ in terms of processing power, memory, and
5 min read
4 Bit Binary Incrementer
What is 4 Bit Binary Incrementer ?It adds 1 binary value to the existing binary value stored in the register or in other words we can simply say that it increases the value stored in the register by 1.For any n-bit binary incrementer ,‘n’ refers to the storage capacity of the register which needs to be incremented by 1. So we require ‘n’ number of
2 min read
4 Bit Binary Decrementer
What is 4 Bit Binary Decrementer ?It subtracts 1 binary value from the existing binary value stored in the register or in other words we can simply say that it decreases the existing value stored in the register by 1. For any n- bit binary decrementer, ‘n’ refers to the storage capacity of the register which needs to be decremented by 1. So we requ
3 min read
One bit memory cell (or Basic Bistable element)
A One Bit Memory Cell (also known as a Basic Bistable Element) is a digital circuit that can store a single bit of information. It is a type of sequential circuit that can hold its state until a new input signal is received, causing the state to change. One Bit Memory Cells are used in digital systems as temporary storage elements and are the build
6 min read
Article Tags :
three90RightbarBannerImg