Implement multi-way gates: Or8Way, Mux4Way16, Mux8Way16, DMux4Way, DMux8Way

This commit is contained in:
2025-08-28 13:19:40 +02:00
parent 93f730d0ce
commit 88b4cc4ad9
5 changed files with 29 additions and 10 deletions

View File

@@ -3,7 +3,7 @@
// by Nisan and Schocken, MIT Press.
// File name: projects/1/Or8Way.hdl
/**
* 8-way Or gate:
* 8-way Or gate:
* out = in[0] Or in[1] Or ... Or in[7]
*/
CHIP Or8Way {
@@ -11,5 +11,12 @@ CHIP Or8Way {
OUT out;
PARTS:
//// Replace this comment with your code.
}
// Chain Or gates to combine all 8 inputs
Or(a=in[0], b=in[1], out=or01);
Or(a=in[2], b=in[3], out=or23);
Or(a=in[4], b=in[5], out=or45);
Or(a=in[6], b=in[7], out=or67);
Or(a=or01, b=or23, out=or0123);
Or(a=or45, b=or67, out=or4567);
Or(a=or0123, b=or4567, out=out);
}