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 over the array. A device has unit cells with centers . Its parameter is the mean of the unit values,
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 is .
- Choose the unit cell, and the number of units of each device from the ratio.
- Choose an array of rows and columns, with equal to the total number of units (add dummy cells if needed).
- 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.
- Among such patterns, spread the devices so that their second moments are as close as possible (the dispersion rule).
- 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 for a constant vector . Then . So for every if and only if .
Proof. By linearity of the mean, . If , then . If , the gradient gives .
Lemma (step 3 works). If the cells of are a union of point-reflection pairs about the center , plus possibly the center cell itself, then . Each pair has the mean , and the center cell is , so the mean over all cells is .
When step 3 is possible. Pairs exist for every cell except the center cell, which exists only when and are both odd. So point-symmetric patterns exist exactly when every count is even, or when and are odd and exactly one count is odd. An odd count with an even cannot have the common centroid in any pattern, symmetric or not: the values of the cell centers are , so the sum of an odd number of them is half an odd integer, but the centroid needs the sum , which is an integer. The same holds for an even . A pattern with the common centroid need not be point symmetric: in a array, the offsets and from the center give two devices of 3 cells each with the centroid at the center.
Theorem 2 (the quadratic residual). Let , and let
with a symmetric matrix . Let be the second moment of about . Then
This is zero for every if and only if .
Proof. The mean of the linear term is . For the quadratic term, , and the trace is linear, so the mean over is . Subtracting gives the formula. If , take , which is symmetric, to get .
For a smooth field, the Taylor series about 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 (a gradient of 1 per pitch), the order AABB gives , the alternating order ABAB gives , and the common-centroid order ABBA gives 0. With the curvature about the center, ABBA gives : A has its cells at the offsets and B at , so , and . ABAB is not common centroid, but it gives 0 for this curvature. No order of one row cancels both.
The cross-quad. The pattern AB over BA puts each device on one diagonal. It cancels gradients in , in and in any direction. Its second moments are for both devices, but for A and for B. So a pure or curvature cancels, and a curvature leaves .
A array with four units each. Of the 70 assignments, 8 have the common centroid. Of these, 6 also cancel the curvature , and only 2 cancel both and : the pattern ABBA over BAAB and its swap, whose second moments are equal. The construction of the implementation gives ABAB over BABA, which cancels and leaves for .
An odd count. A 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 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.
# 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
- Show that the pattern ABBA over BAAB has , so it cancels every quadratic field.
- 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 ?
- Find a 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.
- A field has per square pitch, and . Compute the mismatch of the cross-quad and of the one-row ABBA.
References
- 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
- 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
- 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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag JQ9ZE3 Edit this page History Report an error Markdown