Skip to content

Instantly share code, notes, and snippets.

@ritog
Created June 13, 2021 07:58
Show Gist options
  • Save ritog/c4e6f5ceb1e7ea2e3ba3601c9de121be to your computer and use it in GitHub Desktop.
Save ritog/c4e6f5ceb1e7ea2e3ba3601c9de121be to your computer and use it in GitHub Desktop.
Creating a custom chip with basic gates (nand2tetris) (Hashnode blog demo)
// Custom.hdl
// this is a part of Hashnode blog Convoluted demo
CHIP Custom {
IN a, b, c;
OUT out;
PARTS:
Not(in=a, out=nota);
Not(in=b, out=notb);
Not(in=c, out=notc);
And(a=nota, b=notb, out=notanotb);
And(a=notanotb, b=notc, out=w1);
And(a=a, b=notb, out=anotb);
And(a=anotb, b=notc, out=w2);
And(a=anotb, b=c, out=w3);
And(a=a, b=b, out=ab);
And(a=ab, b=notc, out=w4);
Or8Way(in[0]=w1, in[1]=w2, in[2]=w3, in[3]=w4, out=out);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment