Optimizing FPGA Adder Trees with GPC and LUT Mapping
Large-scale integer addition is a staple in digital signal processing (DSP) and video processing. However, these operations often incur significant resource overhead. To improve performance, we must align the adder tree structure with the physical architecture of the FPGA—specifically the Look-Up Table (LUT) characteristics—to reduce resource consumption and improve timing. This analysis explores how to leverage Altera’s LUT structure to design compressor trees that maximize logic utilization.
🏗️ Compressor Tree Fundamentals #
The foundation of any compressor tree lies in the half-adder and full-adder. A half-adder takes two input bits to produce a sum (S) and a carry (C). A full-adder handles three bits, including a carry-in, to produce a sum and a carry-out.
Compressor trees are built by connecting the S and C outputs of full adders into a multi-layer tree structure. Compared to standard carry-save trees, which use two or three adder modules to reduce the number of addends, compressor trees are more efficient. They reduce the number of addends before the final sum is calculated by a carry-propagation adder.
🔢 Generalized Parallel Counters (GPC) #
A compressor tree is essentially the logic above the carry-propagation adder. Its goal is to reduce the number of addends to a manageable amount that can be handled by a final carry chain.
We can represent a Generalized Parallel Counter (GPC) as a tuple $(K_i, \dots; M)$, where $K_i$ represents the number of bits at a specific position in the input addends. For example, a tuple $(1, 4, 1, 5; 5)$ describes a specific bit distribution.
The constraint $M$ is dictated by the FPGA’s LUT structure. In Altera Stratix devices, for instance, the LUTs are 6-input. To optimize resource usage, the GPC must adapt to these input limits. Two primary constraints apply:
- The number of bits in any column must not exceed $M$.
- The maximum data range must be achievable.
Consider the implementation of $(1, 4, 1, 5; 5)$. The delay includes one full-adder (FA) delay and the delay of four carry chains. Because FPGAs provide high-speed carry chains, GPCs are highly suitable for this architecture. Using GPCs effectively can reduce the number of levels in an adder tree. For example, calculating a three-row sum using a Wallace tree might require two levels of circuitry (two full adders followed by a carry-propagation adder). In contrast, a $(3, 3; 4)$ GPC can achieve this in a single level.
🛠️ Hardware-Aware Mapping Algorithms #
To maximize LUT utilization and minimize the logic footprint, we define a GPC selection algorithm based on the Altera LUT structure.
In Stratix devices, the Adaptive Logic Module (ALM) contains two 6-LUTs that share inputs. This allows an ALM to perform a 6-to-2 function. If we map a 6-input/3-output GPC to a LUT, the utilization is only 75%. However, a 6-input/4-output mapping achieves 100% utilization. Mapping two 6-input/3-output GPCs to two ALMs is often impossible because the shared inputs prevent proper synthesis.
Definitions and Logic #
- Primitive GPC: The set of all GPCs that satisfy the $M$ and $n$ constraints.
- Covering GPC: A GPC whose implementation is unique and cannot be replaced by another GPC. For example, $(2, 2; 3)$ is not a covering GPC because $(2, 3; 3)$ can also implement it by setting one bit to zero.
- Compressor Ratio: The ratio of input bits to output bits. For $(2, 3; 3)$, the ratio is $5/3 \approx 1.66$.
The Optimization Algorithm #
The algorithm follows these steps to build the compressor tree:
- Generate the set of covering GPCs based on $M$ and $n$.
- Generate a set of primitive GPCs to construct the tree, which will later be replaced by their corresponding covering GPCs.
- Calculate the compressor ratio for each primitive GPC and classify them.
- Select the column with the most bits as the baseline. Perform a forward and backward search to find the highest compressor ratio for the next GPC mapping. Repeat until all columns are searched.
- Repeat the process for the newly generated bits.
- When the remaining bits in a row or column are fewer than $k$, the iteration ends. Any bits not assigned a GPC are passed to the final carry-propagation adder.
In high-performance embedded systems where real-time processing is mandatory, optimizing these hardware primitives is essential. For more on real-time operating systems in such environments, see VxWorks.
📊 Performance Analysis #
The effectiveness of the GPC approach was compared against two other adder implementations:
- ADD: A standard adder tree built using 3-input adders as the basic structure.
- 3GD: A carry-save adder structure that does not utilize the ALM’s internal carry chains.
The results show that the GPC approach yields lower latency than both ADD and 3GD. While the resource usage of GPC is similar to the ADD method, it is significantly lower than the 3GD method. This is primarily because both ADD and GPC leverage the high-speed internal carry chains of the FPGA.