/1/Mux.hdl
http://github.com/happy4crazy/elements_of_computing_systems · Unknown · 21 lines · 17 code · 4 blank · 0 comment · 0 complexity · f940861c89c82bf752303eaa0ecf934a MD5 · raw file
- // This file is part of the materials accompanying the book
- // "The Elements of Computing Systems" by Nisan and Schocken,
- // MIT Press. Book site: www.idc.ac.il/tecs
- // File name: projects/01/Mux.hdl
-
- /**
- * Multiplexor. If sel=0 then out = a else out = b.
- * In other words, mux(a,b,s) = a!s + bs
- */
-
- CHIP Mux {
-
- IN a, b, sel;
- OUT out;
-
- PARTS:
- Not(in=sel,out=notsel);
- And(a=a, b=notsel, out=left);
- And(a=b, b=sel, out=right);
- Or(a=left, b=right, out=out);
- }