Carry Chains
Master the CARRY4 primitive — Xilinx's dedicated fast-arithmetic silicon path that implements ripple-carry adders, subtractors, and counters 5× faster than LUT-only logic.
What are Carry Chains?
Binary addition is the most fundamental arithmetic operation in digital logic. When you add two multi-bit numbers, each bit position must account for a carry from the bit below — that carry must propagate from the least-significant bit (LSB) all the way to the most-significant bit (MSB). This is known as ripple-carry propagation.
If you implement a wide adder using only LUTs and general routing fabric, each carry bit has to travel through a LUT output and then through the routing interconnect to reach the next stage. That journey takes approximately 0.5 ns per bit stage. A 32-bit adder would require roughly 16 ns just for carry propagation — completely unacceptable at 500 MHz (2 ns period).
The solution is dedicated carry chain silicon. Xilinx FPGAs include a hardwired path specifically for carry propagation that bypasses general routing entirely. This dedicated path achieves approximately 0.1 ns per carry stage — roughly 5× faster than routing through general fabric. The primitive that implements this fast path is called CARRY4.
CARRY4 Primitive Structure
The CARRY4 primitive has a specific set of inputs and outputs designed exclusively for fast chained arithmetic. Understanding each port is essential for knowing how Vivado synthesizes arithmetic operations and how to debug timing failures in adder paths.
| Port | Direction | Width | Function |
|---|---|---|---|
CI |
Input | 1 | Carry in from the CARRY4 directly below in the same CLB column |
CYINIT |
Input | 1 | Initialize the chain: VCC for subtraction (CI=1), GND for addition (CI=0) |
DI[3:0] |
Input | 4 | Data input from LUT O5 outputs — carry generate signals (A AND B) |
S[3:0] |
Input | 4 | Sum select from LUT O6 outputs — carry propagate signals (A XOR B) |
O[3:0] |
Output | 4 | Sum outputs — XOR of S[i] and carry-in to that stage |
CO[3:0] |
Output | 4 | Carry outputs — CO[3] cascades to next CARRY4's CI via dedicated routing |
The carry mux logic at each stage follows two simple rules:
- S[i] = 0: CO[i] = DI[i] — carry generate/kill mode (carry determined by data, not previous stage)
- S[i] = 1: CO[i] = CI — carry ripple mode (carry passes through from the stage below)
How Fast Arithmetic Works Inside CARRY4
For a 1-bit full adder stage with inputs A[i] and B[i] and carry-in CI:
-
The LUT6 output (O6) computes
S[i] = A[i] XOR B[i]— the "propagate" signal fed into CARRY4 S port -
The LUT5 output (O5) computes
DI[i] = A[i] AND B[i]— the "generate" signal fed into CARRY4 DI port - CARRY4 combines them: if S[i]=1, carry ripples through from below; if S[i]=0, carry is generated from DI[i]
- The final sum bit is
O[i] = S[i] XOR carry_in_to_stage_i
Since a 7-series LUT6 can produce both O5 and O6 simultaneously (using its dual-output feature), each Slice implements 4 bits of full addition using its 4 LUTs and 1 CARRY4 — with no wasted resources. With 4 Slices per CLB column, that is 16 bits per CLB. A 128-bit adder stacks 8 CLBs vertically; the tools handle column placement automatically.
Operations Implemented by CARRY4
Any digital operation that can be reduced to fast carry propagation benefits from the CARRY4 chain. The following table lists the most common operations the synthesizer maps to CARRY4:
| Operation | How CARRY4 is Used | Verilog Operator |
|---|---|---|
| Adder | Direct ripple-carry chain with CYINIT=GND | sum = a + b; |
| Subtractor | Two's complement: invert B bits, CYINIT=VCC (carry-in=1) | diff = a - b; |
| Accumulator | Adder with registered feedback; carry chain per clock cycle | acc <= acc + data; |
| Comparator | Subtraction result — sign bit gives greater/less-than | gt = (a > b); |
| Counter | Increment via carry chain — very efficient for wide counters | cnt <= cnt + 1; |
| Incrementer | CARRY4 with one input tied to 0, carry-in = 1 | out = in + 1; |
| Shift-and-add multiplier | Partial sum accumulation uses carry chain per partial product | prod = a * b; (small widths) |
Cascading Carry Chains for Wide Adders
Wide adders require multiple CARRY4 primitives chained in series within the same CLB column. The cascade mechanism is straightforward: CO[3] of one CARRY4 connects to CI of the next via a dedicated carry routing wire that never touches general fabric.
- CYINIT = GND: carry-in to bit 0 is 0 — standard addition
- CYINIT = VCC: carry-in to bit 0 is 1 — used in two's complement subtraction (invert B + carry-in of 1)
- CO[3] of each CARRY4 connects to CI of the one above — dedicated carry wire, ~0.01 ns crossing delay
- Vivado P&R places all cascaded CARRY4s in the same column automatically — no Pblock needed
Synthesis Inference — Let Vivado Do the Work
In virtually all practical designs, you do not need to instantiate CARRY4 manually. Vivado's synthesis engine recognizes arithmetic operators and maps them to CARRY4 chains automatically. The following code shows both approaches — inferred (recommended) and manual instantiation (advanced only):
After synthesis, open the Vivado Synthesis Report and search for
CARRY4
in the resource utilization section. For a 16-bit adder you will see exactly 4
CARRY4 instances. For a 32-bit adder, 8 instances.
Performance Comparison: Carry Chain vs LUT-Only Adder
The following table compares timing for CARRY4-based adders versus LUT-only implementations at worst-case process/voltage/temperature corner for Xilinx 7-series:
| Adder Width | CARRY4 Chain Delay | LUT-Only Delay | Speed Improvement | CARRY4 Count |
|---|---|---|---|---|
| 8-bit | ~0.8 ns | ~4 ns | 5× | 2 |
| 16-bit | ~1.6 ns | ~8 ns | 5× | 4 |
| 32-bit | ~3.2 ns | ~16 ns (LUT tree) | 5× | 8 |
| 64-bit | ~6.4 ns | ~25 ns | ~4× | 16 |
| 128-bit | ~12.8 ns | ~45 ns | ~3.5× | 32 |
A: 8 CARRY4 primitives. Each CARRY4 handles 4 bits of carry propagation, so 32 ÷ 4 = 8 CARRY4s. Vivado places all 8 in the same CLB column automatically — they span 8 Slices across 2 CLBs (4 Slices per CLB). The total carry propagation delay is approximately 8 × 0.1 ns = 0.8 ns, plus LUT and flip-flop delays.
Knowledge Check
1. How many full-adder stages does one CARRY4 primitive implement?
- A 1 stage
- B 2 stages
- C 4 stages
- D 8 stages
2. Which signal propagates carry between adjacent CARRY4 primitives in a cascade?
- A CO[0] to CYINIT of next CARRY4
- B CO[3] to CI of next CARRY4
- C O[3] to DI[0] of next CARRY4
- D S[3] to CI of next CARRY4
3. CARRY4 dedicated carry paths are faster than general routing carry propagation by approximately how much?
- A 2×
- B 10×
- C 5×
- D 20×
4. Which Verilog operator causes Vivado to automatically infer a CARRY4 chain during synthesis?
- A & (bitwise AND)
- B + (addition operator)
- C ^ (XOR operator)
- D >> (right shift)
5. In CARRY4, what does setting CYINIT = VCC accomplish?
- A Resets the carry chain to zero
- B Disables the carry chain output
- C Initializes the carry chain with carry-in = logic 1 (used for subtraction)
- D Routes carry through general fabric instead of dedicated path
6. How many CARRY4 primitives are required to build a 64-bit adder?
- A 8
- B 64
- C 16
- D 32
Practical Exercise
fast_adder with two 16-bit inputs
(a, b) and a 17-bit output (sum) where bit 16
captures the carry-out (overflow indicator). Use a simple
assign sum = {1'b0,a} + {1'b0,b}; statement. Synthesize in Vivado targeting any Artix-7, Kintex-7, or UltraScale device. After synthesis completes: (1) open the Synthesis Report and search for "CARRY4" in the resource utilization table — verify you see exactly 4 instances; (2) open the implemented design schematic and trace the CARRY4 cascade from bottom to top of the column; (3) right-click any CARRY4 and select "Highlight Fanout" to visualize the chain; (4) run
report_timing -max_paths 5 -path_type full and identify
whether the critical path slack is dominated by carry chain delay or by the
surrounding LUT/FF delays.
Summary
- The CARRY4 primitive provides 4 dedicated carry stages per Slice at ~0.1 ns per stage — 5× faster than general routing (~0.5 ns/stage)
- Ports: CI (carry in), CYINIT (chain init via VCC/GND), DI[3:0] (generate from LUT O5), S[3:0] (propagate from LUT O6), CO[3:0] (carry out), O[3:0] (sum out)
- CO[3] cascades to the next CARRY4's CI via a dedicated carry wire — no general routing involved
-
Vivado automatically infers CARRY4 chains from Verilog
+and-operators — manual instantiation is rarely necessary - Supported operations include: adders, subtractors, accumulators, comparators, counters, incrementers, and shift-and-add multipliers
- A 32-bit adder uses 8 CARRY4s; a 64-bit adder uses 16 — all placed in the same CLB column by Vivado automatically
- Check the synthesis report for CARRY4 instance counts to verify correct inference after synthesis