mirror of
https://github.com/soconnor0919/eceg431.git
synced 2025-12-11 22:54:43 -05:00
Implement basic logic gates: Not, And, Or, Xor, Mux, DMux
This commit is contained in:
10
01/Mux.hdl
10
01/Mux.hdl
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user