4.6k views

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 $C_0$ only (+ and – denote addition and subtraction respectively)?

1. $A + B$, and $A – B$, but not $A + 1$
2. $A + B$, and $A + 1$, but not $A – B$
3. $A + B$, but not $A – B$ or $A + 1$
4. $A + B$, and $A – B$, and $A + 1$
edited | 4.6k views
+21

S0 = Axor ( Bxor K) xor C0

C1 = A0(B0 xor K) + A0C+ (Bxor K).C0

Now Since we can put only values for K and C0. Therefore we can have 4 possible combinations of K and C0 ( 00,01,10,11). Putting these values in the above formula we get

1. K = 0 and C0 = 0  gives S= Axor B0   and C1 = A0.B0. This shows A+B can be performed( Full Adder forumla modification by putting values of K and C0)

2. K = 1 and C= 1 gives S= Axor B0  and C1 = A0.B0' + A+ B0' . This shows A-B can be performed. ( Full Subtractor formula modification by putting values of K and C0.)

3. But to have A + 1 we need to put B = 0 and thats not allowed.

So option A is correct.

+1
but it is given the input is already in  2's complement form..so K=0,C=0  should give A-B not A+B right?
+3
@Mitari when k=0, B xor k = B. Therefore the full adder will perform A+B. If B is a negative number then since it is in 2'complement form, A+(-B) will be calculated.
0
0

## Trick to memorize the carry equations-

There are two  control line one is $K$ and another is $C_{0}$ .

When $K=1$ , $C_{0}= 1$ we can perform $A-B$

When $K=0$,  $C_{0}=0$ we can perform $A+B$

But without manipulating $B(B_{0},B_{1},\ldots)$ we cannot perform A+1. But here we have only two control lines which is $K,C_{0}$. Therefore the answer is A.

Note:

For A+B, $C_{0}= 0$ , $K=1$, and $0 \oplus x = x$

$\frac{\begin{matrix} &A3 &A2 &A1 &A0 \\ +& B3 & B2 & B1 & B0 \end{matrix}}{\begin{matrix} &S3&S2&S1&S0\end{matrix}}$

$\frac{\begin{matrix} &C3&C2&C1&C0=0\\ &A3 &A2 &A1 &A0 \\ \qquad\qquad\qquad\qquad+& B3 & B2 & B1 &B0 \end{matrix}}{\begin{matrix} Sum \enspace Output:&S3&S2&S1&S0\\Carry \enspace Output:\qquad&C4&C3&C2&C1\end{matrix}}$

For A- B, $C_{0} = 1$ , $K = 1$, and $1\oplus x=\bar x$

Subtraction Using 1's complement, $(A -B)$

1. Find 1's complement of $B$= $2^{n}-1 -B$,  We do 1's complement but change bits 0 to 1 or 1 to 0 (where n is no of bits)

2. Add A , $2^{n} -1 - B +A = 2^{n}-1+(A-B)$ but we need only A-B , $2^{n}$ is last carry , That is, $C_{4}$ will be discarded, to remove -1, add $C_{0}=1$.

$\frac{\begin{matrix} &A3 &A2 &A1 &A0 \\ -& B3 & B2 & B1 & B0 \end{matrix}}{\begin{matrix} &S3&S2&S1&S0\end{matrix}}$

Subtraction using 1's complement

$\frac{\begin{matrix} &C3&C2&C1&C0=1\\ &A3 &A2 &A1 &A0 \\ \qquad\qquad\qquad\qquad+& \overline{B3} & \overline{B2} & \overline{B1} &\overline{B0} \end{matrix}}{\begin{matrix} Sum \enspace Output:&S3&S2&S1&S0\\Carry \enspace Output:\qquad&C4&C3&C2&C1\end{matrix}}$

selected
0
@praveen saini : can you tell how A+B+1 is possible as told by some students.
+2
K = 0 , C0 = 1
0

sir,

2^n is the last carry , I didnot understand this part ?

+2
For (A - B), you should write $1 \oplus x=\overline{x}$
0
Thanks very nice explanation :)

