Algorithm Search⌘K

Techniquecore

Common-centroid layout

Also called common-centroid placement, interdigitation.

Splits matched devices into unit cells arranged so that each device has the same centroid, cancelling linear process gradients in analog circuits.

Common-centroid layout is a layout technique for matched devices: each device is split into equal unit cells, and the cells are placed so that the centroid (the mean position) of every device is the same point. Its topic is analog sizing and layout, one of the five topics of this sub-area. If a process parameter changes linearly across the die, the mean value over each device is then the same, so a linear gradient adds no mismatch, exactly. A quadratic change still leaves a mismatch, and this page gives its exact size.

In plain words

Two capacitors on a chip must be equal. The oxide is a bit thicker on the left side of the die than on the right. If one capacitor sits on the left and one on the right, they differ.

Cut each capacitor into equal small pieces and wire the pieces of each one in parallel. Now arrange the pieces so that each capacitor has its pieces spread around the same middle point, for example in the order A, B, B, A. The extra thickness that one piece of A gets on the left, the other piece of A loses on the right. B gets the same average. The two capacitors stay equal for any steady change from one side to the other.

The trick does not remove a change that curves, and it does nothing against the random differences between pieces.

When it applies

  • Two or more devices must match in a ratio: the transistors of a differential pair or a current mirror, the capacitors of a switched-capacitor filter or a DAC, the resistors of a divider.
  • Each device can be built from identical unit cells in parallel (or in series), so its value is the sum of the unit values, and the ratio of two devices is the ratio of their mean unit values.
  • The process parameter (oxide thickness, sheet resistance, threshold voltage, temperature) changes smoothly over the area of the array, so a low-order Taylor series describes it.
  • The units can share one orientation and one environment, so that only the gradient differs from cell to cell.

The template

Model a parameter field p(x,y)p(x, y) over the array. A device DD has kDk_D unit cells with centers r1,…,rkDr_1, \ldots, r_{k_D}. Its parameter is the mean of the unit values,

PD=1kD∑i=1kDp(ri).P_D = \frac{1}{k_D} \sum_{i=1}^{k_D} p(r_i).

This is exact for a quantity that adds, such as a capacitance or a current at a fixed drive, and it holds to first order for the threshold voltage of parallel transistors. The centroid of DD is cD=1kD∑iric_D = \frac{1}{k_D} \sum_i r_i.

  1. Choose the unit cell, and the number of units of each device from the ratio.
  2. Choose an array of RR rows and CC columns, with RCR C equal to the total number of units (add dummy cells if needed).
  3. Pair each cell with its point reflection through the center of the array, and give both cells of each pair to the same device. A device with an odd number of units takes the center cell.
  4. Among such patterns, spread the devices so that their second moments are as close as possible (the dispersion rule).
  5. Surround the array with dummy cells, so that every unit has the same neighbors, and route each device symmetrically.

Theorem 1 (linear gradients cancel exactly). Let p(r)=p0+g⋅rp(r) = p_0 + g \cdot r for a constant vector gg. Then PD=p0+g⋅cDP_D = p_0 + g \cdot c_D. So PA=PBP_A = P_B for every gg if and only if cA=cBc_A = c_B.

Proof. By linearity of the mean, PD=1kD∑i(p0+g⋅ri)=p0+g⋅cDP_D = \frac{1}{k_D} \sum_i (p_0 + g \cdot r_i) = p_0 + g \cdot c_D. If cA=cBc_A = c_B, then PA−PB=g⋅(cA−cB)=0P_A - P_B = g \cdot (c_A - c_B) = 0. If cA≠cBc_A \neq c_B, the gradient g=cA−cBg = c_A - c_B gives PA−PB=∣cA−cB∣2>0P_A - P_B = |c_A - c_B|^2 > 0. □\square

Lemma (step 3 works). If the cells of DD are a union of point-reflection pairs about the center cc, plus possibly the center cell itself, then cD=cc_D = c. Each pair {r,2c−r}\{r, 2c - r\} has the mean cc, and the center cell is cc, so the mean over all cells is cc. □\square

