// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/2/Add16.hdl
/**
 * 16-bit adder: Adds two 16-bit two's complement values.
 * The most significant carry bit is ignored.
 */
CHIP Add16 {
    IN a[16], b[16];
    OUT out[16];

    PARTS:

    HalfAdder(a=a[0] , b=b[0] , sum=out[0] , carry=ab0carry);

    FullAdder(a=a[1] , b=b[1] , c=ab0carry , sum=out[1], carry=abc1cary);
    FullAdder(a=a[2] , b=b[2] , c=abc1cary , sum=out[2], carry=abc2cary);
    FullAdder(a=a[3] , b=b[3] , c=abc2cary , sum=out[3], carry=abc3cary);
    FullAdder(a=a[4] , b=b[4] , c=abc3cary , sum=out[4], carry=abc4cary);
    FullAdder(a=a[5] , b=b[5] , c=abc4cary , sum=out[5], carry=abc5cary);
    FullAdder(a=a[6] , b=b[6] , c=abc5cary , sum=out[6], carry=abc6cary);
    FullAdder(a=a[7] , b=b[7] , c=abc6cary , sum=out[7], carry=abc7cary);
    FullAdder(a=a[8] , b=b[8] , c=abc7cary , sum=out[8], carry=abc8cary);
    FullAdder(a=a[9] , b=b[9] , c=abc8cary , sum=out[9], carry=abc9cary);
    FullAdder(a=a[10] , b=b[10] , c=abc9cary , sum=out[10], carry=abc10cary);
    FullAdder(a=a[11] , b=b[11] , c=abc10cary , sum=out[11], carry=abc11carry);
    FullAdder(a=a[12] , b=b[12] , c=abc11carry , sum=out[12], carry=abc12cary);
    FullAdder(a=a[13] , b=b[13] , c=abc12cary , sum=out[13], carry=abc13cary);
    FullAdder(a=a[14] , b=b[14] , c=abc13cary , sum=out[14], carry=abc14cary);
    FullAdder(a=a[15] , b=b[15] , c=abc14cary , sum=out[15], carry=abc15cary);

    

}