// Import the base libraries for JHDL design
import byucc.jhdl.base.*;
import byucc.jhdl.Logic.*;

// Our FullAdder is a Java class.  Begin the class declaration here
public class FullAdder extends Logic {

  // This is cell's interface (ports)
  public static CellInterface[] cell_interface = {
    in("a", 1),
    in("b", 1),
    in("cin", 1),
    out("sum", 1),
    out("cout", 1)
  };

  // This is the constructor - it gets called when a new FullAdder is desired
  public FullAdder(Node parent, Wire a, Wire b, 
                   Wire cin, Wire sum, Wire cout) {
    
    // Since we extend Logic, always have to call its constructor as the first thing
    super(parent);


    // Connect the wires passed in as parameters to the constructor to
    // the ports from the CellInterface above. 
    connect("a", a);
    connect("b", b);
    connect("cin", cin);
    connect("sum", sum);
    connect("cout", cout);

    // Build our logic as a collection of gates.
    or_o( and(a,b), and(a,cin), and(b,cin), cout ); /* cout is output */
    xor_o( a, b, cin, sum );                        /* sum is output */

  }
}