When step 3 is possible. Pairs exist for every cell except the center cell, which exists only when RR and CC are both odd. So point-symmetric patterns exist exactly when every count is even, or when RR and CC are odd and exactly one count is odd. An odd count with an even RR cannot have the common centroid in any pattern, symmetric or not: the yy values of the cell centers are 12,32,…\frac12, \frac32, \ldots, so the sum of an odd number of them is half an odd integer, but the centroid R2\frac{R}{2} needs the sum kDR2k_D \frac{R}{2}, which is an integer. The same holds for an even CC. A pattern with the common centroid need not be point symmetric: in a 3×53 \times 5 array, the offsets {(0,0),(−1,0),(1,0)}\{(0,0), (-1,0), (1,0)\} and {(−2,0),(1,1),(1,−1)}\{(-2,0), (1,1), (1,-1)\} from the center give two devices of 3 cells each with the centroid at the center.

Theorem 2 (the quadratic residual). Let cA=cB=cc_A = c_B = c, and let

p(r)=p0+g⋅(r−c)+12(r−c)⊤H(r−c)p(r) = p_0 + g \cdot (r - c) + \tfrac12 (r - c)^\top H (r - c)

with a symmetric matrix H=(hxxhxyhxyhyy)H = \begin{pmatrix} h_{xx} & h_{xy} \\ h_{xy} & h_{yy} \end{pmatrix}. Let SD=1kD∑i(ri−c)(ri−c)⊤S_D = \frac{1}{k_D} \sum_i (r_i - c)(r_i - c)^\top be the second moment of DD about cc. Then

PA−PB=12tr⁡(H(SA−SB))=12hxxΔSxx+hxyΔSxy+12hyyΔSyy.P_A - P_B = \tfrac12 \operatorname{tr}\big(H (S_A - S_B)\big) = \tfrac12 h_{xx} \Delta S_{xx} + h_{xy} \Delta S_{xy} + \tfrac12 h_{yy} \Delta S_{yy}.

This is zero for every HH if and only if SA=SBS_A = S_B.

Proof. The mean of the linear term is g⋅(cD−c)=0g \cdot (c_D - c) = 0. For the quadratic term, (r−c)⊤H(r−c)=tr⁡(H(r−c)(r−c)⊤)(r - c)^\top H (r - c) = \operatorname{tr}(H (r - c)(r - c)^\top), and the trace is linear, so the mean over DD is tr⁡(HSD)\operatorname{tr}(H S_D). Subtracting gives the formula. If SA≠SBS_A \neq S_B, take H=SA−SBH = S_A - S_B, which is symmetric, to get 12tr⁡((SA−SB)2)>0\frac12 \operatorname{tr}((S_A - S_B)^2) > 0. □\square

For a smooth field, the Taylor series about cc shows that the third-order terms are left after this. So the error of a common-centroid pair is of second order in the size of the array, and of third order when the second moments also agree.

Classic examples

The cells have pitch 1, and the numbers below use exact fractions.

One row of four. With p(x)=xp(x) = x (a gradient of 1 per pitch), the order AABB gives PA−PB=−2P_A - P_B = -2, the alternating order ABAB gives −1-1, and the common-centroid order ABBA gives 0. With the curvature p(x)=(x−2)2p(x) = (x - 2)^2 about the center, ABBA gives PA−PB=2P_A - P_B = 2: A has its cells at the offsets ±32\pm \frac32 and B at ±12\pm \frac12, so SA=94S_A = \frac94, SB=14S_B = \frac14 and 12⋅2⋅2=2\frac12 \cdot 2 \cdot 2 = 2. ABAB is not common centroid, but it gives 0 for this curvature. No order of one row cancels both.

The cross-quad. The 2×22 \times 2 pattern AB over BA puts each device on one diagonal. It cancels gradients in xx, in yy and in any direction. Its second moments are Sxx=Syy=14S_{xx} = S_{yy} = \frac14 for both devices, but Sxy=14S_{xy} = \frac14 for A and −14-\frac14 for B. So a pure x2x^2 or y2y^2 curvature cancels, and a curvature hxyh_{xy} leaves PA−PB=hxy⋅12P_A - P_B = h_{xy} \cdot \frac12.

