HDLbits
Start Practicing

Verilog Language/Basics

Full Adder

easy
basicsadderassigncombinational

A full adder extends the half adder by also accepting a carry-in bit, making it possible to chain multiple full adders together to build multi-bit adders (see the ripple-carry adder problem in Modules & Hierarchy).

Build a circuit with inputs a, b, and cin, and outputs sum and cout, implementing a full adder.

Interface

Signal Direction Width Description
a input 1 Operand
b input 1 Operand
cin input 1 Carry-in
sum output 1 Sum bit
cout output 1 Carry-out bit

Truth Table

a b cin sum cout
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

Notes

  • sum is the XOR of all three inputs.
  • cout is 1 whenever at least two of the three inputs are 1 (a 3-input majority function).