Binary Addition and Subtraction

Tom Kelliher, CS 220

Oct. 3, 2003

Administrivia

Announcements

Written assignment due Monday.

Assignment

Read 3.10

From Last Time

Decoders, encoders, muxes.

Outline

  1. Binary Adders

  2. Unsigned binary subtraction; complements.

Coming Up

Combined signed addition/subtraction.

Binary Adders

  1. Two half-adders and an OR gate give us a full binary adder. In the text, note how an earlier computed XOR is used to eliminate a gate from the carry equation.

  2. Full binary adder: three inputs, two outputs.

  3. Ripple carry adder: example of reuse and divide and conquer.
    1. Wire together n full binary adders in order to add two n bit numbers.

      Wiring example.

    2. Running time of a ripple carry adder.

      Running time of a full binary adder is O. Ripple carry adder?

      Excessive!!!

  4. An O (!!!) adder.
    1. Important equations (briefly explain):

      Carry generate at bit position i: .

      Carry propagate at position i: .

    2. Carry-in is .

      .

      .

      .

      Etc.

    3. What's the circuit depth of ?

    4. What's wrong with this picture?

  5. Carry lookahead addition.
    1. A different type of divide and conquer adder using a tree hierarchy to compute and distribute carry information.

    2. What's the height of a binary tree?

      (CLA is not binary, more like quad, but that's ok.)

    3. What's the running time of a CLA?

Unsigned Binary Subtraction

Unsigned here means we can use a minus sign. Realistic?

Let A = 110101 and B = 011010. Compute A - B and B - A.

A - B: fine. B - A: borrow out of msb.

  1. Actual value computed: .

  2. We want .

  3. So, compute .

The borrow into the msb leads us to the notion of complements.

Complements

Used for signed representations.

  1. Diminished radix complement: 1's complement.
    1. The 1's complement of an n bit binary number A is .

    2. What's the bit representation of ? The one's complement of A? A plus its one's complement?

  2. Radix complement: 2's complement.
    1. The 2's complement of an n bit binary number A is .

    2. 1's complement plus one.

      Two's complement of A? A plus its two's complement?

Adding to subtract:

  1. Denote the 2's complement of B as .

    Recall .

  2. .

    Note we should get a carry out of the msb when we perform .

  3. Work the two examples again.



Thomas P. Kelliher
Thu Oct 2 13:55:09 EDT 2003
Tom Kelliher