# How to design a four bit adder-subtractor circuit?

In this article you will learn about how to design a four bit adder-subtractor circuit? Every Digital Computer should always execute two arithmetic Operations: addition & subtraction. Multiplication & Division operations become simple if both of these tasks are implemented properly (Multiplication is equivalent to repeated addition, whereas division is equivalent to repeated subtraction). Take into account the process of trying to add multiple binary numbers, that is the basic operations executed by a computer system. The four fundamental addition operations for multiple binary numbers which are single bit, are as follows:

• 0 + 1 = 1
• 1 + 0 = 1
• 0 + 0 = 0
• 1 + 1 = (Carry)1 0

Every Digital Computer should always execute two arithmetic Operations: Every binary addition during first 3 operations yields a total of one bit, namely, either zero or one. However, the output of the 4th addition operation (with inputs of One and one) is 2 binary numbers. here lower significant bit usually referred to as ‘Sum Bit,’ whereas higher significant bit has been referred to as ‘Carry Bit.’

A full adder within Digital Logic

The full adder is an added that takes three inputs &generates two outputs as a result. The first 2 inputs typically A & B, with the third being a C-IN input carry. Output carry generally labelled as C-OUT, whereas normal output labelled as S, that stands for SUM.

A half adder is a type of combinational arithmetic circuitry that uses two numbers addition and outputs an S, sum bit, as well as a C, carry but.  The S (sum bit) is the result of the XORing of A & B, and also the C (carry bit) is the ANDing of A & B, if A & B, seem to be input bits.

## 4 Bit Adder and Subtractor

Binary Adder-Subtractor comprises a digital circuit that can perform basic arithmetic of binary integers in the same circuit. The binary result of a control signal determines the operation to be executed. It’s among the ALU‘s, arithmetic logic unit elements

XOR Gate, Full Adder, and Binary Addition & Subtraction, are all prerequisites for this circuit.

Designing: A single basic binary adder may do both addition & subtraction tasks. As illustrated in the diagram underneath, a binary circuit may be created by combining an Ex-OR gate alongside every full adder. 4-bit parallel adder and 4-bit parallel subtractor shown below has multiple 4 bit inputs labelled ‘A3 A2 A1 A0’ & ‘B3 B2 B1 B0’.

The carry input of the of the full adder’s least significant bit is linked to the mode input control line labelled as k. The kind of execution, either addition and otherwise subtraction, is determined by such a control line.

If k equals to 1, circuit is just a subtractor, but when k equals to zero, it is then converted to an adder. XOR gate has 2 inputs, only one of which being Linked to the B, the other to the input k. Whenever k = 0, B Ex-ORed 0 results in B. Next, full adders perform addition of B & A with carry input 0, resulting in addition operation.

• If M = 1, the B Ex-ORed Zero produces the B complement, as well as the carry input becomes 1. As a result, inputs of complemented B are added with A, then One is added via input carry, nothing more than an operation of 2’s complement. As a result, the operation of subtraction is carried out.
• First Adder: The 1st full adder includes a control line as one of its direct inputs (input carry Cin).
• Second Adder: Within full adder, the input A0, A’s least significant bit, is explicitly input.
• Third Adder: The XORed of k and B0 is the 3rd input. Sum or Difference, referred to as S0 and Carry (C0) are the outputs generated.

Procedure

Finally, as being one of the outputs of the 2nd full adder, C0 gets serially passed. The sum or difference S0 gets stored as the sum or difference’s least significant bit. A1, A2, & A3 constitute as direct inputs to the 2nd, 3rd, and 4th full adders, respectively. The 3rd input would be the B1, B2, B3 XORed K to the 2nd, 3rd, and 4th full adders. Carry C1 and C2 get serially passed as inputs towards the consecutive full adder. C3 will become the sum or difference’s total carry. S1, S2, and S3 are recorded in order to build the outcome with S0.We employ n full adders to create an n-bit adder-subtractor.

### Truth Table

It is used for the addition of significant digits.(carry)
The logic gates which are used in Binary full-adders are And gate, OR gate and EXOR gate.
In practical life, the applications of full adders are that they are used in digital processors.
It is used for addition of Least significant digits.
The logic gates involved in half adders are EX OR gate and AND gate.

Half adders are practically used in digital measuring devices like calculators.
Subtractor:
It is a digital circuit used for subtraction of binary numbers using logic gates. In this we add (2’s compliment and 1) on the number from to be subtracted. For example we have to subtract A from B, We do A+ (2’s compliment of B+1). Two types: Half-subtractor and Full-subtractor.
Full subtractor:
It is the circuit in which subtraction of two bits is done by borrowing. There are three inputs and two outputs.
Half-Subtractor:
The half subtractor  is used to subtract two binary . There are two inputs and two outputs on this device. This circuit is used to subtract two binary values, A and B, that are both single bits. The half subtractor has two output states: ‘diff’ and ‘borrow.’

Basically it is a digital circuit which does both addition as well as subtraction itself. This circuit works using an EX-OR gate, binary addition and subtraction, Full adder.

We will need four full adders. Supplying them inputs respectively, A0, A1, A2, A3 for first adder, second adder, third adder, and fourth adder. Now the second input for adders would be output of EX-OR gates, Same as input A, There would be attached four EX-OR gates with all adders respectively. As we all know that this EX-OR gate will have two inputs. The first input of this EX-OR gate would be named as B, and as done previously

We will name B0, B1, B2, B3 respectively. And the second input to this EX-OR gate is what we are providing it to be ‘M’ input which would be the second input of the EX-OR gates and which would be same for all EX-OR gates. This M will decide whether we are performing addition operation or subtraction operation. And Beside all this the 3rd input we are going to provide is to be known as the carry or borrow, which would be the same ‘M’. In case of addition it would be carry while in case of subtraction it would be borrow.

So in addition operation this carry is given to the full-adder and the full adder output would be sum S0 (at the first adder) and carry C1(from the first full adder). And the carry generated would be propagated to the next full adder. Similarly, next full adder will generate sum and generate carry to next full adder, and so on to all full adders.
But if it would be a subtraction operation then instead of sum we would be having difference and instead of carry we would be having borrow. So this is our circuit.