From b3af552bfd752945f352c14b94a20547d1281c45 Mon Sep 17 00:00:00 2001 From: Konarak Date: Sun, 5 Dec 2021 09:33:35 +0530 Subject: [PATCH] add nor, xnor chips --- projects/custom/Nor.hdl | 22 ++++++++++++++++++++++ projects/custom/Xnor.hdl | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 projects/custom/Nor.hdl create mode 100644 projects/custom/Xnor.hdl diff --git a/projects/custom/Nor.hdl b/projects/custom/Nor.hdl new file mode 100644 index 0000000..7abed00 --- /dev/null +++ b/projects/custom/Nor.hdl @@ -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); +} diff --git a/projects/custom/Xnor.hdl b/projects/custom/Xnor.hdl new file mode 100644 index 0000000..e0a2ff5 --- /dev/null +++ b/projects/custom/Xnor.hdl @@ -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); +}