🡄 Previous

Next 🡆

Contents > Functions

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.

Q = C ? B : A

Here is the Tetris version:

Q = C ? B : A

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.

Q = C ? A : B

The Tetris version follows.

Q = C ? A : B

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:

Q = C ? B : A

Below is the Tetris version.

Q = C ? B : A

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.

Q = C ? A : B

Here is the Tetris realization:

Q = C ? A : B

🡄 Previous

Next 🡆