Algorithmcore
Min-cut placement
Also called Breuer min-cut placement.
Breuer's placement that bisects the netlist and the chip region again and again with a min-cut partitioner, until each region holds a few cells.
- Solves
- Placement
- Time
- O(p (n + m + P) log S) worst · averageO((n + m + P) log S) best
- Space
- O(n + m + P) extra
- Where
- P = the number of pins; S = the number of sites; m = the number of nets; n = the number of cells; p = the largest number of FM passes in one region
- Model
- Word RAM
- Properties
- randomizednot exactrecursive
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Melvin A. Breuer, 1977
Min-cut placement solves the placement problem by divide and conquer on the chip. It cuts the placement region into two halves by a line, splits the cells into two groups of the right sizes with a hypergraph partitioner so that few nets cross, and does the same in each half, until each region holds one site or a few cells. Breuer introduced it in 1977. The idea is that every net that crosses a cut line adds to the wire length, so keeping the cuts small keeps the HPWL small. It is a heuristic: each cut is only locally good, and the method has no approximation guarantee.
In plain words
You must seat many guests at a long table so that friends sit close. Split the guests into two groups with few friendships across, and give each group one half of the table. Then split each group again for its half, and so on, until each guest has a chair.
Each split looks only at the guests of one group. A guest who has a friend in the other half of the room would like to sit near that side, but a plain split cannot see this. Terminal propagation fixes that: it adds a dummy guest who stands for the friend outside and is fixed on the right side.
The problem
The input is a netlist of unit cells and nets with pins, fixed pads with integer positions, and a rectangle of unit sites at the points with and , with . The output is a legal placement: an injective map of the cells to the sites. The goal, which the method approaches but does not reach in general, is the least total HPWL of the nets. The implementation puts every pin at the position of its cell or pad, with no pin offsets. Rows of cells of different widths change only the capacity of a region; the method stays the same.
The algorithm
The regions are processed in breadth-first order with a queue, so that all regions of one level are cut before the next level starts. Each cell has an estimated position, the center of its current region, which terminal propagation uses for cells outside the region being cut.
MIN-CUT-PLACE(cells, nets, pads, W, H)- 1
Q ← a queue with (the whole region, all cells) - 2
while Q is not empty - 3
(B, C) ← the front of Q, removed - 4
if B is one site then place the cell of C there (if any) and continue - 5
cut B across its longer side through the middle into B0 and B1, with c0 and c1 sites - 6
build the netlist of C: each net restricted to C; with terminal propagation, add a fixed terminal on side s if the other pins of the net lie on side s of the line, and drop the net if they lie on both sides - 7
t ← round(|C| c0 / (c0 + c1)); start from a random split with t cells on side 0 - 8
(C0, C1) ← FM with the fixed terminals and |C0| in [max(t − 1, |C| − c1), min(t + 1, c0)] - 9
for s ∈ {0, 1}: set the estimate of each cell of C_s to the center of B_s, and add (B_s, C_s) to Q - 10
return the sites of the cells
Line L6 looks at each net with a pin in . The pins in stay. A pin outside is a pad at its position or a cell at its estimate. If its coordinate across the cut lies exactly on the cut line, it is ignored, since it pulls to neither side. If all other outside pins are on side , the net gets the fixed terminal of side ; if they are on both sides, the net is cut whatever the split is, so it is left out. Without terminal propagation, line L6 keeps only the pins in .
Line L8 uses Fiduccia-Mattheyses passes with the two terminals fixed. A tentative move may leave the window by one cell, but only a prefix of the pass that ends inside the window is kept. So FM can still swap cells when the window has one value, as for a region of 4 cells and 4 sites. The window is never empty, and it keeps and .
Example
Place 8 cells on a grid of sites. A pad at and a pad at . The 13 nets, all 2-pin, are
So cells 0 to 3 form one cluster with pad , cells 4 to 7 another with pad , and the net joins them. The trace is the run of the implementation with terminal propagation and random.Random(0).
| step | region | cut line | cells | terminals | result | cut |
|---|---|---|---|---|---|---|
| 1 | 0 to 7 | on side 0, on side 1 | 1 | |||
| 2 | 0 to 3 | for 0 on side 0, cell 4 at for 3 on side 1 | 3 | |||
| 3 | 4 to 7 | cell 3 at for 4 on side 0, for 7 on side 1 | 3 | |||
| 4 | 0, 2 | for 0 on side 0 | 0 at , 2 at | 1 | ||
| 5 | 1, 3 | cell 0 for 1 on side 0, cell 2 for 1 and 3 on side 1 | 1 at , 3 at | 2 | ||
| 6 | 4, 5 | cell 3 at for 4 on side 1 | 5 at , 4 at | 1 | ||
| 7 | 6, 7 | cell 5 for 6 and 7 on side 0, cell 4 for 6 and for 7 on side 1 | 7 at , 6 at | 3 |
Step 1 has , so the window is exactly 4; FM goes from the random start, with cut 7, to cut 1. In step 2, the split also has cut 3, and the random start decides. In step 5 the net is dropped, because cell 4 has the estimate , exactly on the line . In step 7 both splits cut 3 nets.
The placement is
| 2 | 3 | 4 | 6 | |
| 0 | 1 | 5 | 7 |
with HPWL 16. The lines are crossed by nets, and the line by 7 nets, so , as the identity below says. A brute force over all placements gives the optimum 16 for this instance. Without terminal propagation, seeds 0 to 3 give 24, 20, 18 and 24; with it, all four give 16.
Correctness
The proof shows the following.
- The window. For , the window of line L8 contains , so the random start lies in it, and every kept split satisfies and .
- Legality. By induction on the queue, each region holds at most as many cells as it has sites. Regions of the same level are disjoint, and each cell is in exactly one of them. A region of one site holds at most one cell. So the output is an injective map to sites inside the rectangle.
- Termination. Each cut is through the middle of a side of length at least 2, so both parts are smaller. The queue becomes empty after at most regions.
- HPWL as a sum of cuts. With integer positions, the HPWL of a placement equals the sum, over the lines and , of the number of nets with pins on both sides of the line. Each cut of line L8 tries to make one term of this sum small.
- Terminal propagation counts exactly. If all outside pins of every net were at their final positions, the cut of line L8 with the terminals would be the number of nets of the region that cross the line, less the number of dropped nets, which does not depend on the split. So both have the same best splits. The terminal propagation page discusses this. The estimates are only centers of regions, so in the algorithm this is a model, not a guarantee.
Proof: Min-cut placement returns a legal placement, stops after at most 2S - 1 regions, and its HPWL is a sum of cut countsfull
The sites are the integer points with and , and . A region is a rectangle of sites . For a region with the cells , line L5 cuts the longer side through the middle into and , with and sites, and line L7 sets with . The window of line L8 is with and .
Lemma 1 (window). If , then .
Proof. Let . Rounding gives . Since , we have , so , and because is an integer. In the same way , so , and . Also gives . The terms and hold trivially. So every term of the maximum is at most , and every term of the minimum is at least .
Lemma 2 (FM keeps the window). If the start has , the split returned by line L8 has .
Proof. A pass keeps the prefix of its tentative moves with the largest total gain among the prefixes that end with , and the empty prefix is one of them because the pass starts inside the window. So each pass ends inside the window, and the next pass starts there. The fixed terminals never move and are not counted in . FM stops because a new pass starts only after a pass with positive total gain, and the integer cut falls by at least 1 each time.
The start of line L7 has exactly cells on side 0, which is in the window by Lemma 1. So with Lemma 2 every split satisfies and .
Theorem 1 (legality). If , the output places every cell on a site of the rectangle, and no two cells on the same site.
Proof. Call a pair in the queue good if is at most the number of sites of . The first pair is good because . If is good and is cut, Lemmas 1 and 2 show that both pairs are good. Consider the tree of all regions put in the queue, where the children of a cut region are and . The two children are disjoint and their union is the parent, so two regions of the tree are either nested or disjoint. The cells of a cut region go to exactly one child, so at each time every cell is in exactly one region of the queue, or has a site. A cell leaves the queue only through line L4, and line L4 handles only regions of one site. A good pair with one site has at most one cell, so line L4 never puts two cells of one region on its site. Two different one-site regions are leaves of the tree, so they are disjoint and are different sites. By Theorem 2 the queue becomes empty, so every cell gets a site.
Theorem 2 (termination). The loop of lines L2 to L9 runs at most times, and every root to leaf path of the region tree has at most cuts.
Proof. A region that is cut is not one site, so its longer side has length , and the cut makes parts with sides and . So both children are nonempty rectangles with fewer sites. The region tree is a binary tree in which each inner node has exactly two children. Its leaves are pairwise disjoint nonempty sets of sites, so there are at most leaves, and at most nodes. Each node is removed from the queue once. On a path from the root, each vertical cut replaces a width by at most , so after vertical cuts the width is 1 and no more vertical cut happens (line L5 cuts vertically only when the width is the longer side, and a region of width 1 and height 1 is not cut). The same holds for the height.
Lemma 3 (HPWL as a sum of cut counts). Let all pins have integer positions. For an integer , let be the number of nets with pins on both sides of the line , and define in the same way. Then the HPWL is .
Proof. Take one net with smallest and largest coordinates . It has pins on both sides of exactly when , that is . There are such , which is the part of its bounding box. The same argument holds for . Add over all nets and change the order of the sums.
Every cell of is later placed inside by Theorem 1, so it ends on side of the cut line. So the cut that line L8 makes small is a part of one term or : the nets of that will cross that line.
Lemma 4 (terminal propagation). Suppose that every pin outside is at a fixed position that is not on the cut line. For a split , let be the number of nets with a pin in that have pins on both sides of the line when the cells of are on side , and let be the cut of the netlist built in line L6. Then , where is the number of nets left out because they have outside pins on both sides. does not depend on the split.
Proof. Take a net with a pin in . If it has no outside pins, crosses the line exactly when its pins in are split, and the restricted net is cut exactly then (a net with one pin is never split and is left out). If all its outside pins are on side , crosses the line exactly when some pin in is on side , and that is exactly when the restricted net with the terminal of side is cut. If it has outside pins on both sides, it crosses the line for every split, and it is left out of the netlist. Add over the nets.
So under the assumption of Lemma 4, the splits of least cut in line L8 are exactly the splits with the fewest crossing nets. In the algorithm the outside cells are at the centers of their regions, not at their final sites, so the assumption is false in general, and the lemma explains the method but gives no bound.
Running time. By Theorem 2 there are levels. The regions of one level have disjoint cell sets. Line L6 visits each pin of each net with a pin in , and adds at most one terminal per net. With a mark per net, a net is handled once per region it touches, and a net with pins touches at most regions of a level, so the netlists of a level have pins in all. An FM pass with gain buckets costs time linear in the size of its netlist (see the Fiduccia-Mattheyses page), so a level costs if each region uses at most passes, and the total is . The queue holds the regions of at most two levels, with disjoint cell sets, so the space is . The implementation picks each move by a scan of the free cells and rebuilds each restricted net from its full pin list, so a region with cells costs per pass over the nets of the region.
What is not proved. Nothing above compares the HPWL of the output with the minimum. Each cut is only a local optimum of FM, and no approximation ratio of min-cut placement for HPWL is known.
Complexity
- Levels. A cut halves the longer side, so after at most levels every region is one site. This is .
- One level. The regions of a level hold disjoint cells. Building their netlists in line L6 visits each pin of each net with a pin in the region, and each net gets at most one terminal, so a level has pins in total with marking of the nets. With gain buckets, an FM pass costs time linear in the size of its netlist, so a level costs for at most passes per region.
- Total. time and space, since the regions of a level can be processed one by one.
- The implementation finds the move of largest gain by a scan, and line L6 recomputes each restricted net from the full pin list, so a region with cells costs per FM pass. This is fine for the toy inputs of the tests.
Properties
Min-cut placement is a heuristic for an NP-hard problem. What is proved and what is measured are kept apart.
What is proved. Legality, termination and the cost above; the identity between HPWL and the sum of crossing counts; and the exact count of terminal propagation, up to a constant, when the outside pins are where they are assumed to be. No approximation ratio for HPWL is known. Each cut is a local optimum of FM, not a minimum cut, and a minimum cut at one level can force a bad cut at the next.
What is measured. The numbers below are from the implementation of this page, on toy inputs, and are not benchmark results. Published placers based on min-cut partitioning were compared on the ISPD 2005 and 2006 placement contest benchmarks; see those contests for the numbers.
- Tiny grids. On 100 random instances with 6 cells on a grid, 8 nets and 0 to 3 pads outside the grid (generator
random.Random(2026), run seeded withrandom.Random(t)), compared with a brute force over all placements: with terminal propagation the result was optimal in 53 instances, with mean ratio 1.036 to the optimum; without it, optimal in 7, with mean ratio 1.171. - A hidden grid. 20 netlists (generator
random.Random(2027)), each the grid graph on 64 cells in a random order, with 112 two-pin nets and 16 pad nets to pads just outside the edge. Each net has length at least 1, and the hidden layout reaches 128, so the optimum is exactly 128. With terminal propagation the mean HPWL was 146.3, and two of the first three runs reached 128. Without it the mean was 392.4. Terminal propagation won in all 20.
Variants and improvements
- Cut sequences. Breuer compared quadrature (alternate vertical and horizontal cuts through the middle, as here), bisection (cut the region into rows first, then cut each row), and slice/bisection. The order of the cut lines changes the result.
- Multilevel partitioners. Modern min-cut placers such as Capo use multilevel hypergraph partitioning for each cut, with fixed terminals, and a tolerance on the sizes.
- Unequal cuts and whitespace. A cut line need not be in the middle; it can follow the sizes of the two cell groups, so that the free space spreads evenly.
- End cases. Stop at regions of a few cells and place them by exhaustive search or by a small branch and bound, then legalize and run detailed placement.
- k-way cuts. Cut a region into four parts at once (quadrisection), which sees both directions at the same time.
- Hybrids. Use min-cut placement to spread cells in an analytical or quadratic placer, or use quadratic placement to estimate the positions for terminal propagation.
When to use it
Use min-cut placement when you have a good hypergraph partitioner and want a placement that is legal by construction, that scales to large netlists, and that tends to keep the routing demand across each cut line small. In the ISPD 2005 and 2006 placement contests, analytical placers had the best results, so min-cut is now used mostly inside other flows, for floorplans and for the end cases. The recursive cuts also build a slicing floorplan of the chip.
Pitfalls
- No terminal propagation. Without it, each cut ignores the cells outside the region, and the two halves of a cluster can end up far apart. The toy measurements above show the size of the effect.
- Balance too tight or too loose. An exact window gives FM no room to move; too much slack lets one side take more cells than its sites. Bound the window by the capacities, as line L8 does.
- Pins on the cut line. A pin exactly on the line pulls to neither side. Counting it on one side biases the cut.
- Nets with outside pins on both sides. Such a net is cut in every split. Giving it two terminals adds a constant to every cut, which is harmless, but giving it one terminal is wrong.
- Depth first order. If the regions are cut depth first, the estimates of the cells in regions not yet cut are coarse, and terminal propagation sees less. Breadth first order makes all estimates of one level equally fine.
Implementations
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/min-cut-placement/. The authors are listed in prov/S0NJTB.jsonl.
import random
from collections import deque
from fractions import Fraction
from typing import Sequence
Point = tuple[int, int]
def hpwl(pos: Sequence[Point], nets: Sequence[Sequence[int]]) -> int:
"""Total half-perimeter wirelength; pins sit at the cell or pad position (no pin offsets)."""
total = 0
for e in nets:
xs = [pos[p][0] for p in e]
ys = [pos[p][1] for p in e]
total += max(xs) - min(xs) + max(ys) - min(ys)
return total
def fm_with_fixed(
k: int,
nets: Sequence[Sequence[int]],
fixed: dict[int, int],
side: Sequence[int],
lo: int,
hi: int,
) -> list[int]:
"""Fiduccia-Mattheyses passes on vertices 0 .. k-1 plus fixed vertices.
fixed maps the extra vertex ids (k and up) to their side; they never move
and do not count for the balance. A tentative move may take the number of
free vertices on side 0 one step outside [lo, hi], but only a prefix that
ends inside [lo, hi] is applied, so exact balance (lo = hi) still allows
swaps. The vertex of largest gain is found by a scan.
"""
total = k + len(fixed)
side = list(side) + [0] * len(fixed)
for v, s in fixed.items():
side[v] = s
vnets: list[list[int]] = [[] for _ in range(total)]
for i, e in enumerate(nets):
for v in e:
vnets[v].append(i)
while True:
cnt = [[0, 0] for _ in nets]
for i, e in enumerate(nets):
for v in e:
cnt[i][side[v]] += 1
gain = [0] * total
for v in range(k):
s = side[v]
for i in vnets[v]:
gain[v] += (cnt[i][s] == 1) - (cnt[i][1 - s] == 0)
locked = [False] * k + [True] * len(fixed)
c0 = sum(1 for v in range(k) if side[v] == 0)
moves: list[int] = []
run, best_run, best_k = 0, 0, 0
while True:
pick = -1
for v in range(k):
if locked[v]:
continue
nc0 = c0 - 1 if side[v] == 0 else c0 + 1
if lo - 1 <= nc0 <= hi + 1 and (pick < 0 or gain[v] > gain[pick]):
pick = v
if pick < 0:
break
v, f = pick, side[pick]
t = 1 - f
locked[v] = True
for i in vnets[v]:
e = nets[i]
if cnt[i][t] == 0:
for u in e:
if not locked[u]:
gain[u] += 1
elif cnt[i][t] == 1:
for u in e:
if side[u] == t and not locked[u]:
gain[u] -= 1
cnt[i][f] -= 1
cnt[i][t] += 1
if cnt[i][f] == 0:
for u in e:
if not locked[u]:
gain[u] -= 1
elif cnt[i][f] == 1:
for u in e:
if side[u] == f and u != v and not locked[u]:
gain[u] += 1
run += gain[v]
side[v] = t
c0 += -1 if f == 0 else 1
moves.append(v)
if lo <= c0 <= hi and run > best_run:
best_run, best_k = run, len(moves)
for v in moves[best_k:]:
side[v] = 1 - side[v]
if best_run <= 0:
return side[:k]
def min_cut_placement(
n: int,
nets: Sequence[Sequence[int]],
pads: Sequence[Point],
width: int,
height: int,
rng: random.Random,
terminal_propagation: bool = True,
) -> list[Point]:
"""Place n unit cells on the sites (x, y), 0 <= x < width, 0 <= y < height.
Pin ids 0 .. n-1 are cells and n + j is the fixed pad at pads[j]. Regions
are cut in breadth-first order across their longer side, through the
middle, and the cells of each region are bisected by FM in proportion to
the site counts, within one cell. With terminal propagation, every net
with pins outside the region gets a fixed terminal on the side of the cut
where those pins are (pads at their position, other cells at the center
of their current region); a net with outside pins on both sides is always
cut and is left out, and pins exactly on the cut line are ignored.
Returns the site of each cell. Cost: at most ceil(log2 width) +
ceil(log2 height) levels of regions; building the subnetlists of a level
costs O(sum of |e|^2 over the nets), and an FM pass in a region of k
cells costs O(k^2 + sum of |e|^2 over its nets) with the scan.
"""
if n > width * height:
raise ValueError("more cells than sites")
est: list[tuple[Fraction, Fraction]] = [(Fraction(width - 1, 2), Fraction(height - 1, 2))] * n
pos: list[Point] = [(-1, -1)] * n
pin_nets: list[list[int]] = [[] for _ in range(n)]
for i, e in enumerate(nets):
for p in e:
if p < n:
pin_nets[p].append(i)
queue = deque([(0, width, 0, height, list(range(n)))]) # @line L1
while queue: # @line L2
x0, x1, y0, y1, cells = queue.popleft() # @line L3
if not cells:
continue
if x1 - x0 == 1 and y1 - y0 == 1: # @line L4
pos[cells[0]] = (x0, y0)
continue
vertical = x1 - x0 >= y1 - y0 # @line L5
if vertical:
xm = x0 + (x1 - x0) // 2
line = Fraction(2 * xm - 1, 2)
sub = [(x0, xm, y0, y1), (xm, x1, y0, y1)]
else:
ym = y0 + (y1 - y0) // 2
line = Fraction(2 * ym - 1, 2)
sub = [(x0, x1, y0, ym), (x0, x1, ym, y1)]
caps = [(b[1] - b[0]) * (b[3] - b[2]) for b in sub]
local = {c: j for j, c in enumerate(cells)}
k = len(cells)
fixed: dict[int, int] = {}
sub_nets: list[list[int]] = []
seen: set[int] = set()
for c in cells: # @line L6
for i in pin_nets[c]:
if i in seen:
continue
seen.add(i)
inner = sorted({local[p] for p in nets[i] if p < n and p in local})
if terminal_propagation:
sides = set()
for p in nets[i]:
if p < n and p in local:
continue
q = (Fraction(pads[p - n][0]), Fraction(pads[p - n][1])) if p >= n else est[p]
coord = q[0] if vertical else q[1]
if coord != line:
sides.add(0 if coord < line else 1)
if len(sides) == 2:
continue
if sides:
s = sides.pop()
term = k + s
fixed[term] = s
inner.append(term)
if len(inner) >= 2:
sub_nets.append(inner)
# The two terminal ids k and k + 1 must both exist for fm_with_fixed.
fixed.setdefault(k, 0)
fixed.setdefault(k + 1, 1)
t = round(Fraction(k * caps[0], caps[0] + caps[1])) # @line L7
lo, hi = max(k - caps[1], t - 1, 0), min(caps[0], t + 1, k)
start = [0] * t + [1] * (k - t)
rng.shuffle(start)
side = fm_with_fixed(k, sub_nets, fixed, start, lo, hi) # @line L8
for s in (0, 1): # @line L9
group = [cells[j] for j in range(k) if side[j] == s]
bx0, bx1, by0, by1 = sub[s]
for c in group:
est[c] = (Fraction(bx0 + bx1 - 1, 2), Fraction(by0 + by1 - 1, 2))
queue.append((bx0, bx1, by0, by1, group))
return pos # @line L10
test_min_cut_placement.py 140 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/min-cut-placement/. The authors are listed in prov/S0NJTB.jsonl.
import random
from itertools import permutations
from min_cut_placement import fm_with_fixed, hpwl, min_cut_placement
def direct_hpwl(pos, nets) -> int:
"""HPWL by a direct sum over pairs of pins: the largest x gap plus the largest y gap."""
total = 0
for e in nets:
total += max(abs(pos[a][0] - pos[b][0]) for a in e for b in e)
total += max(abs(pos[a][1] - pos[b][1]) for a in e for b in e)
return total
def crossings(pos, nets) -> int:
"""Sum over the lines x = j + 1/2 and y = j + 1/2 of the number of nets that cross the line."""
xs = [p[0] for p in pos]
ys = [p[1] for p in pos]
total = 0
for j in range(min(xs) - 1, max(xs) + 1):
total += sum(1 for e in nets if min(pos[p][0] for p in e) <= j < max(pos[p][0] for p in e))
for j in range(min(ys) - 1, max(ys) + 1):
total += sum(1 for e in nets if min(pos[p][1] for p in e) <= j < max(pos[p][1] for p in e))
return total
def brute_force(n, nets, pads, width, height) -> int:
sites = [(x, y) for x in range(width) for y in range(height)]
best = None
for perm in permutations(sites, n):
h = hpwl(list(perm) + list(pads), nets)
if best is None or h < best:
best = h
return best
def random_instance(rng, n, width, height, m):
q = rng.randint(0, 3)
pads = []
for _ in range(q):
if rng.random() < 0.5:
pads.append((rng.choice([-1, width]), rng.randrange(height)))
else:
pads.append((rng.randrange(width), rng.choice([-1, height])))
pins = n + q
nets = []
for _ in range(m):
size = rng.choice([2, 2, 3, 3, 4])
e = rng.sample(range(pins), min(size, pins))
if any(p < n for p in e) and len(e) >= 2:
nets.append(e)
return pads, nets
def check_legal(pos, n, width, height):
assert len(pos) == n
assert len(set(pos)) == n
for x, y in pos:
assert 0 <= x < width and 0 <= y < height
def page_example():
# 8 cells on a 4 x 2 grid, pad 8 at the left (x = -1) and pad 9 at the right (x = 4).
nets = [[8, 0], [0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [3, 4], [4, 5], [4, 6], [5, 6], [5, 7], [6, 7], [7, 9]]
pads = [(-1, 0), (4, 1)]
return 8, nets, pads, 4, 2
def test_page_example():
n, nets, pads, w, h = page_example()
pos = min_cut_placement(n, nets, pads, w, h, random.Random(1))
check_legal(pos, n, w, h)
full = pos + pads
assert hpwl(full, nets) == direct_hpwl(full, nets) == crossings(full, nets)
assert hpwl(full, nets) >= brute_force(n, nets, pads, w, h)
def test_hpwl_identity_and_direct_sum():
rng = random.Random(3)
for _ in range(300):
n = rng.randint(1, 8)
w, h = rng.randint(1, 4), rng.randint(1, 4)
if n > w * h:
continue
pads, nets = random_instance(rng, n, w, h, rng.randint(0, 10))
sites = rng.sample([(x, y) for x in range(w) for y in range(h)], n)
full = sites + pads
assert hpwl(full, nets) == direct_hpwl(full, nets) == crossings(full, nets)
def test_fm_with_fixed_keeps_balance_and_never_worse():
rng = random.Random(9)
for _ in range(300):
k = rng.randint(1, 9)
nets = []
for _ in range(rng.randint(0, 12)):
e = sorted(set(rng.sample(range(k + 2), min(k + 2, rng.randint(2, 4)))))
if any(v < k for v in e):
nets.append(e)
t = rng.randint(0, k)
side = [0] * t + [1] * (k - t)
rng.shuffle(side)
fixed = {k: 0, k + 1: 1}
def cut(s):
full = list(s) + [0, 1]
return sum(1 for e in nets if len({full[v] for v in e}) == 2)
out = fm_with_fixed(k, nets, fixed, side, t, t)
assert out.count(0) == t
assert cut(out) <= cut(side)
def test_against_brute_force_on_small_grids():
rng = random.Random(2026)
for trial in range(120):
w, h = rng.choice([(1, 3), (2, 2), (3, 1), (2, 3), (3, 2), (1, 5), (4, 1)])
n = rng.randint(1, w * h)
pads, nets = random_instance(rng, n, w, h, rng.randint(1, 8))
for tp in (True, False):
pos = min_cut_placement(n, nets, pads, w, h, random.Random(trial), terminal_propagation=tp)
check_legal(pos, n, w, h)
full = pos + pads
got = hpwl(full, nets)
assert got == direct_hpwl(full, nets) == crossings(full, nets)
assert got >= brute_force(n, nets, pads, w, h)
def test_larger_grid_is_legal():
rng = random.Random(4)
for _ in range(10):
w, h = rng.randint(3, 6), rng.randint(3, 6)
n = rng.randint(1, w * h)
pads, nets = random_instance(rng, n, w, h, 2 * n)
pos = min_cut_placement(n, nets, pads, w, h, rng)
check_legal(pos, n, w, h)
History
Breuer (1977) proposed placing a circuit by repeated min-cut partitioning, with several orders of cut lines, and related the cut values to the wire length. Lauther (1979) used min-cut placement for building blocks. Dunlop and Kernighan (1985) added terminal propagation and applied the method to standard cells, with a Kernighan-Lin style partitioner. In the late 1990s, multilevel partitioners such as hMETIS made min-cut placement fast on large designs, and Capo (Caldwell, Kahng and Markov, 2000) was a widely used min-cut placer.
References
- M. A. Breuer, Min-cut placement, Journal of Design Automation and Fault-Tolerant Computing 1(4), 343 to 362, 1977, the placement by repeated min-cut partitioning, the cut line sequences (quadrature, bisection and slice/bisection), and the relation between the cut values and the wire length
- M. A. Breuer, A class of min-cut placement algorithms, Proceedings of the 14th Design Automation Conference, 284 to 290, 1977, the conference version of the min-cut placement procedures
- Alfred E. Dunlop and Brian W. Kernighan, A procedure for placement of standard-cell VLSI circuits, IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 4(1), 92 to 98, 1985, terminal propagation, and min-cut placement of standard cells with Kernighan-Lin style partitioning
- C. M. Fiduccia and R. M. Mattheyses, A linear-time heuristic for improving network partitions, 19th Design Automation Conference, 175 to 181, 1982, the partitioner used at each cut, with the balance condition
- Andrew B. Kahng, Jens Lienig, Igor L. Markov and Jin Hu, VLSI Physical Design, From Graph Partitioning to Timing Closure, second edition, Springer, 2022, Chapter 4, Global and Detailed Placement (min-cut placement; general locator)
Where this leads
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 | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag S0NJTB Edit this page History Report an error Markdown