A 2×42 \times 4 array with four units each. Of the 70 assignments, 8 have the common centroid. Of these, 6 also cancel the curvature x2x^2, and only 2 cancel both x2x^2 and xyxy: the pattern ABBA over BAAB and its swap, whose second moments are equal. The construction of the implementation gives ABAB over BABA, which cancels x2x^2 and leaves 12\frac12 for hxy=1h_{xy} = 1.

An odd count. A 3×33 \times 3 array with 4 units of A and 5 of B: B takes the center. The construction gives ABA, BBB, ABA. A row of 6 with 3 units each has no common-centroid pattern, by the parity argument.

A binary-weighted capacitor array. A ratio 1 : 1 : 2 with 4, 4 and 8 units fills a 4×44 \times 4 array. The construction gives the rows ABCC, ABCC, CCBA, CCBA, in which all three devices have the centroid at the center.

Variations

  • Alternating rows. A one-dimensional order such as ABAB reduces the effect of a gradient along the row, but it is common centroid only for special counts and orders.
  • Higher-order cancellation. Match the second moments as well (Theorem 2), with larger arrays and more units, to cancel a quadratic field.
  • Dispersion. Spread the units of each device evenly, so that no device has long runs of its own cells. This lowers the effect of the higher-order terms and of local defects.
  • Automatic generation. Placement tools search among the common-centroid patterns for one that also keeps the routing short and the dispersion high.
  • Symmetry about an axis. A placement in which each device is mirrored about one axis cancels gradients across the axis only. See symmetry constraints, and the placers symmetric-feasible sequence pairs and ASF-B*-trees.

Pitfalls

  • Random mismatch remains. Common centroid cancels systematic gradients. The random mismatch of each unit is not reduced by the arrangement, only by the total area, as the Pelgrom mismatch model says.
  • Edge effects. A unit at the edge of the array etches differently from one inside. Without dummy cells around the array, the outer units differ, and the cancellation fails.
  • Routing. The wires that join the units of one device add resistance and capacitance. If the routing of A and B differs, the routing makes a new mismatch.
  • Orientation. MOS units must share one orientation, because stress and the angle of implants make the orientation matter.
  • The mean is an approximation for transistors. For parallel transistors, the drain current is not linear in the threshold voltage, so Theorem 1 holds only to first order in the spread of the threshold.
  • Curvature over large arrays. The quadratic residual grows with the square of the array size. A large array of a few devices can be worse than a compact one.

Code

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

common_centroid_layout.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/common-centroid-layout/. The authors are listed in prov/JQ9ZE3.jsonl.

"""Common-centroid arrays of unit cells, and the mismatch that a gradient leaves.

The array has rows x cols unit cells. Cell (i, j) has its center at
(j + 1/2, i + 1/2), in units of the cell pitch. A pattern is a list of rows,
and each entry is the index of the device that owns the cell.
"""

from fractions import Fraction


