Implement basic logic gates: Not, And, Or, Xor, Mux, DMux

This commit is contained in:
2025-08-27 19:07:20 +02:00
parent beb668806a
commit ad5f774ae0
6 changed files with 32 additions and 13 deletions

View File

@@ -2,7 +2,7 @@
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/1/Mux.hdl
/**
/**
* Multiplexor:
* if (sel = 0) out = a, else out = b
*/
@@ -11,5 +11,9 @@ CHIP Mux {
OUT out;
PARTS:
//// Replace this comment with your code.
}
// Mux(a,b,sel) = Or(And(a, Not(sel)), And(b, sel))
Not(in=sel, out=notSel);
And(a=a, b=notSel, out=aAndNotSel);
And(a=b, b=sel, out=bAndSel);
Or(a=aAndNotSel, b=bAndSel, out=out);
}