A register swap exchanges the contents of two registers.
In hardware this can happen in one clock edge:
R1 ← R2, R2 ← R1
The comma in register transfer notation means both transfers happen at the same edge. Both registers sample their inputs at the same instant, using the values from before the edge, and only then do they update. So R1 receives R2's old value and R2 receives R1's old value. No temporary register is needed.
This is the same edge rule that makes a shift register work: every flip-flop reads its neighbor's old value.
Done as two separate edges, it fails: R1 ← R2 first overwrites R1, so R2 ← R1 then copies R2's own value back. Both end up equal.
If a datapath can only do one transfer per edge, it needs a third register and three edges:
- R3 ← R1
- R1 ← R2
- R2 ← R3
Software has the same problem, which is why a swap in most programming languages needs a temporary variable.