/2/FullAdder.hdl
http://github.com/happy4crazy/elements_of_computing_systems · Unknown · 26 lines · 21 code · 5 blank · 0 comment · 0 complexity · 9e346ac1fb5bbaf306787ea583cd3688 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/FullAdder.hdl
-
- /**
- * Full adder. Computes sum, the least significant bit of
- * a + b + c, and carry, the most significant bit of a + b + c.
- *
- * The LSB of a + b +c = LSB(a + b) + c
- * The MSB of a + b + c = MSB(a + b), MSB can never be more than 1
- * given that max sum is 1 + 1 + 1 = 11
- */
-
- CHIP FullAdder {
-
- IN a, b, c;
- OUT sum, // LSB of a + b + c
- carry; // MSB of a + b + c
-
- PARTS:
- HalfAdder(a=a, b=b, sum=absum, carry=abcarry);
- HalfAdder(a=absum, b=c, sum=sum, carry=abccarry);
- Xor(a=abcarry, b=abccarry, out=carry);
- }