def common_centroid_pattern(rows: int, cols: int, counts: list) -> list:
    """Give each device counts[d] cells so that each device has its centroid at
    the center of the array. Each cell is paired with its point reflection
    through the center, and both cells of a pair go to the same device."""
    n = rows * cols
    if sum(counts) != n or any(k < 0 for k in counts):
        raise ValueError("the counts must be nonnegative and fill the array")
    odd = [d for d, k in enumerate(counts) if k % 2]
    if len(odd) != n % 2:
        raise ValueError("no common-centroid pattern: wrong number of odd counts")
    grid = [[-1] * cols for _ in range(rows)]
    left = [k // 2 for k in counts]  # pairs still to place
    if n % 2:  # the center cell is its own reflection
        grid[rows // 2][cols // 2] = odd[0]
    for i in range(rows):
        for j in range(cols):
            mi, mj = rows - 1 - i, cols - 1 - j
            if (i, j) >= (mi, mj):
                continue  # each pair once, from its first cell
            # spread the devices: take the one with the largest share of pairs left
            d = max(range(len(counts)), key=lambda e: (Fraction(left[e], max(counts[e], 1)), -e))
            left[d] -= 1
            grid[i][j] = grid[mi][mj] = d
    return grid


def cells_of(grid: list) -> dict:
    out: dict = {}
    for i, row in enumerate(grid):
        for j, d in enumerate(row):
            out.setdefault(d, []).append((Fraction(2 * j + 1, 2), Fraction(2 * i + 1, 2)))
    return out


def centroids(grid: list) -> dict:
    return {d: (sum(x for x, _ in c) / len(c), sum(y for _, y in c) / len(c)) for d, c in cells_of(grid).items()}


def device_means(grid: list, p) -> dict:
    """The mean of a parameter field p(x, y) over the cells of each device."""
    return {d: sum(Fraction(p(x, y)) for x, y in c) / len(c) for d, c in cells_of(grid).items()}


def second_moments(grid: list) -> dict:
    """For each device, the mean of (dx^2, dx dy, dy^2) about the array center."""
    cx, cy = Fraction(len(grid[0]), 2), Fraction(len(grid), 2)
    out = {}
    for d, c in cells_of(grid).items():
        k = len(c)
        out[d] = (
            sum((x - cx) ** 2 for x, _ in c) / k,
            sum((x - cx) * (y - cy) for x, y in c) / k,
            sum((y - cy) ** 2 for _, y in c) / k,
        )
    return out
test_common_centroid_layout.py 122 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/common-centroid-layout/. The authors are listed in prov/JQ9ZE3.jsonl.

import itertools
import random
from fractions import Fraction

import pytest

from common_centroid_layout import centroids, common_centroid_pattern, device_means, second_moments


def all_patterns(rows: int, cols: int, counts: list):
    """Every assignment of the cells to the devices with the given counts."""
    cells = [(i, j) for i in range(rows) for j in range(cols)]

    def rec(d: int, free: list, grid: list):
        if d == len(counts) - 1:
            for i, j in free:
                grid[i][j] = d
            yield [row[:] for row in grid]
            return
        for pick in itertools.combinations(free, counts[d]):
            for i, j in pick:
                grid[i][j] = d
            rest = [c for c in free if c not in pick]
            yield from rec(d + 1, rest, grid)

    yield from rec(0, cells, [[-1] * cols for _ in range(rows)])


def linear(gx: Fraction, gy: Fraction):
    return lambda x, y: 5 + gx * x + gy * y


def quadratic(rows: int, cols: int, g: tuple, h: tuple):
    cx, cy = Fraction(cols, 2), Fraction(rows, 2)
    gx, gy = g
    hxx, hxy, hyy = h

    def p(x, y):
        dx, dy = x - cx, y - cy
        return 5 + gx * dx + gy * dy + Fraction(1, 2) * (hxx * dx * dx + 2 * hxy * dx * dy + hyy * dy * dy)

    return p


def is_point_symmetric(grid: list) -> bool:
    r, c = len(grid), len(grid[0])
    return all(grid[i][j] == grid[r - 1 - i][c - 1 - j] for i in range(r) for j in range(c))


def test_examples() -> None:
    assert common_centroid_pattern(1, 4, [2, 2]) == [[0, 1, 1, 0]]
    assert common_centroid_pattern(2, 2, [2, 2]) == [[0, 1], [1, 0]]
    g = common_centroid_pattern(3, 3, [4, 5])
    assert g[1][1] == 1
    with pytest.raises(ValueError):
        common_centroid_pattern(1, 6, [3, 3])
    with pytest.raises(ValueError):
        common_centroid_pattern(3, 3, [3, 3, 3])


def test_pattern_has_one_centroid_and_cancels_linear_gradients() -> None:
    rng = random.Random(1989)
    for rows in range(1, 5):
        for cols in range(1, 6):
            n = rows * cols
            for k in (2, 3):
                for counts in itertools.product(range(n + 1), repeat=k):
                    if sum(counts) != n or len([c for c in counts if c % 2]) != n % 2:
                        continue
                    g = common_centroid_pattern(rows, cols, list(counts))
                    assert is_point_symmetric(g)
                    assert sorted(sum(row.count(d) for row in g) for d in range(k)) == sorted(counts)
                    cs = set(centroids(g).values())
                    assert cs == {(Fraction(cols, 2), Fraction(rows, 2))}
                    gx, gy = Fraction(rng.randint(-50, 50), 7), Fraction(rng.randint(-50, 50), 7)
                    assert len(set(device_means(g, linear(gx, gy)).values())) == 1


def test_brute_force_linear_cancels_iff_same_centroid() -> None:
    rng = random.Random(7)
    for rows, cols, counts in ((2, 4, [4, 4]), (3, 3, [4, 5]), (1, 6, [3, 3]), (2, 3, [2, 4])):
        grads = [(Fraction(rng.randint(-9, 9)), Fraction(rng.randint(-9, 9))) for _ in range(4)] + [(1, 0), (0, 1)]
        any_cc = False
        for g in all_patterns(rows, cols, counts):
            same = len(set(centroids(g).values())) == 1
            cancels = all(len(set(device_means(g, linear(*gr)).values())) == 1 for gr in grads)
            assert same == cancels
            any_cc |= same
        assert any_cc == (len([c for c in counts if c % 2]) == (rows * cols) % 2)


def test_quadratic_residual_formula() -> None:
    rng = random.Random(42)
    for rows, cols, counts in ((1, 4, [2, 2]), (2, 2, [2, 2]), (2, 4, [4, 4]), (3, 3, [4, 5]), (4, 4, [8, 8])):
        g = common_centroid_pattern(rows, cols, counts)
        m = second_moments(g)
        for _ in range(5):
            grad = (Fraction(rng.randint(-9, 9)), Fraction(rng.randint(-9, 9)))
            h = tuple(Fraction(rng.randint(-9, 9), 4) for _ in range(3))
            means = device_means(g, quadratic(rows, cols, grad, h))
            (a0, a1, a2), (b0, b1, b2) = m[0], m[1]
            predicted = Fraction(1, 2) * h[0] * (a0 - b0) + h[1] * (a1 - b1) + Fraction(1, 2) * h[2] * (a2 - b2)
            assert means[0] - means[1] == predicted


def test_brute_force_best_quadratic_residual() -> None:
    # For the pure curvature p = (x - cx)^2, the best mismatch over all
    # common-centroid patterns of a 2 x 4 array is reached by some pattern,
    # and the generated pattern is never better than the best.
    p = quadratic(2, 4, (0, 0), (Fraction(2), 0, 0))
    best = None
    for g in all_patterns(2, 4, [4, 4]):
        if len(set(centroids(g).values())) == 1:
            means = device_means(g, p)
            r = abs(means[0] - means[1])
            best = r if best is None else min(best, r)
    gen = device_means(common_centroid_pattern(2, 4, [4, 4]), p)
    assert best == 0
    assert abs(gen[0] - gen[1]) >= best

Exercises

  1. Show that the pattern ABBA over BAAB has SA=SBS_A = S_B, so it cancels every quadratic field.
  2. For a row of 8 cells with 4 units each, find all orders with the common centroid. Which of them has the smallest residual for p(x)=(x−4)2p(x) = (x - 4)^2?
  3. Find a 3×33 \times 3 pattern of three devices with 3 units each, all with the centroid at the center (there are 12). Show that none of them is point symmetric, so step 3 of the template cannot make them.
  4. A field has hxx=0.3h_{xx} = 0.3 per square pitch, and hxy=hyy=0h_{xy} = h_{yy} = 0. Compute the mismatch of the cross-quad and of the one-row ABBA.

References

  1. Alan Hastings, The Art of Analog Layout, second edition, Prentice Hall, 2006, the sections Gradients and Centroids and Common-Centroid Layout (the rules of coincidence, symmetry, dispersion and compactness), and Section 12.3.5, Common-Centroid Layout of MOS Transistors
  2. Marcel J. M. Pelgrom, Aad C. J. Duinmaijer and Anton P. G. Welbers, Matching properties of MOS transistors, IEEE Journal of Solid-State Circuits 24(5), 1433 to 1440, 1989, the split of mismatch into a random part that falls with the area and a part that grows with the distance between the devices
  3. Georges G. E. Gielen and Rob A. Rutenbar, Computer-aided design of analog and mixed-signal integrated circuits, Proceedings of the IEEE 88(12), 1825 to 1854, 2000, the section on analog layout (device matching, symmetry and common-centroid placement)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • three classic examples