|
IMPLEMENTING
AN ADDER IN AN FPGA
by Ingo
Cyliax
Start ý Implementing
ý Adder Architecture ý Lessons
Learned ý Sources and PDF
Designing with FPGAs is a lot like designing
with other digital components. You have some idea of what functions
you would like to implement in your design, and the FPGA provides
the basic building blocks to implement these. As you recall, FPGAs
are made up of an array of logic blocks wired together with routing
resources. Except for some functions, the routing facilities are only
used to connect the blocks. This month, Iým going to show you some
examples of how familiar structures are implemented in FPGA logic
blocks.
One of the most common digital functional
blocks is the adder, which is used in counters and arithmetic functions.
The adder is a structure that is difficult to implement efficiently.
The truth table for a full adder, an adder that has a carry input
and carry output, is shown in Table 1. Youýll need the CIN
and COUT signals to cascade adders to implement adders
for larger word sizes.
| Inputs |
Outputs |
|
A
0
0
1
1
0
0
1
1
|
B
0
1
0
1
0
1
0
1
|
CIN
0
0
0
0
1
1
1
1
|
Sum
0
1
1
0
1
0
0
1
|
COUT
0
0
0
1
0
1
1
1
|
| Table 1ýHere is
the truth table for a full adder. A full adder is an adder that
takes the two operands (A and B) and a carry input, and produces
both the sum and a carry output. |
A simple 1-bit full adder can be constructed
with the following functions:
Sum = A XOR B XOR CIN
COUT = (A ý B) + (A ý CIN)
+ (B ý CIN)
 |
| Figure 1ýThe logic to implement
a native full adder. It takes the carry input, adds it with the
two operands (A and B), and generates the outputýs sum and carry
out. |
To build a 16-bit adder, you simply chain
16 adders together (see Figure 1) by wiring the COUT to
the CIN of the next stage (see Figure 2). This particular
design also has input and output registers to hold values.
|

(click
here for figure)
|
Figure 2ýTo build a 16-bit adder,
all you need to do is chain all 16 single-bit adders together.
This is called a ripple carry adder because the carry ripples
through all the stages. |
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |