/2/HalfAdder.hdl

http://github.com/happy4crazy/elements_of_computing_systems · Unknown · 20 lines · 16 code · 4 blank · 0 comment · 0 complexity · 33d322f07d60d5fe889c47ee7bb892c8 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/02/HalfAdder.hdl
  5. /**
  6. * Half adder. Computes sum, the least significnat bit of a + b,
  7. * and carry, the most significnat bit of a + b.
  8. */
  9. CHIP HalfAdder {
  10. IN a, b;
  11. OUT sum, // LSB of a + b
  12. carry; // MSB of a + b
  13. PARTS:
  14. Xor(a=a, b=b, out=sum);
  15. And(a=a, b=b, out=carry);
  16. }