Half Adder Chip

Abstraction and Implementation of Half Adder Chip in Hardware Design Language and Java™.

Adder Chip

The chip used to add two n-bit numbers is known as Adder, also known as n-bit Adder.

Half Adder Chip

Half Adder chip is used to add 2-bits.

Chip name: HalfAdder
Inputs: a, b
Outputs: sum, carry
Function: sum = LSB of a + b
          carry = MSB of a + b

Implementation of Half Adder Chip in HDL

The function in the above abstraction can help in the implementation of Half Adder Chip.

sum = a XOR b

carry = a AND b

CHIP HalfAdder {
    IN a, b;    // 1-bit inputs
    OUT sum,    // Right bit of a + b 
        carry;  // Left bit of a + b

    PARTS:
    Xor(a=a, b=b, out=sum);
    And(a=a, b=b, out=carry);
}

Implementation of Half Adder Chip in Java™

Similar to the Implementation in HDL

package CombChips;

class HalfAdder_Gate extends Xor_Gate {

    protected static int[] HalfAdder(int a, int b) {
        int[] out = new int[2];

        // sum
        out[0] = Xor(a, b);

        // carry
        out[1] = And_Gate.And(a, b);

        return out;
    }
}

Last updated