# Digital Design LAB Lab 5 ADDER SUBTRACTOR

## Preview text

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering Fall 2011 ECOM 4113: Digital Design LAB Eng. Ahmed Abumarasa
Digital Design LAB
Lab 5

 Introduction:
In electronics, an adder or summer is a digital circuit that performs addition of numbers. In many computers and other kinds of processors, adders are used not only in the arithmetic logic unit(s), but also in other parts of the processor, where they are used to calculate addresses, table indices, and similar.

A half adder adds two one-bit binary numbers A and B. It has two outputs, S and C (the value theoretically carried on to the next addition); the final sum is 2C + S. The simplest halfadder design, pictured on the right, incorporates an XOR gate for S and an AND gate for C. Half adders cannot be used compositely, given their incapacity for a carry-in bit.

input

A

B

0

0

0

1

1

0

1

1

Output

S

C

0

0

1

0

1

0

0

1

S = A xor B. C = A.B

A full adder adds binary numbers and accounts for values carried in as well as out. A one-bit full adder adds three one-bit numbers, often written as A, B, and Cin; A and B are the operands, and Cin is a bit carried in (in theory from a past addition). The circuit produces a two-bit output sum typically represented by the signals Cout and S, where
. The one-bit full adder's truth table is:

input

output

A

B

Cin

S

Cout

0

0

0

0

0

0

0

1

1

0

0

1

0

1

0

0

1

1

0

1

1

0

0

1

0

1

0

1

0

1

1

1

0

0

1

1

1

1

1

1

S = A xor B xor Cin. Cout = A.B + A.Cin + B.Cin = (A xor B).Cin + A.Cin

 Half subtractor :

The half-subtractor is a combinational circuit which is used to perform subtraction of two bits. It has two inputs, X (minuend) and Y (subtrahend) and two outputs D (difference) and B (borrow).

input

X

Y

0

0

0

1

1

0

1

1

Output

D

B

0

0

1

1

1

0

0

0

D = X xor Y. B = X.Y

 Full subtractor :

The full-subtractor is a combinational circuit which is used to perform subtraction of three bits. It has three inputs, X (minuend) and Y (subtrahend) and Z (subtrahend) and two outputs D (difference) and B (borrow).

D = X- Y- Z. B = 1 if (X < y+ z)

input

output

X

Y

Z

D

B

0

0

0

0

0

0

0

1

1

1

0

1

0

1

1

0

1

1

0

1

1

0

0

1

0

1

0

1

0

0

1

1

0

0

0

1

1

1

1

1

D = X xor Y xor Z. B = Z.( X xnor Y) + X.Y
It is possible to create a logical circuit using multiple full adders to add N-bit numbers. Each full adder inputs a Cin, which is the Cout of the previous adder. This kind of adder is a ripple carry adder, since each carry bit "ripples" to the next full adder. Note that the first (and only the first) full adder may be replaced by a half adder.

In digital circuits, an adder–subtractor is a circuit that is capable of adding or subtracting numbers (in particular, binary). Below is a circuit that does adding or subtracting depending on a control signal. It is also possible to construct a circuit that performs both addition and subtraction at the same time.

M: controller, adding when M=0 and Subtracting when M=1.

Sub: A-B.

V: overflow flag, denote that an overflow happened when V=1.

 Lab work:
 Implement the four circuit (half and full adder and subtractor). 