h1

Puzzle #3

June 4, 2007

OK, 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.

load_puzzle.png

3 comments

  1. This one works on confusion. XOR (^) is all you need here. Remember that
    X^X=0 and that X^0=X
    So:
    X,Y (XOR, store in X)
    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
    (done)


  2. Good job Saar!!!


  3. [...] - 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 [...]


Leave a Comment