HalfAdder

Xor(a=a,b=b,out=sum);
And(a=a,b=b,out=carry);

FullAdder

HalfAdder(a=a,b=b,sum=s,carry=c1);
HalfAdder(a=s,b=c,sum=sum,carry=c2);
Or(a=c1,b=c2,out=carry);

Add16

FullAdder(a=a[0],b=b[0], sum=out[0], carry=c0);
FullAdder(a=a[1],b=b[1],c=c0, sum=out[1], carry=c1);
// ...
FullAdder(a=a[15],b=b[15],c=c14, sum=out[15], carry=c15);

Inc16

Add16(a=in,b[0]=true,out=out);

Or16Way

Or8Way(in=in[0..7],out=or1);
Or8Way(in=in[8..15],out=or2);
Or(a=or1,b=or2,out=out);

ALU

// x
Mux16(a=x,b=false,sel=zx, out=x1);
Not16(in=x1,out=xnot);
Mux16(a=x1,b=xnot,sel=nx, out=x2);

// y
Mux16(a=y,b=false,sel=zy, out=y1);
Not16(in=y1,out=ynot);
Mux16(a=y1,b=ynot,sel=ny, out=y2);

// f
Add16(a=x2,b=y2, out=xplusy);
And16(a=x2,b=y2, out=xandy);
Mux16(a=xandy, b=xplusy, sel=f, out=outbeforeno);

// no
Not16(in=outbeforeno, out=outbeforenonot);

// out
Mux16(a=outbeforeno, b=outbeforenonot, sel=no, out=out, out=out1);

// zr
Or16Way(in=out1,out=out1OR);
Not(in=out1OR, out=zr);

// ng
And16(a=true,b=out1, out[15]=highbit);
And(a=true, b=highbit, out=ng);