This is a halfadder logical circuit This circuit performs a
This is a half-adder logical circuit: This circuit performs a very basic version of binary addition. It has two input bits, A and B, and two output bits S (Sum) and C (Carry). S is A XOR B. C is A AND B. Write a function with two boolean inputs and two boolean outputs, S and C, that recreates the half-adder. Solution
Solution
First gate is XOR gate , for which we know that if both input are same then output is 0 else output is 1.
And second gate is normal AND gate
function [S,C] = halfAdd(A, B)
if(A == B)
S = 0;
if(A == 1)
C = 1
end
else
S = 1;
C = 0;
end
end
