/1/DMux.hdl

http://github.com/happy4crazy/elements_of_computing_systems · Unknown · 19 lines · 15 code · 4 blank · 0 comment · 0 complexity · 6a374a92bd8c14660d065a3304d22c59 MD5 · raw file

  1. // This file is part of the materials accompanying the book
  2. // "The Elements of Computing Systems" by Nisan and Schocken,
  3. // MIT Press. Book site: www.idc.ac.il/tecs
  4. // File name: projects/01/DMux.hdl
  5. /**
  6. * Demultiplexer. If sel = 0 then {a = in; b = 0} else {a = 0; b = in}
  7. */
  8. CHIP DMux {
  9. IN in, sel;
  10. OUT a, b;
  11. PARTS:
  12. Not(in=sel, out=notsel);
  13. And(a=in, b=notsel, out=a);
  14. And(a=in, b=sel, out=b);
  15. }