Full adder is a combinational circuit which computer binary addition of three binary inputs. The truth table of full adder is given below.

## Input a |
## Input b |
## Input cin |
## Output sum |
## Output carry |

0 |
0 |
0 |
0 |
0 |

0 |
0 |
1 |
1 |
0 |

0 |
1 |
0 |
1 |
0 |

0 |
1 |
1 |
0 |
1 |

1 |
0 |
0 |
1 |
0 |

1 |
0 |
1 |
0 |
1 |

1 |
1 |
0 |
0 |
1 |

1 |
1 |
1 |
1 |
1 |

We can write boolean expression for full adder as follows $$sum = a\oplus b \oplus cin$$ $$carry = a.b + b.cin + cin.a$$

If you see above equation, we require two ex-or gate, three AND gate and one three input OR gate. We can minimise the logic gate requirement by modifying the boolean expression as follows. $$carry = ab + (a \oplus b)cin$$

Now we require only two AND gate and one OR gate in carry expression because a ex-or b is already computed from sum expression. Now the logic gate required for implementing full adder is reduced.

If you observe above boolean expression and logic ccircuit diagram, it is basically two half adder and one OR gate. $$\text{For a half adder, } sum = a \oplus b \text { and } carry = a.b$$ Hence, we can implement full adder using two half adder with addition of one OR gate.

First, we'll describe a half adder by creating a module half_adder in Verilog source file. Below is the Verilog code for half adder.

```
//Half adder using data flow modeling
module half_adder (
input a,b,
output sum,carry
);
assign sum = a ^ b;
assign carry = a & b;
endmodule
```

Now create another seperate module for full adder. The module neme is full_adder and input output port list is same as full adder module. Instantiate two half adder with instance name ha0 and ha1. Make connection between the top module and half_adder module. The verilog code for full adder using half adder is given below.

```
//Full adder using half adder
module full_adder(
input a,b,cin,
output sum,carry
);
wire c,c1,s;
half_adder ha0(a,b,s,c);
half_adder ha1(cin,s,sum,c1);
assign carry = c | c1 ;
endmodule
```

```
module full_adder_tb;
reg a,b,cin;
wire sum,carry;
full_adder uut(a,b,cin,sum,carry);
initial begin
a = 0; b = 0; cin = 0;
#10
a = 0; b = 0; cin = 1;
#10
a = 0; b = 1; cin = 0;
#10
a = 0; b = 1; cin = 1;
#10
a = 1; b = 0; cin = 0;
#10
a = 1; b = 0; cin = 1;
#10
a = 1; b = 1; cin = 0;
#10
a = 1; b = 1; cin = 1;
#10
$finish();
end
endmodule
```

Privacy Policy

This policy contains information about your privacy. By posting, you are declaring that you understand this policy:

- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)

- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.

- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.

This policy is subject to change at any time and without notice.

Terms and Conditions

These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:

- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.

Failure to comply with these rules may result in being banned from submitting further comments.

These terms and conditions are subject to change at any time and without notice.

## Comments