Algorithmadvanced
TILOS
Also called Fishburn-Dunlop sizing, TILOS sizing.
Fishburn and Dunlop's transistor sizing that, on the Elmore model where delay is a posynomial, enlarges the device with the best delay gain on the critical path.
- Solves
- Gate sizing
- Time
- O(K (n + m)) worst
- Space
- O(n + m) extra
- Where
- K = the total number of size steps over all gates; m = the number of connections; n = the number of gates
- Model
- Real RAM
- Properties
- deterministicnot exactgreedy
- Evidence
- Proof sketchCode in 1 languages
- Origin
- John P. Fishburn, Alfred E. Dunlop, 1985
TILOS is a greedy method for gate sizing: it starts with every device at its smallest size, and while the circuit is too slow it makes one device on the critical path one step larger, the one that gives the largest decrease of the path delay per unit of added area. Fishburn and Dunlop gave it in 1985 for transistor sizing, under an Elmore delay model in which every delay is a posynomial in the sizes. The output always meets the target when the method succeeds, but it is a heuristic: the area is not the least in general, and the method can fail when a solution exists.
In plain words
A circuit is too slow. Larger gates drive their loads faster, but they cost area, and they also load the gates in front of them, which then get slower.
TILOS starts with every gate as small as it can be. It finds the slowest path through the circuit, since only that path decides the delay. For each gate on that path it asks: if this gate were one size larger, how much faster would the path get, and how much area would that cost? It makes the best one larger. Then it measures the circuit again, because the slowest path may now be a different one.
It stops when the circuit is fast enough. If no step on the slowest path makes it faster, it gives up. It never makes a gate smaller again.
The problem
The circuit is a DAG of gates in topological order, and gate has a size from an increasing list . With the notation of static timing analysis, the delay of gate is the Elmore delay of a switch-level RC model,
where is the intrinsic delay, the drive resistance, the input capacitance of a fanout gate and the fixed load of wires and outputs. The arrival time of a gate is the latest arrival time of its fanins plus its own delay, and the circuit delay is the latest arrival time. Given a target , find sizes with and least area . TILOS sizes one device per step, transistor or gate; the page uses gates, as the implementation does.
The algorithm
TILOS(circuit, size lists, target T)- 1
x ← the smallest size of every gate repeat- 2
if Δ(x) ≤ T then return x - 3
P ← a critical path, traced back from the latest arrival - 4
for each gate g on P that is below its largest size do - 5
G_g ← the decrease of the delay of P if g moves one size up - 6
g* ← the gate with G_g > 0 and the largest G_g / (area added) - 7
if there is no such gate then return failure - 8
move g* one size up
The gain in line L5 is local. A larger lowers and raises the delay of each fanin of , through its input capacitance, and changes no other delay. So the gain is the change of plus the change of the delays of the fanins of that are on . Fishburn and Dunlop sized transistors and multiplied a size by a fixed bump factor in each step; a list of library sizes is the discrete form of the same rule.
Example
Take a chain of four gates with all , resistances , areas and a load at the output. Gate 0 is a fixed driver of size 1, the other gates have the sizes , and the target is .
| step | sizes | delay | area | gains , , | move |
|---|---|---|---|---|---|
| 0 | 1, 1, 1 | 46 | 7 | , 0, 16 | gate 3 |
| 1 | 1, 1, 2 | 30 | 8 | , 1, 4 | gate 3 |
| 2 | 1, 1, 3 | 26 | 9 | , 2, 1 | gate 3 |
| 3 | 1, 1, 4 | 25 | 10 | , 3, at the top | gate 2 |
| 4 | 1, 2, 4 | 22 | 13 | done |
In step 2 the ratios are for gate 2 (area 3 per step) and for gate 3, so gate 3 grows again. Gate 1 never helps: a larger gate 1 loads the weak driver more than it gains. TILOS ends with area 13 and delay 22. Enumeration of all 64 sizings gives the least area 12, at sizes with delay . TILOS cannot reach it, because it would have to make gate 3 smaller after gate 2 grows.
TILOS can also fail when a sizing exists. Take the same chain with , all areas 1, and . The smallest sizes give delay 17. TILOS makes gate 1 larger (gain ) and reaches delay ; then no single step on the path has a positive gain, and it stops. The sizes give delay .
Correctness
The proof is in proofs/correctness.md. The path traced back from the latest arrival through the fanin that sets each arrival time has a delay equal to the circuit delay. Every move takes the next size in a list, so the sizes stay legal, and the method returns sizes only after it checks ; so a returned sizing always meets the target, and if no sizing does, TILOS fails. Each move raises one position in one list, so the loop ends after at most moves. Each is a posynomial in the sizes, so the continuous problem is a geometric program and every local minimum is global. TILOS does not find that minimum: the example shows that it can end with more area than the discrete optimum.
Proof: TILOS returns only sizings that meet the target, stops after a bounded number of steps, and is not optimalfull
Model. The circuit is a DAG of gates in topological order, with edges. Gate has a size from a finite increasing list , and constants , and . Its delay is
The arrival time is for a gate without fanins and otherwise. The circuit delay is and the area is . Given a target , the problem is to find sizes with and least area. TILOS starts at the smallest sizes. While , it takes a critical path , and over the gates that are not at their largest size it computes the gain , where moves one step up its list. It moves up the gate with the largest positive ratio , and it stops with failure if no gain is positive.
Lemma 1 (critical path). Let be found by starting at a gate of largest arrival and following, from each gate, the fanin that sets its arrival time, until a gate without fanins. Then is a path of the DAG from a gate without fanins, and .
Proof. By the recurrence, for each step and . Summing gives , and by the choice of .
Lemma 2 (the gain is local). Moving gate up changes only and the delays of the fanins of . So is the change of plus the change of over the fanins of that lie on , and with a mark on the gates of it is computed in time.
Proof. appears in through and in for through the load term , and nowhere else. The other terms of the path sum do not change. The predecessor of on is one such fanin, but an earlier gate of can also be a fanin of , so all fanins on must be counted.
Theorem 1 (soundness). If TILOS returns sizes , then for all and . If no assignment meets , TILOS returns failure.
Proof. Each move takes the next entry of , so all sizes stay in their lists. TILOS returns sizes only when the test holds. If no assignment meets , that test never holds, and by Theorem 2 the loop ends, so it ends with failure.
Theorem 2 (termination and time). TILOS makes at most moves, and runs in time.
Proof. Each move raises the position of one gate in its list by one, and no move lowers a position, so the sum of the positions grows by one per move and is at most . Each round computes all arrival times in , traces the path in , and by Lemma 2 computes all gains on the path in in total.
Lemma 3 (the delay is a posynomial). For continuous sizes , each is a posynomial, and with every is a convex function of . So the continuous problem with path constraints for all paths is a geometric program, and every local minimum of it is global.
Proof. is a sum of monomials , and with positive coefficients. A monomial is , and the log of a sum of exponentials of affine functions is convex. Sums of posynomials are posynomials, so each path constraint is a posynomial at most , and the area is convex. A convex problem has no local minimum that is not global.
Lemma 3 is the fact that Fishburn and Dunlop used. It does not make TILOS optimal, because TILOS only moves sizes up, one step and one gate at a time, along the current critical path.
Theorem 3 (not optimal). There are instances where TILOS returns sizes whose area exceeds the least area over the discrete sizes.
Proof. The chain of the page, with , , all , , gate 0 fixed at size 1, sizes for the others and . TILOS returns with area 13 and delay 22. The sizes have delay and area 12.
Theorem 4 (not complete). There are instances where TILOS fails although some sizing meets the target.
Proof. The same chain with , all , and . At the smallest sizes the delays are , , and , so . Moving gate 1 up gains , gate 2 gains and gate 3 gains 0, so TILOS moves gate 1, which gives . Now each move on the path has gain at most 0, and TILOS fails. The sizes have delays and .
Complexity
Each round does one timing pass in , traces the path in , and computes all the local gains on the path in in total. There are at most rounds, so the time is and the extra space is . With a bump factor on continuous sizes, the number of rounds is at most the sum over the gates of of the ratio of the largest to the smallest size.
Properties
- Sound: when it returns a sizing, the sizing meets the target (proved).
- Monotone: sizes only grow and the area strictly grows in each round.
- Not optimal and not complete: it can use more area than the optimum, and it can fail on targets that some sizing meets (shown by examples). Its area is at least the optimum, as for any feasible sizing.
- It only looks at one critical path at a time. When many paths are near critical, it can spend area on gates that help only one of them.
- Its quality is measured, not proved. Sapatnekar, Rao, Vaidya and Kang measured the gap between TILOS and the exact convex optimum on their test circuits.
Variants and improvements
- Continuous bumping. The original multiplies a size by a factor slightly above 1 in each step, which approximates the continuous problem.
- Area recovery. A second pass that tries to make gates smaller while the target still holds removes some of the overshoot shown in the example.
- Exact continuous sizing. Since the delay is a posynomial, the continuous problem can be solved to optimality, as a geometric program by convex optimization, or by Lagrangian relaxation gate sizing. A TILOS result is often used as the start point for these methods or for a rounding step.
- Other delay models. The greedy loop works with any delay model that gives the gain of a single move, for example a table model. The posynomial argument then no longer holds.
When to use it
Use it as a fast first sizing of a circuit that misses its target by a moderate amount, when the sizes come from a small library and an optimal answer is not needed. It is simple to add to a timing engine, because it needs only the critical path and a local delay change. When area or power matters a lot, follow it with area recovery, or use an exact continuous method and round the result.
Pitfalls
- A gain that counts only the delay of the resized gate is wrong. A larger gate loads its fanins, and that change often cancels the gain, as gate 1 in the example shows.
- An earlier gate on the critical path can also be a direct fanin of the resized gate, not only its predecessor on the path. Its delay changes too.
- The critical path must be found again after each move; the old path may no longer be the longest.
- Failure does not mean that no sizing meets the target. Check the target against the delay with a better method before you report that it cannot be met.
- The sizes never go down, so the result depends on the start. Starting from larger sizes can give a different answer.
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/tilos/. The authors are listed in prov/Q10RHR.jsonl.
"""TILOS: greedy upsizing on the critical path (Fishburn and Dunlop, 1985).
The circuit is a DAG of gates 0..n-1 in topological order. Gate i has an
intrinsic delay p[i], a drive resistance r[i] / x for size x, an input
capacitance c[i] * x, an area a[i] * x, a fixed load f[i] (wire and, for an
output, the external load) and a list sizes[i] of allowed sizes in
increasing order. Its delay is
D_i = p[i] + r[i] / x_i * (f[i] + sum of c[j] * x_j over fanouts j),
an Elmore delay of a switch-level RC model. A gate without fanins starts at
time 0, the arrival time of a gate is the latest fanin arrival plus its own
delay, and the circuit delay is the latest arrival over all gates. All
arithmetic is exact with Fractions.
"""
from fractions import Fraction
class Circuit:
def __init__(self, fanin, p, r, c, a, f, sizes):
self.n = len(fanin)
self.fanin = [list(v) for v in fanin]
self.fanout = [[] for _ in range(self.n)]
for j, ins in enumerate(self.fanin):
for i in ins:
assert i < j # topological order
self.fanout[i].append(j)
self.p, self.r, self.c, self.a, self.f = p, r, c, a, f
self.sizes = [sorted(s) for s in sizes]
def gate_delay(ckt, x, i):
load = ckt.f[i] + sum(ckt.c[j] * x[j] for j in ckt.fanout[i])
return ckt.p[i] + Fraction(ckt.r[i]) / x[i] * load
def arrivals(ckt, x):
"""Arrival time of each gate and the fanin that sets it (or None)."""
arr, pred = [], []
for i in range(ckt.n):
best, who = Fraction(0), None
for k in ckt.fanin[i]:
if who is None or arr[k] > best:
best, who = arr[k], k
arr.append(best + gate_delay(ckt, x, i))
pred.append(who)
return arr, pred
def delay(ckt, x):
return max(arrivals(ckt, x)[0])
def area(ckt, x):
return sum(ckt.a[i] * x[i] for i in range(ckt.n))
def critical_path(ckt, x):
arr, pred = arrivals(ckt, x)
g = max(range(ckt.n), key=lambda i: (arr[i], -i))
path = []
while g is not None:
path.append(g)
g = pred[g]
return path[::-1]
def path_delay(ckt, x, path):
return sum(gate_delay(ckt, x, g) for g in path)
def tilos(ckt, target):
"""Return the sizes found by TILOS, or None if it gets stuck."""
x = [s[0] for s in ckt.sizes] # @line L1
step = [0] * ckt.n
while True:
if delay(ckt, x) <= target: # @line L2
return x
path = critical_path(ckt, x) # @line L3
best, best_ratio = None, None
on_path = set(path)
for g in path: # @line L4
if step[g] + 1 == len(ckt.sizes[g]):
continue
y = list(x)
y[g] = ckt.sizes[g][step[g] + 1]
# only g and its fanins change their delay
touched = [g] + [k for k in ckt.fanin[g] if k in on_path]
gain = path_delay(ckt, x, touched) - path_delay(ckt, y, touched) # @line L5
ratio = gain / (ckt.a[g] * (y[g] - x[g]))
if gain > 0 and (best is None or ratio > best_ratio): # @line L6
best, best_ratio = g, ratio
if best is None: # @line L7
return None
step[best] += 1 # @line L8
x[best] = ckt.sizes[best][step[best]]
test_tilos.py 98 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/tilos/. The authors are listed in prov/Q10RHR.jsonl.
import random
from fractions import Fraction
from itertools import product
from tilos import Circuit, area, critical_path, delay, path_delay, tilos
def brute_force(ckt, target):
"""Least area over every assignment of discrete sizes that meets target."""
best = None
for x in product(*ckt.sizes):
if delay(ckt, list(x)) <= target:
ar = area(ckt, list(x))
if best is None or ar < best:
best = ar
return best
def random_circuit(rng, n):
fanin = [[]] + [sorted(rng.sample(range(i), rng.randint(1, min(2, i)))) for i in range(1, n)]
p = [rng.randint(0, 2) for _ in range(n)]
r = [rng.randint(1, 3) for _ in range(n)]
c = [rng.randint(1, 2) for _ in range(n)]
a = [rng.randint(1, 3) for _ in range(n)]
has_fanout = {i for ins in fanin for i in ins}
f = [0 if i in has_fanout else rng.randint(4, 16) for i in range(n)]
sizes = [[1]] + [[1, 2, 3, 4] for _ in range(n - 1)] # gate 0 is a fixed driver
return Circuit(fanin, p, r, c, a, f, sizes)
def test_against_enumeration(rng=random.Random(1985)):
found = optimal = 0
for _ in range(250):
ckt = random_circuit(rng, rng.randint(2, 5))
slow = delay(ckt, [s[0] for s in ckt.sizes])
target = Fraction(rng.randint(1, int(slow) + 2))
best = brute_force(ckt, target)
x = tilos(ckt, target)
if best is None:
assert x is None # nothing meets the target, so TILOS cannot
continue
if x is not None:
found += 1
assert all(s in ckt.sizes[i] for i, s in enumerate(x))
assert delay(ckt, x) <= target
assert area(ckt, x) >= best # a heuristic: never below the optimum
optimal += area(ckt, x) == best
assert found > 50 and optimal > 0
def test_loose_target_keeps_minimum_sizes(rng=random.Random(7)):
for _ in range(50):
ckt = random_circuit(rng, 5)
x0 = [s[0] for s in ckt.sizes]
assert tilos(ckt, delay(ckt, x0)) == x0
def test_critical_path_is_longest(rng=random.Random(8)):
for _ in range(100):
ckt = random_circuit(rng, 5)
x = [rng.choice(s) for s in ckt.sizes]
path = critical_path(ckt, x)
assert path_delay(ckt, x, path) == delay(ckt, x)
assert ckt.fanin[path[0]] == []
assert all(path[k] in ckt.fanin[path[k + 1]] for k in range(len(path) - 1))
# the local gain of the implementation equals the change of the whole path
for g in path:
y = list(x)
y[g] += 1
whole = path_delay(ckt, x, path) - path_delay(ckt, y, path)
touched = [g] + [k for k in ckt.fanin[g] if k in path]
assert whole == path_delay(ckt, x, touched) - path_delay(ckt, y, touched)
def example():
return Circuit([[], [0], [1], [2]], [1, 1, 1, 1], [3, 1, 2, 3], [1, 1, 1, 1], [2, 1, 3, 1],
[0, 0, 0, 12], [[1], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]])
def test_example_of_the_page():
ckt = example()
assert delay(ckt, [1, 1, 1, 1]) == 46
x = tilos(ckt, 24)
assert x == [1, 1, 2, 4] and delay(ckt, x) == 22 and area(ckt, x) == 13
assert brute_force(ckt, 24) == 12
assert delay(ckt, [1, 1, 2, 3]) == 24 and area(ckt, [1, 1, 2, 3]) == 12
def test_failure_although_a_sizing_exists():
ckt = Circuit([[], [0], [1], [2]], [1, 1, 1, 1], [1, 3, 3, 1], [1, 1, 1, 1], [1, 1, 1, 1],
[0, 0, 0, 6], [[1], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]])
assert delay(ckt, [1, 1, 1, 1]) == 17
assert tilos(ckt, 16) is None # stuck at sizes (1, 2, 1, 1) with delay 33/2
assert delay(ckt, [1, 2, 1, 1]) == Fraction(33, 2)
assert delay(ckt, [1, 2, 2, 2]) == 15 and brute_force(ckt, 16) == 7
History
John Fishburn and Alfred Dunlop of AT&T Bell Laboratories presented TILOS at ICCAD 1985. They noted that under the Elmore model of a switch-level RC circuit the delay is a posynomial in the transistor sizes, so the continuous sizing problem has no local minimum that is not global, and they gave the greedy bumping rule as a fast way to a good solution. In 1993 Sapatnekar, Rao, Vaidya and Kang solved the same problem exactly by convex optimization and compared the results with TILOS. In 1999 Chen, Chu and Wong solved the gate and wire sizing form exactly by Lagrangian relaxation.
References
- John P. Fishburn and Alfred E. Dunlop, TILOS: a posynomial programming approach to transistor sizing, Proceedings of the IEEE International Conference on Computer-Aided Design (ICCAD), 326 to 328, 1985, the posynomial form of the Elmore delay and the greedy bumping of the transistor with the best sensitivity on the critical path
- Sachin S. Sapatnekar, Vasant B. Rao, Pravin M. Vaidya and Sung-Mo Kang, An exact solution to the transistor sizing problem for CMOS circuits using convex optimization, IEEE Transactions on Computer-Aided Design 12(11), 1621 to 1634, 1993, the convex formulation of the same problem and the measured comparison with TILOS
- Andrew B. Kahng, Jens Lienig, Igor L. Markov and Jin Hu, VLSI Physical Design, From Graph Partitioning to Timing Closure, Springer, 2011, Chapter 8, Timing Closure, Section 8.5.1, Gate Sizing
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 Q10RHR Edit this page History Report an error Markdown