# An N-bit adder built of one-bit adders with simple carry propagation.
class Adder < Blueprint
# This initializes the object, If we already have a one-bit adder
# blueprint lying around, we can reuse it with that second argument.
def initialize(n, bp = nil)
super(n.to_s + "-bit adder")
# Blueprint for a the one-bit adder
bp = OBA.new unless bp
@one_bit_bp = bp
# Make all the adders, and specify them as inputs.
addrs = bp.manyothers(n)
# Create output connectors and chain the carries.
prev = nil
for addr in addrs
c = Connector.new
if prev then
prev = addr