add nor, xnor chips

This commit is contained in:
Konarak 2021-12-05 09:33:35 +05:30
parent 7ae97dea41
commit b3af552bfd
2 changed files with 45 additions and 0 deletions

22
projects/custom/Nor.hdl Normal file
View File

@ -0,0 +1,22 @@
// 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/custom/Nor.hdl
/**
* Nor gate:
* out = 1 if (a == 0 or b == 0)
* 0 otherwise
*/
CHIP Nor {
IN a, b;
OUT out;
PARTS:
// Put your code here:
Nand(a=a, b=a, out=outx);
Nand(a=b, b=b, out=outy);
Nand(a=outx, b=outy, out=outz);
Nand(a=outz, b=outz, out=out);
}

23
projects/custom/Xnor.hdl Normal file
View File

@ -0,0 +1,23 @@
// 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/custom/Xnor.hdl
/**
* Or gate:
* out = (a == b)
* 0 otherwise
*/
CHIP Xnor {
IN a, b;
OUT out;
PARTS:
// Put your code here:
Nand(a=a, b=b, out=outw);
Nand(a=a, b=outw, out=outx);
Nand(a=b, b=outw, out=outy);
Nand(a=outx, b=outy, out=outz);
Nand(a=outz, b=outz, out=out);
}