Back Source Testbench

package work.Generic_Adder

This package provides generic binary adders.

The rest of the package contains implementation details of the CSAdd and CIAdd procedures. It is subject to change, and therefore currently undocumented. Please refer to the source code for details.

Building other adder-based circuits

In order to build a subtractor, you can exploit one of the formulae:

  A - B = A + ¬B + 1
  A - B = ¬(¬A + B)

An incrementer or decrementer is better built using functions from package work.Bit_Manipulation:

  function incr (A : in std_ulogic_vector) return std_ulogic_vector is
  begin
    return A xor lshift(cascade_and(A), 1, '1');
  end incr;

  function decr (A : in std_ulogic_vector) return std_ulogic_vector is
  begin
    return not incr(not A);
  end decr;

A negation can be done with Y := incr(not A);.

Wallace trees and other tree adders use rows of full adders. There is no procedure that implements a full adder, but its components are available: package work.Misc provides the xor3 and maj23 functions that calculate the Y and carry outputs, respectively.


Copyright (C) 2002, 2003 Michael Riepe