In the note part for A+B ,c=0;k=0
+1
Hello Riya nice explanation but I m little bit confused ...in the question if it is given that operands are in 2's complement representation then what does it mean here
0
If the operands are in 2′s complement representation

What if the numbers are given in 1's complement representation

Will this circuit works fine ??

Can we use 2's complement subtraction method for Numbers represented in 1's or sign magnitude representation ??
0

What if the numbers are given in 1's complement representation

Will this circuit works fine ??

yes...

K=0,C0=0 ===> A+B

K=1, C0=0 ===> A-B

K=0,C0=1 ===> A+B+1

K=1,C0=1 ===> A-B+1

Can we use 2's complement subtraction method for Numbers represented in 1's or sign magnitude representation ??

if the numbers are positive, then there is no problem.

otherwise 2's complement subtraction also lead to their own ( 1's complement/sign magnitude) method.

if you takes 1's complement form, then A-B = A + (1's complement of B) ===> A-B = A + X

which is same as adding positive numbers ( in 2's complement form ), then by seeing result you have to follow 1's complement subtraction.

0
Means if numbers are signed and in 1s complement representation..i cant use 2s complement subtraction method ??
0
yes
0

Means if numbers are signed and in 1s complement representation..i cant use 2s complement subtraction method ??

For binary base is 2. 1's complement is diminished radix subtraction and 2's complement is radix subtraction.

In diminished radix we have to ignore carry and add 1 [(base ^ n) -1)+ x-y] and radix is [base ^ n +x - y ]

following operations can be performed by suitably setting the control lines K and C0 only !

It is given that we can not touch B here. B input is fixed.

So suppose we set K = 0, C0 = 0, Then we can perform A + B.

We set K = 1, C0 =0 we can perform A - B.

We can not perform A + 1 because ,even though we can set K = 0, & C0 =1 we can not set B to 0. Though we can computer now A+B+ 1 !

0
for A-B, K-1 and C0=1. You need to take 2s complement of B.
+1
In 2nd  substitution it should be :

$K=1$  and  $C_0=1$

$A-B$ = $A+$ ~B$+1$

Please edit if you find it correct.
0

@Akash Kanase @Riya Roy(Arayana)  @Arjun @Praveen Saini What happens when C0 = 0 and K = 1?

A + B: It can be done by setting  K = 0 and Co = 0

A - B: It can be done by setting K = 1 and Co = 1 because here subtraction is done using 2's complement so by K = 1, we are getting 1's complement of B and by Co = 1, we are adding 1 to make 2's complement of B and then adding A and 2's complement of B.

A + 1, A - 1: It can't be performed as B is always there either as B or B' which can't be made 1 by K, C
ans d)
0
option A) is the correct ans.But I'm also getting D)
:(
0
How? What is the use of K?
+1

A+B can be done when k=0 (then we get (k xor B)=B) and C0=0

A-B can be done when k=1 (then we get the complement of B) and C0=1

that means A+(-B)

option A.

0
And In case B0, B1........ all are 0 then it gives A + 1. So, D) should be the answer.
What is wrong in this?
0

In the question it is given that you can only change the K and C0 but setting B is not possible.

To perform A+1 with given circuit, its necessary to make B side input to be 0 & C0 = 1. Since there is bit wise XOR is taking place before input to the full adder so we can only get B's 1's complement or B as it is. This the reason we can not perform A+1.

0
A and B are inputs given by the user and can be anything. I don't think it would be wrong if we compute A+1 by keeping B=0.

So I think (D) should be the answer.

If k=0 and c0 = 0 then A+B

If k=1 and c0=1 then A-B

If k=0 and c0=1 and B =1 then A+1

(If K is connected to c0, then manipulating k and c0 Simultaneously
is not be possible, in that case answer is be A)

0

In the question it is given that you can only change the K and C0 but setting B is not possible.

To perform A+1 with given circuit, its necessary to make B side input to be 0 & C0 = 1. Since there is bit wise XOR is taking place before input to the full adder so we can only get B's 1's complement or B as it is. This the reason we can not perform A+1.

1
2