Re: FullAdder [ BuiltIn ] Design Type

Posted by rjrotheryjr on
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/FullAdder-BuiltIn-Design-Type-tp4027554p4027561.html

Thank you Yong.

After reviewing Mark's response and the Java source,
you're correct it does not adhere to any specific design.
The java source is the following:

package builtInChips;

import Hack.Gates.BuiltInGate;

/**
 * A FullAdder.
 * s returns the LSB of the sum of the three bits a,b and c.
 * cout returns the carry bit.
 */
public class FullAdder extends BuiltInGate {

    protected void reCompute() {
        short a = inputPins[0].get();
        short b = inputPins[1].get();
        short c = inputPins[2].get();
        short sum = (short)(a + b + c);
        outputPins[0].set((short)(sum % 2));
        outputPins[1].set((short)(sum / 2));
    }
}

Best,
Richard