GATE | GATE-CS-2003 | Question 90

Consider the ALU shown below.

GATECS2009Q46

If the operands are in 2’s complement representation, which of the following operations can be performed by suitably setting the control lines K and C0 only (+ and – denote addition and subtraction respectively) ?
(A) A + B, and A – B, but not A + 1
(B) A + B, and A + 1, but not A – B
(C) A + B, but not A – B, or A + 1
(D) A + B, and A – B, and A + 1


Answer: (A)

Explanation: We can set value of k and c as 0 or 1



Two things we need to know—

  1. If we take xor of any number with 1 we get it in its complement form.
  2. If we take xor of any number with 0 we get that number itself.

So on setting k=1 we can get –B and c will work like select signal

Like c=0 means add

C=1 means subtract

Hence with k=1 c=1 we get A-B

With K=0 c=0 we get A+B

We need b=1,c=0 or b=0,c=1 to get A+1
since b isn’t predefined we can’t get A+1

So Ans is (A) part.

Quiz of this Question



My Personal Notes arrow_drop_up

Improved By : nimesh krishnani



Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.