You are on page 1of 3

National University Of Modern Languages And Sciences

Submitted by: Muhammad Awais

Submitted to: Sir Asim Zaman

Roll no: 6648

Course: CA (Lab Task)

Assignment: 3
4-bit binary Adder – Subtractor Circuit
Theory:
The addition and subtraction operations can be combined into one common circuit by including
an XOR gate with each full adder. The subtraction of binary numbers can be done most
conveniently by means of complements. That is the subtraction A – B can be done by taking the
2’s complement of B and adding it to A.

Explanation:
When M = 0 the circuit is an ‘adder’

when M = 1 the circuit becomes a ‘subtractor’.

Each XOR-gate receives input M and one of the inputs of B.

• When M = 0, we have B ⊕ 0 = B. The full adders receive the value of B, the input carry is 0
(zero), and the circuit performs A plus B. • When M = 1, we have B ⊕ 1 = B’ and C0 = 1. This
means the B-inputs are all complemented by XOR and a ‘1’ is added through the input carry C0.
Hence the 2’s complement. Now the circuit performs the operation A plus the 2’s complement of
B i.e. A minus B.

Equations:

When, M = 0, A+B i.e. B ⊕ 0 = B and ‘add A’ to it using a Full-adder

When M = 1, A – B i.e. B ⊕ 1 = B’, ‘add C0 = 1’ (2’s complement of B) and Add A + B’.

Two Cases for Subtraction:

Depending on the values of A and B, we have cases: 1. A > B: In this case the resultant (A + 2’s
complement of B) sum will produce an end carry (Cout=1), which is discarded, and what is left is the
result A – B. 2. A < B: In this case the sum is equal to the 2’s complement of (B – A). To obtain the correct
answer, take the 2’s complement of the sum and place a negative sign in the front. The resultant is A –
B.

Now finds the the given task for the given Assignment is:
(1) For addition (M=0) take A3.A2.A1.A0 = 1 1 0 1 and B3.B2.B1.B0 = 0 1 0 0 and ADD.
(2) (2) For subtraction (M=1) take A3.A2.A1.A0 = 1 1 0 1 & B3.B2.B1.B0 = 0 1 0 0 & Subt.
We will need four full adders. Supplying them inputs respectively, A0, A1, A2, and 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.

(((((Screenshot Lgao Idr)))))))))))))))

You might also like