/1/Or.hdl

http://github.com/happy4crazy/elements_of_computing_systems · Unknown · 28 lines · 22 code · 6 blank · 0 comment · 0 complexity · e8981e1f6d23e0c0a7ca8a7a281bf18e 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/Or.hdl
  5. /**
  6. * Or gate. out = a or b
  7. */
  8. /**
  9. * x + y = not( not(x) not(y))
  10. */
  11. CHIP Or {
  12. IN a, b;
  13. OUT out;
  14. PARTS:
  15. // Nand(a=a, b=a, out=left);
  16. // Nand(a=b, b=b, out=right);
  17. // Nand(a=left, b=right, out=out);
  18. Not(in=a, out=nota);
  19. Not(in=b, out=notb);
  20. And(a=nota, b=notb, out=neitheranorb);
  21. Not(in=neitheranorb, out=out);
  22. }