🡄 Previous

Next 🡆

Contents > Functions

Add

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

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

Q = A + B, where the plus sign denotes arithmetic add.

B passes through, unchanged.

Its circuit consists of a chain of full adders, devices capable of single-digit addition. Each full adder accepts three 1-bit addends, X, Y, and Z, and it outputs their sum, a 2-bit value composed of the twos bit, C, and the ones bit, S. The table below shows the outputs for all possible inputs.

XYZCSMeaning
000000 + 0 + 0 = 0
001010 + 0 + 1 = 1
010010 + 1 + 0 = 1
011100 + 1 + 1 = 2
100011 + 0 + 0 = 1
101101 + 0 + 1 = 2
110101 + 1 + 0 = 2
111111 + 1 + 1 = 3

Per the table rows where S is 1:

S = X Y Z + X Y Z + X Y Z + X Y Z

= X (Y Z + Y Z) + X (Y Z + Y Z)

= X (Y ⊕ Z) + X (Y ⊕ Z)

= X ⊕ Y ⊕ Z

= X ⊕ Y ⊕ 1 ⊕ Z

= (X ⊕ Y ⊕ 1) ⊕ Z

= (X ⊕ Y) ⊕ Z

Per the table rows where C is 1:

C = X Y Z + X Y Z + X Y Z + X Y Z

= Z (X Y + X Y) + X Y (Z + Z)

= Z (X X + X Y + X Y + Y Y) + X Y

= Z (X + Y) (X + Y) + X Y

= Z (X + Y) (X Y) + (X Y)

= Z (X + Y) + (X Y)

= Z (X + Y) + (X Y) + (X Y)

= Z (X + Y) + (X X Y) + (Y X Y)

= Z (X + Y) + (X X Y + X X Y) + (Y X Y + Y X Y)

= Z (X + Y) + X (X Y + X Y) + Y (X Y + X Y)

= Z (X + Y) + X (X ⊕ Y) + Y (X ⊕ Y)

= Z (X + Y) + (X ⊕ Y) (X + Y)

= (X + Y) (Z + X ⊕ Y)

The expressions for S and C are combined:

T = X ⊕ Y

S = T ⊕ Z

C = (X + Y) (Z + T) = X + Y + Z + T

The resultant expressions suggest the following circuit, where the XNORs (the gray rectangles) are composed from four NORs.

Full Adder Schematic

The Tetris realization is based on a slight modification that forwards input X through and out between C and S. It consists of nine NORs and three crosses, as shown below.

Full Adder Schematic, Outputs X

Here are the results for X = 0 and all possible values of Y and Z:

Full Adder, X = 0

Here are the results for X = 1 and all possible values of Y and Z:

Full Adder, X = 1

The complete circuit consists of full adders chained in the arrangement below. Each full adder accepts a pair of addend digits, Ai and Bi, and it outputs their sum digit, Qi, along with one of the input digits, Bi, unmodified.

4-bit Adder Schematic

The circuit evaluates right-to-left. For each full adder, if the sum of the carry-in, Z, and the addend digits, Ai and Bi, is not a single-digit number, then the high digit, C, is carried out to the full adder on its left. The initial carry-in is 0 (far right) and the final carry-out is lost.

Crisscrossing wires are required to interlace the inputs and to disentangle the outputs:

8-bit Adder Schematic

The Tetris realization retains the triangular patterns from all the cross overs:

8-bit Adder

The full adders are stacked diagonally to enable the carries to ripple in the expected order.

🡄 Previous

Next 🡆