Files
eceg431/01/Or8Way.hdl

25 lines
664 B
Plaintext

// 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/1/Or8Way.hdl
/**
* 8-way Or gate:
* out = in[0] Or in[1] Or ... Or in[7]
*/
CHIP Or8Way {
IN in[8];
OUT out;
PARTS:
// combine pairs
Or(a=in[0], b=in[1], out=pair0);
Or(a=in[2], b=in[3], out=pair1);
Or(a=in[4], b=in[5], out=pair2);
Or(a=in[6], b=in[7], out=pair3);
// combine groups of pairs
Or(a=pair0, b=pair1, out=lowGroup);
Or(a=pair2, b=pair3, out=highGroup);
// combine both groups
Or(a=lowGroup, b=highGroup, out=out);
}