🡄 Previous

Next 🡆

Contents > Functions

Bitwise AND

The bitwise AND function operates on a 2-byte array. It sets the first byte to the bitwise AND of both bytes:

f( [ A, B ] ) = [ Q, B ]

Q = AB and B passes through, unchanged.

As revealed in the following schematic, each bit of Q, Qi, is the output of an AND gate that combines each bit of A, Ai, with each bit of B, Bi.

Bitwise AND Schematic

In the Tetris version below, the AND gates are arranged in a line in the top-left. The space-dominating parallelogram is composed of parallel chains of swap circuits that propagate the bits of B from right-to-left. Each chain is equivalent to one of the horizontal wires in the schematic. Since the swap circuits must be stacked to form a chain, the signals advance diagonally-upward.

Bitwise AND

There is a variation that sets the second byte to the bitwise AND of both bytes:

f( [ A, B ] ) = [ A, Q ]

Q = AB and A passes through, unchanged.

Its circuit is the horizontal reflection of the one above:

Bitwise AND Schematic

The Tetris realization follows.

Bitwise AND

🡄 Previous

Next 🡆