## Conditional Byte Copy

The conditional byte copy function operates on a 3-byte array. It either copies the first byte to the second byte, or it does nothing, per the value of the third byte.

f( [ A, B, C ] ) = [ A, Q, C ], where C ∈ { 0, 1 }

Q is A if C is 1; otherwise, Q is B. In both cases, A and C pass through, unchanged.

In its circuit, shown below, each bit of Q, Qi, is the output of a 2-to-1 multiplexer that selects between Ai and Bi based on C0.

Here is the Tetris version:

Flipping the circuit horizontally creates a variation that either copies the third byte to the second byte, or does nothing, per the value of the first byte:

f( [ C, A, B ] ) = [ C, Q, B ], where C ∈ { 0, 1 }

Q is B if C is 1; otherwise, Q is A. In both cases, C and B pass through, unchanged.

The flipped circuit appears below.

The Tetris version follows.

Repositioning the multiplexers from the A lines to the B lines reverses the roles of the second and third bytes:

f( [ C, A, B ] ) = [ C, A, Q ], where C ∈ { 0, 1 }

Q is A if C is 1; otherwise, Q is B. In both cases, A and C pass through, unchanged.

Here is the schematic:

Below is the Tetris version.

Finally, flipping that circuit horizontally yields a variation that either copies the second byte to the first byte, or does nothing, per the value of the third byte:

f( [ A, B, C ] ) = [ Q, B, C ], where C ∈ { 0, 1 }

Q is B if C is 1; otherwise, Q is A. In both cases, B and C pass through, unchanged.

The flipped circuit follows.

Here is the Tetris realization: