## Puzzle #3

June 4, 2007OK, you seem to like them so here is another puzzle/interview question.

In the diagram below both X and Y are n-bit wide registers. With each clock cycle you could select a bit-wise basic operation between X and Y and load it to either X or Y, while the other register keeps its value.

The problem is to exchange the contents of X and Y. Describe the values of the “select logic op” and “load XnotY” signals for each clock cycle.

Advertisements

This one works on confusion. XOR (^) is all you need here. Remember that

by Saar Drimer June 5, 2007 at 2:52 pm`X^X=0 and that X^0=X`

So:

`X,Y (XOR, store in X)`

(done)X^Y,Y (XOR, store in Y)

X^Y,Y^(X^Y) = Y^Y^X = 0^X = X (XOR, store in X)

X^(X^Y) = Y,X

Good job Saar!!!

by nirdahan June 5, 2007 at 6:27 pm[…] – Solution June 19th, 2007 This post is written only for completeness reasons. The answer to puzzle #3 was almost immediately given in the comments. I will just repeat it here. The important […]

by Puzzle #3 - Solution « Adventures in ASIC Digital Design June 19, 2007 at 3:09 pmx = x^y — [1]

by Narasimha January 21, 2009 at 1:01 pmy = x^y

from [1], y =(x^y)^y = x –[2]

x = x^y

from[1] & [2] x= =(x^y)^x = y

solution is

x = x ^ y;

y = x ^ y;

x = x ^ y;

for alu select xor operation, and xnoty 1, 0 , 1 for seleting x y and x as destination register.

by sudeep September 24, 2009 at 9:38 am1) loadxnoty=1 , selectlogicop = xor

(x) -> x^y , (y) -> y

2) loadxnoty=0 , selectLogicOp = xor

(x) -> x^y , (y) -> (x^y)^y = x

3) loadxnoty=1 , selectLogicOp = xor

(x) -> (x^y)^x = y , (y) => x

o/p = (x^y)^y

x | y | o/p |

0 | 0 | 0 |

0 | 1 | 0 |

1 | 0 | 1 |

1 | 1 | 1 |

Therefore (x^y)^y = x

by Tushar May 15, 2010 at 7:18 am