GATE | GATE-CS-2003 | Question 90
Consider the ALU shown below.
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
Explanation: We can set value of k and c as 0 or 1
Two things we need to know—
- If we take xor of any number with 1 we get it in its complement form.
- 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
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.