/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
- // 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/02/HalfAdder.hdl
-
- /**
- * Half adder. Computes sum, the least significnat bit of a + b,
- * and carry, the most significnat bit of a + b.
- */
-
- CHIP HalfAdder {
-
- IN a, b;
- OUT sum, // LSB of a + b
- carry; // MSB of a + b
-
- PARTS:
- Xor(a=a, b=b, out=sum);
- And(a=a, b=b, out=carry);
- }