🌱Aadam's Garden

Search

Search IconIcon to open search

Full Adder

Last updated Jun 23, 2022

# Full Adder

  • A circuit that adds three bits (a carry into the sum and the two bits we want to add) and outputs a carry and a bit of sum is called a full adder.
  • Carry out is $1$ when $A$ and $B$ are both $1$, or when $C_{in} = 1$ and $A \oplus B = 1.$: $$C_{out} = AB + C_{in}(A \oplus B)$$
  • The sum $S$ is 1 whenever one of the inputs $A, B$, or $C_{in}$ are $1$, or when all three of them are $1$. This is equivalent to the XOR of all three bits: $$S = A \oplus B \oplus C.$$
  • The logic circuit is: 📝 wongIntroductionClassicalQuantum_2022-01-18 18.35.36.excalidraw 1.png
  • Code in Verilog:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module halfadd(C,S,A,B); 
	input A, B; 
	output C, S; 
	
	xor xor1(S,A,B); 
	and and1(C,A,B); 
endmodule 

module fulladd(Cout,S,A,B,Cin); 
	input A, B, Cin; 
	output Cout, S; 
	wire w1, w2, w3; 

	halfadd half1(w1,w2,A,B); 
	halfadd half2(w3,S,w2,Cin); 
	or or1(Cout,w1,w3); 
endmodule 

module main; 
	reg A,B,Cin; 
	wire Cout,S; 
	
	fulladd full1(Cout,S,A,B,Cin); 
	
	initial begin 
		A=0; 
		B=1; 
		Cin=1; 
		#5; // Wait 5 time units. 
		$display("Carry = ",Cout); 
		$display("Sum = ",S); 
	end
endmodule

# Sources

# Uses

It used in Ripple-carry adder to perform binary addition.