Skip to content

Instantly share code, notes, and snippets.

@tansaku
Created February 2, 2014 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tansaku/8764639 to your computer and use it in GitHub Desktop.
Save tansaku/8764639 to your computer and use it in GitHub Desktop.
// 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/02/Adder16.hdl
/*
* Adds two 16-bit values.
* The most-significant carry bit is ignored.
*/
CHIP CheckZero16 {
IN in[16];
OUT zero,nonzero;
PARTS:
// Put you code here:
Or(a=in[0],b=in[1],out=x);
Or(a=in[2],b=in[3],out=y);
Or(a=in[4],b=in[5],out=z);
Or(a=in[6],b=in[7],out=u);
Or(a=in[8],b=in[9],out=i);
Or(a=in[10],b=in[11],out=j);
Or(a=in[12],b=in[13],out=k);
Or(a=in[14],b=in[15],out=l);
Or(a=x,b=y,out=f);
Or(a=z,b=u,out=g);
Or(a=f,b=g,out=h);
Or(a=i,b=j,out=m);
Or(a=k,b=l,out=n);
Or(a=m,b=n,out=o);
Or(a=h,b=o,out=p);
Or(a=p,b=false,out=nonzero);
Not(in=p,out=zero);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment