X and Y are n-bit wide registers. In each clock cycle you can select a bit-wise basic operation between X and Y and store 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.
Monday, March 2, 2009
Swapping X & Y
Subscribe to:
Post Comments (Atom)
x=x^y -- (1) selectLogic Op = XOR, Load XnotY=1
ReplyDeletey=(x^y) selectLogic Op = XOR, Load XnotY=0
=((x^y)^y) from(1)
y=x -- (2)
x=(x^y) selectLogic Op = XOR, Load XnotY=0
=(x^y^x) -- from (1)&(2)
x=Y
So X & Y are swapped
small correction for the above sol...
ReplyDeletethe last Load XnotY should be 1 (not 0)
it is a shame you don't give credit to where you 'borrowed' those from...
ReplyDeletehttp://asicdigitaldesign.wordpress.com