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)

With CSAdd and a mux, you can also calculate abs(A - B) with little overhead:

  CSAdd(not A, B, Y, Z, G, P);
  if G = '1' then -- actually, this means A < B
    -- ¬A + B + 1 = B - A
    Result := Z;
  else
    -- ¬(¬A + B) = A - B
    Result := not Y;
  end if;

An incrementer or decrementer is better built using other functions. See package work.Bit_Manipulation.

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 © 2002 - 2004 Michael Riepe