Digital Design LAB Lab 5 ADDER SUBTRACTOR

208 downloads 2527 Views 268KB Size Report
A half adder adds two one-bit binary numbers A and B. It has two outputs, S and C (the .... Implement the four circuit (half and full adder and subtractor).
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 ADDER SUBTRACTOR

 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.

 Half Adder: 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.

A 0 0 1 1

S = A xor B. C = A.B

input B 0 1 0 1

S 0 1 1 0

Output C 0 0 0 1

 Full Adder: 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 A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

Cin 0 1 0 1 0 1 0 1

S 0 1 1 0 1 0 0 1

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

output Cout 0 0 0 1 0 1 1 1

 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).

X 0 0 1 1

input Y 0 1 0 1

D 0 1 1 0

Output B 0 1 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 X 0 0 0 0 1 1 1 1

Y 0 0 1 1 0 0 1 1

Z 0 1 0 1 0 1 0 1

D 0 1 1 0 1 0 0 1

output B 0 1 1 1 0 0 0 1

D = X xor Y xor Z. B = Z.( X xnor Y) + X.Y

 4-bit Adder: 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.

 Adder-Subtractor: 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. Adding: A+B.

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). Implement the 4-bit adder-subtractor.