adder n sub

download adder n sub

of 7

Transcript of adder n sub

  • 7/29/2019 adder n sub

    1/7

    Islamic University of Gaza

    Faculty of Engineering

    Department of Computer Engineering

    Fall 2011ECOM 4113: Digital Design LAB

    Eng. Ahmed Abumarasa

    Digital Design LAB

    Lab 5

    ADDER SUBTRACTOR

  • 7/29/2019 adder n sub

    2/7

    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 half-

    adder 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 Output

    A B S C

    0 0 0 0

    0 1 1 0

    1 0 1 0

    1 1 0 1

    S = A xor B.

    C = A.B

  • 7/29/2019 adder n sub

    3/7

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

  • 7/29/2019 adder n sub

    4/7

    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 Output

    X Y D B

    0 0 0 0

    0 1 1 1

    1 0 1 0

    1 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) andtwo 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 11 0 0 1 0

    1 0 1 0 0

    1 1 0 0 0

    1 1 1 1 1

  • 7/29/2019 adder n sub

    5/7

    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 thefirst (and only the first) full adder may be replaced by a half adder.

  • 7/29/2019 adder n sub

    6/7

    Adder-Subtractor:In digital circuits, an addersubtractor 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.

  • 7/29/2019 adder n sub

    7/7

    Lab work: Implement the four circuit (half and full adder and subtractor). Implement the 4-bit adder-subtractor.