Algorithm Search⌘K

Algorithmcore

Tsay's exact zero-skew algorithm

Also called exact zero skew clock routing, exact zero skew.

Tsay's bottom-up merge of subtrees that puts each tapping point where the Elmore delays to both sides are equal, so the whole tree has zero skew.

Time
Θ(n) given_topology
Space
Θ(n) extra
Where
n = the number of clock sinks
Properties
deterministicexactrecursive
Origin
Ren Song Tsay, 1991

Tsay's exact zero-skew algorithm is a clock routing algorithm: it builds a wire tree from a clock source to a set of sinks so that the Elmore delay from the root to every sink is exactly the same. It works bottom up over a given binary topology. To join two subtrees whose own skew is already zero, it computes the one point on the wire between their roots where the delays to both sides are equal, from a closed formula. When that point falls outside the wire, it puts the tap at the end of the slower subtree and makes the wire to the faster one longer than the distance. Ren-Song Tsay published it in 1991.

In plain words

A clock signal must reach every register at the same time. The clock wire forms a tree, and the delay to a register depends on the length of the wire and on the load that each piece of wire must charge.

Start with the registers as single points. Take two subtrees that the topology says to join. Each already has the same delay to all its own registers. Run a wire between their roots and find the point on it where the delay down to the left equals the delay down to the right. One formula gives this point. That point becomes the root of the joined subtree. If one side is much slower, even putting the point at its root is not enough, so the wire to the faster side is made longer, with a detour, until both match.

The problem

The input is a set of nn sinks with points psp_s in the plane and load capacitances cs>0c_s > 0, a full binary tree (the topology) whose leaves are the sinks, and the wire resistance rr and capacitance cc per unit length. Wires run horizontally and vertically, and a wire of length ℓ\ell is modeled as an RC interconnect tree edge in the pi model: a resistor rℓr \ell with cℓ/2c \ell / 2 at each end. The output is a point for each internal node of the topology and a wire length for each edge, such that the Elmore delay from the root to every sink is the same. This is the zero-skew case of clock tree synthesis.

Each subtree AA is summarized by its root point pAp_A, its total capacitance CAC_A and its delay tAt_A from pAp_A to each of its sinks. Two subtrees AA and BB with L=∣xA−xB∣+∣yA−yB∣>0L = |x_A - x_B| + |y_A - y_B| > 0 are merged at the tapping point at wire length xLx L from pAp_A, where

x=tB−tA+rL (CB+cL/2)rL (cL+CA+CB).x = \frac{t_B - t_A + r L \,(C_B + c L / 2)}{r L \,(c L + C_A + C_B)}.

The algorithm

  1. ZERO-SKEW(topology T, sinks, r, c)
  2. 1if T is a sink s then
  3. 2return subtree with point p_s, capacitance c_s, delay 0
  4. 3A ← ZERO-SKEW(left part of T); B ← ZERO-SKEW(right part of T)
  5. 4L ← L1 distance from p_A to p_B
  6. 5x ← (t_B − t_A + r L (C_B + c L / 2)) / (r L (c L + C_A + C_B))
  7. 6if 0 ≤ x ≤ 1 then ℓ_A ← x L; ℓ_B ← (1 − x) L; p ← the point at length ℓ_A from p_A on a shortest path to p_B
  8. 7else if x < 0 then ℓ_A ← 0; ℓ_B ← the root ℓ ≥ 0 of t_B + r ℓ (c ℓ / 2 + C_B) = t_A; p ← p_A
  9. 8else ℓ_B ← 0; ℓ_A ← the root ℓ ≥ 0 of t_A + r ℓ (c ℓ / 2 + C_A) = t_B; p ← p_B
  10. 9return subtree with point p, capacitance C_A + C_B + c (ℓ_A + ℓ_B), delay t_A + r ℓ_A (c ℓ_A / 2 + C_A)

The root in line L7 is ℓ=((rCB)2+2rc(tA−tB)−rCB)/(rc)\ell = (\sqrt{(r C_B)^2 + 2 r c (t_A - t_B)} - r C_B) / (r c) for c>0c > 0. Lines L7 and L8 are the wire elongation cases: the wire is longer than the distance it spans, so it is routed with a detour. When L=0L = 0 the two roots coincide, and the implementation goes to line L7 or L8 by comparing tAt_A and tBt_B. The tapping point in line L6 is any point at those two distances; the implementation takes the path that runs horizontally first.

Example

Take four sinks with r=c=1r = c = 1: s1=(5,7)s_1 = (5, 7) with load 3, s2=(2,0)s_2 = (2, 0) with load 2, s3=(6,2)s_3 = (6, 2) with load 1 and s4=(6,8)s_4 = (6, 8) with load 2, and the topology ((s1,s2),(s3,s4))((s_1, s_2), (s_3, s_4)).

merge LL xx ℓA\ell_A, ℓB\ell_B tapping point CC tt
s1s_1 with s2s_2 10 70/150=7/1570 / 150 = 7/15 14/314/3, 16/316/3 (2,16/3)(2, 16/3) 15 224/9224/9
s3s_3 with s4s_4 6 30/54=5/930 / 54 = 5/9 10/310/3, 8/38/3 (6,16/3)(6, 16/3) 9 80/980/9
the two results 4 28/112=1/428 / 112 = 1/4 11, 33 (3,16/3)(3, 16/3) 28 727/18727/18

In the first merge the tap is closer to s1s_1, the sink with the larger load: from s1s_1 the delay is 143(73+3)=2249\frac{14}{3}(\frac{7}{3} + 3) = \frac{224}{9}, and from s2s_2 it is 163(83+2)=2249\frac{16}{3}(\frac{8}{3} + 2) = \frac{224}{9}. In the last merge the left subtree is slower (224/9224/9 against 80/980/9), so the tap moves toward it: 2249+1⋅(12+15)=72718\frac{224}{9} + 1 \cdot (\frac{1}{2} + 15) = \frac{727}{18} and 809+3⋅(32+9)=72718\frac{80}{9} + 3 \cdot (\frac{3}{2} + 9) = \frac{727}{18}. The Elmore delay from the root to each of the four sinks, summed as ∑kRikCk\sum_k R_{ik} C_k over the whole pi model tree, is 727/18≈40.39727/18 \approx 40.39. No merge needs elongation, and the total wire length is 10+6+4=2010 + 6 + 4 = 20.

An elongation case: a subtree with CA=1C_A = 1 and tA=4t_A = 4 at (0,0)(0, 0) and a sink with load CB=1C_B = 1 at (1,0)(1, 0), with r=c=1r = c = 1. Then x=(0−4+1.5)/3<0x = (0 - 4 + 1.5) / 3 < 0, so the tap is at (0,0)(0, 0) and the wire to the sink has length 1+8−1=2\sqrt{1 + 8} - 1 = 2, twice the distance. Its delay is 2(1+1)=42 (1 + 1) = 4, as needed.

Correctness

The proof is in proofs/correctness.md. By the downstream form of the Elmore delay, a wire of length ℓ\ell above a subtree whose skew is zero adds rℓ(cℓ/2+C)r \ell (c \ell / 2 + C) to the delay of all its sinks, so the joined subtree has zero skew if and only if the two sides balance at the tap. The skew as a function of the tap position ss is tA−tB−rL(CB+cL/2)+rs(cL+CA+CB)t_A - t_B - r L (C_B + c L / 2) + r s (c L + C_A + C_B): the quadratic terms cancel, so it is linear and strictly increasing, with its only zero at s=xLs = x L. When x<0x < 0 the skew is positive over the whole wire, and the delay of the wire to BB grows without bound with its length, so a longer wire balances it.

Proof: Tsay's merge gives every subtree zero Elmore skew, and the tapping point formula is the unique balance pointfull

Wires have resistance r>0r > 0 and capacitance c≥0c \ge 0 per unit length, in the pi model: a wire of length ℓ\ell is a resistor rℓr \ell with a capacitor cℓ/2c \ell / 2 at each end. Every sink has a load cs>0c_s > 0. A subtree AA has a root point pAp_A, a total capacitance CAC_A (all its sink loads and wire capacitances) and a delay tAt_A. We say that AA is balanced when the Elmore delay from pAp_A to every sink of AA equals tAt_A. A single sink is balanced with t=0t = 0 and C=csC = c_s.

Lemma 1 (adding a wire above a subtree). Let AA be balanced, and connect a new point uu to pAp_A by a wire of length ℓ\ell. Then the Elmore delay from uu to every sink of AA is tA+rℓ(cℓ/2+CA)t_A + r \ell (c \ell / 2 + C_A).

Proof. Use the downstream form of the Elmore delay: the delay from uu to a sink ss is the sum, over the resistors on the path from uu to ss, of the resistance times the capacitance below it. The first resistor is rℓr \ell, and below it lie the capacitor cℓ/2c \ell / 2 at pAp_A and all of AA, so it adds rℓ(cℓ/2+CA)r \ell (c \ell / 2 + C_A). Every later resistor lies inside AA, and the capacitance below it is the same as in AA alone, because the new capacitors sit at uu and at pAp_A, which are above it. So the later resistors add the Elmore delay from pAp_A to ss in AA, which is tAt_A. The capacitor cℓ/2c \ell / 2 at uu is above the first resistor and adds nothing. □\square

Lemma 2 (the skew is linear in the tap position). Let AA and BB be balanced, at L1 distance L>0L > 0, and put the tapping point uu on a shortest rectilinear path between pAp_A and pBp_B, at wire length ss from pAp_A and L−sL - s from pBp_B, with 0≤s≤L0 \le s \le L. The skew f(s)f(s), the delay from uu to the sinks of AA minus that to the sinks of BB, is

f(s)=tA−tB−rL(CB+cL2)+rs (cL+CA+CB).f(s) = t_A - t_B - r L \Big( C_B + \frac{c L}{2} \Big) + r s \,(c L + C_A + C_B).

It is strictly increasing, and it is 0 only at s=xLs = x L with

x=tB−tA+rL(CB+cL/2)rL(cL+CA+CB).x = \frac{t_B - t_A + r L (C_B + c L / 2)}{r L (c L + C_A + C_B)}.

Proof. By Lemma 1, f(s)=tA+rs(cs/2+CA)−tB−r(L−s)(c(L−s)/2+CB)f(s) = t_A + r s (c s / 2 + C_A) - t_B - r (L - s)(c (L - s)/2 + C_B). The terms in s2s^2 are rcs2/2−rcs2/2=0r c s^2 / 2 - r c s^2 / 2 = 0. Collecting the rest: rc(L−s)2/2=rcL2/2−rcLs+rcs2/2r c (L - s)^2 / 2 = r c L^2 / 2 - r c L s + r c s^2 / 2 and r(L−s)CB=rLCB−rsCBr (L - s) C_B = r L C_B - r s C_B, which gives the formula. The coefficient of ss is r(cL+CA+CB)>0r (c L + C_A + C_B) > 0, since CA>0C_A > 0. Solving f(s)=0f(s) = 0 gives s=xLs = x L. □\square

Lemma 3 (elongation). In Lemma 2, if x<0x < 0, then f(s)>0f(s) > 0 for every s∈[0,L]s \in [0, L], so no tapping point on a shortest path between the roots balances the merge. With the tap at pAp_A and a wire of length

ℓ∗=(rCB)2+2rc(tA−tB)−rCBrc(c>0),ℓ∗=tA−tBrCB(c=0)\ell^* = \frac{\sqrt{(r C_B)^2 + 2 r c (t_A - t_B)} - r C_B}{r c} \quad (c > 0), \qquad \ell^* = \frac{t_A - t_B}{r C_B} \quad (c = 0)

from pAp_A to pBp_B, the merge is balanced, and ℓ∗>L\ell^* > L. The case x>1x > 1 is the mirror image, with the tap at pBp_B.

Proof. x<0x < 0 means f(0)>0f(0) > 0, and ff is increasing, so f>0f > 0 on [0,L][0, L]. With the tap at pAp_A, the sinks of AA have delay tAt_A, and by Lemma 1 the sinks of BB have delay g(ℓ)=tB+rℓ(cℓ/2+CB)g(\ell) = t_B + r \ell (c \ell / 2 + C_B). The function gg is continuous and strictly increasing on ℓ≥0\ell \ge 0, with g(L)=tA−f(0)<tAg(L) = t_A - f(0) < t_A and g(ℓ)→∞g(\ell) \to \infty. So g(ℓ)=tAg(\ell) = t_A has one root ℓ∗>L\ell^* > L. For c>0c > 0 the equation is rc2ℓ2+rCBℓ−(tA−tB)=0\frac{r c}{2} \ell^2 + r C_B \ell - (t_A - t_B) = 0, whose positive root is the formula, and for c=0c = 0 it is linear. A wire of length ℓ∗>L\ell^* > L between two points at distance LL is possible as a detour (a snaked wire). □\square

Theorem 1 (zero skew). Every subtree built by the algorithm is balanced, with the values CC and tt that the algorithm stores. So the whole tree has zero skew under the Elmore delay, and its delay from the root to every sink is tt at the root.

Proof. By induction on the topology. A sink is balanced. Let AA and BB be balanced and L=d(pA,pB)L = d(p_A, p_B). If L>0L > 0 and 0≤x≤10 \le x \le 1, Lemma 2 puts the tap at s=xLs = x L, a point at distance xLx L from pAp_A and (1−x)L(1 - x) L from pBp_B, and both sides have the same delay tA+rxL(cxL/2+CA)t_A + r x L (c x L / 2 + C_A). If x<0x < 0 or x>1x > 1, Lemma 3 gives the balanced merge with the stated wire lengths. If L=0L = 0, the tap is the common point. When tA≥tBt_A \ge t_B, the wire to BB gets the length ℓ∗\ell^* of Lemma 3: the same argument holds, since g(0)=tB≤tAg(0) = t_B \le t_A, and ℓ∗=0\ell^* = 0 when tA=tBt_A = t_B. The case tA<tBt_A < t_B is the mirror image. In all cases the new total capacitance is CA+CB+c(ℓA+ℓB)C_A + C_B + c (\ell_A + \ell_B), which the algorithm stores. □\square

Theorem 2 (wire use). When no merge needs elongation, each merge uses wire of length exactly d(pA,pB)d(p_A, p_B), the least length that joins the two roots, so the total wire is the sum of these distances. The tree is not always the shortest zero skew tree for the topology, because the roots of the subtrees are fixed when they are merged; deferred-merge embedding delays this choice.

Proof. The tap lies on a shortest path between the roots, at distances xLx L and (1−x)L(1 - x) L, which sum to LL. Any connected wiring that joins two points has length at least their L1 distance. □\square

Theorem 3 (time). For nn sinks and a given binary topology the algorithm does n−1n - 1 merges, each with O(1)O(1) arithmetic operations and at most one square root, so it runs in O(n)O(n) time in the real RAM model.

Proof. A binary tree with nn leaves has n−1n - 1 internal nodes, and each merge uses a constant number of operations on the stored values of its two children. □\square

Complexity

With the topology given, there are n−1n - 1 merges, each with a constant number of arithmetic operations and at most one square root, so the time is Θ(n)\Theta(n) and the extra space is Θ(n)\Theta(n) for the tree. Building the topology is a separate step; a recursive median split or a greedy pairing of near subtrees takes O(nlog⁡n)O(n \log n) or more.

Properties

  • Exact zero skew under the Elmore delay with the pi model, for every topology and every choice of sink loads.
  • Each merge with 0≤x≤10 \le x \le 1 uses exactly the distance between the two roots, the least wire that joins them.
  • The tree is not of least wire length for the topology. The root of each subtree is fixed when it is built, but the next merge would often be shorter from another root with the same delays. Deferred-merge embedding keeps all such roots as a segment and picks one later.

Variants and improvements

  • Linear delay. With the delay equal to the path length, the tap is at x=(tB−tA+L)/(2L)x = (t_B - t_A + L) / (2 L), the case that DME solves with least wire.
  • Topology generation. Tsay's merge needs a topology. It can come from the recursive split of the method of means and medians, or from a greedy matching that pairs near subtrees with similar delays, which aims to avoid elongations.
  • Bounded skew. If a small skew is allowed, the tap can be anywhere in an interval around xLx L, and the freedom can save wire in later merges.
  • Buffered trees. Real clock trees insert buffers at some merge points. The same balance equation holds when each buffer starts a new stage, with the buffer delay added to tt and its input capacitance in place of CC.

When to use it

Use it for a clock net with a known topology when the Elmore delay of the wires is an acceptable model, for example to build a zero-skew tree on top of a placement, or as the merge step inside a larger clock tree synthesis flow. When wire length matters, use DME on the same topology instead, which also gives zero skew. For a regular grid of sinks, an H-tree gives equal path lengths with no computation.

Pitfalls

  • The formula assumes that both subtrees already have zero skew. A subtree whose sinks have different delays must be fixed first.
  • If xx is outside [0,1][0, 1], clamping it to 0 or 1 without making the wire longer leaves a skew. The elongation of lines L7 and L8 is needed.
  • An elongation wastes wire and capacitance. Many elongations mean a poor topology that pairs subtrees with very different delays.
  • Zero Elmore skew is not zero real skew. The Elmore delay is an upper bound on the 50 percent delay, and the error differs from sink to sink.
  • The elongated length involves a square root, so it is irrational in general. Rounding it leaves a small skew; exact checks need exact or high precision arithmetic.

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.

tsay_zero_skew.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/tsay-zero-skew/. The authors are listed in prov/J8K07F.jsonl.
"""Tsay's exact zero-skew merge, bottom up over a given binary topology.

Wires have resistance r and capacitance c per unit length, in the pi model.
A sink is ((x, y), load capacitance). A topology is a sink index or a pair of
topologies. Each subtree is summarised by its root point, its total
capacitance C and its Elmore delay t from the root to every sink (the same
for all its sinks). Exact with Fractions, except when a wire must be longer
than the distance (elongation), where a square root appears: it is exact when
the number under the root is a square of a rational, else it is rounded to
about 60 decimal digits.
"""

from fractions import Fraction
from math import isqrt


class Node:
    def __init__(self, pt, cap, t, kids, sink=None):
        self.pt, self.cap, self.t, self.kids, self.sink = pt, cap, t, kids, sink


def l1(p, q):
    return abs(p[0] - q[0]) + abs(p[1] - q[1])


def sqrt_fraction(v, bits=200):
    """Exact root of a rational square, else a rational within 2^-bits."""
    v = Fraction(v)
    n, d = v.numerator, v.denominator
    rn, rd = isqrt(n), isqrt(d)
    if rn * rn == n and rd * rd == d:
        return Fraction(rn, rd)
    scale = 1 << (2 * bits)
    return Fraction(isqrt(n * scale // d), 1 << bits)


def point_along(p, q, s):
    """The point at L1 distance s from p on the path from p to q that runs
    horizontally first, then vertically."""
    dx = q[0] - p[0]
    if s <= abs(dx):
        return (p[0] + (s if dx >= 0 else -s), p[1])
    dy = q[1] - p[1]
    rest = s - abs(dx)
    return (q[0], p[1] + (rest if dy >= 0 else -rest))


def elongated(r, c, cap, dt):
    """Wire length L' >= 0 with r L' (c L' / 2 + cap) = dt, for dt >= 0."""
    if c == 0:
        return Fraction(dt) / (r * cap)
    disc = (r * cap) ** 2 + 2 * r * c * dt
    return (sqrt_fraction(disc) - r * cap) / (r * c)


def merge(a, b, r, c):
    """Join subtrees a and b at the tapping point of zero skew."""
    L = l1(a.pt, b.pt)  # @line L4
    if L > 0:
        x = (b.t - a.t + r * L * (b.cap + c * L / 2)) / (r * L * (c * L + a.cap + b.cap))  # @line L5
    else:
        x = Fraction(0) if a.t >= b.t else Fraction(1)
    if 0 <= x <= 1 and L > 0:  # @line L6
        la, lb = x * L, (1 - x) * L
        pt = point_along(a.pt, b.pt, la)
    elif x < 0 or (L == 0 and a.t >= b.t):  # @line L7
        la, lb = Fraction(0), elongated(r, c, b.cap, a.t - b.t)
        pt = a.pt
    else:  # @line L8
        la, lb = elongated(r, c, a.cap, b.t - a.t), Fraction(0)
        pt = b.pt
    t = a.t + r * la * (c * la / 2 + a.cap)  # @line L9
    return Node(pt, a.cap + b.cap + c * (la + lb), t, [(a, la), (b, lb)])


def zero_skew_tree(sinks, topo, r, c):
    """Return the root Node of the zero-skew tree on the given topology."""
    if not isinstance(topo, tuple):  # @line L1
        (x, y), load = sinks[topo]
        return Node((Fraction(x), Fraction(y)), Fraction(load), Fraction(0), [], sink=topo)  # @line L2
    left = zero_skew_tree(sinks, topo[0], r, c)  # @line L3
    right = zero_skew_tree(sinks, topo[1], r, c)
    return merge(left, right, r, c)


def wirelength(node):
    return sum(length + wirelength(k) for k, length in node.kids)
test_tsay_zero_skew.py 131 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/tsay-zero-skew/. The authors are listed in prov/J8K07F.jsonl.

import random
from fractions import Fraction

from tsay_zero_skew import Node, l1, merge, wirelength, zero_skew_tree


def elmore_to_sinks(root, r, c):
    """Elmore delay from the root to every sink as the sum of R_ik C_k over
    the pi model of all wires, with no use of the subtree summaries."""
    nodes, parent_path = [], {}
    cap = {}
    stack = [(root, ())]
    while stack:
        v, path = stack.pop()
        nodes.append(v)
        parent_path[id(v)] = path  # resistances of the edges from the root
        cap[id(v)] = cap.get(id(v), Fraction(0)) + (v.cap if v.sink is not None else 0)
        for k, length in v.kids:
            cap[id(v)] += c * length / 2
            cap[id(k)] = c * length / 2
            stack.append((k, path + ((id(k), r * length),)))
    out = {}
    for s in nodes:
        if s.sink is None:
            continue
        ps = dict(parent_path[id(s)])
        total = Fraction(0)
        for k in nodes:
            common = sum(res for e, res in parent_path[id(k)] if e in ps)
            total += common * cap[id(k)]
        out[s.sink] = total
    return out


def random_topology(rng, items):
    if len(items) == 1:
        return items[0]
    k = rng.randint(1, len(items) - 1)
    return (random_topology(rng, items[:k]), random_topology(rng, items[k:]))


def merges_elongate(node, r, c):
    """Does some merge of the tree need a wire longer than the distance?"""
    if not node.kids:
        return False
    (a, la), (b, lb) = node.kids
    return la + lb != l1(a.pt, b.pt) or merges_elongate(a, r, c) or merges_elongate(b, r, c)


def test_zero_skew_exact(rng=random.Random(80701)):
    exact_cases = 0
    for _ in range(150):
        n = rng.randint(1, 7)
        sinks = [((rng.randint(0, 12), rng.randint(0, 12)), rng.randint(1, 4)) for _ in range(n)]
        order = list(range(n))
        rng.shuffle(order)
        topo = random_topology(rng, order)
        r, c = Fraction(rng.randint(1, 3)), Fraction(rng.randint(1, 3))
        root = zero_skew_tree(sinks, topo, r, c)
        delays = elmore_to_sinks(root, r, c)
        assert set(delays) == set(range(n))
        for s in delays:
            if merges_elongate(root, r, c):
                assert abs(delays[s] - root.t) < Fraction(1, 10**40)
            else:
                assert delays[s] == root.t
        if not merges_elongate(root, r, c):
            exact_cases += 1
            # without elongation each merge uses exactly the distance between the roots
            def check(v):
                if v.kids:
                    (a, la), (b, lb) = v.kids
                    assert la + lb == l1(a.pt, b.pt)
                    assert l1(v.pt, a.pt) == la and l1(v.pt, b.pt) == lb
                    check(a)
                    check(b)
            check(root)
        assert wirelength(root) >= 0
    assert exact_cases > 50


def test_tap_point_against_grid(rng=random.Random(12)):
    # the skew at a tap s along the wire grows strictly with s, so a grid search
    # sees one sign change, at the tap of Tsay's formula
    for _ in range(200):
        r, c = Fraction(rng.randint(1, 3)), Fraction(rng.randint(1, 3))
        a = Node((Fraction(rng.randint(0, 9)), Fraction(rng.randint(0, 9))), Fraction(rng.randint(1, 9)), Fraction(rng.randint(0, 60)), [])
        b = Node((Fraction(rng.randint(0, 9)), Fraction(rng.randint(0, 9))), Fraction(rng.randint(1, 9)), Fraction(rng.randint(0, 60)), [])
        L = l1(a.pt, b.pt)
        if L == 0:
            continue
        m = merge(a, b, r, c)
        (_, la), (_, lb) = m.kids

        def skew(s):
            return (a.t + r * s * (c * s / 2 + a.cap)) - (b.t + r * (L - s) * (c * (L - s) / 2 + b.cap))

        grid = [L * Fraction(j, 64) for j in range(65)]
        signs = [skew(s) for s in grid]
        assert all(x < y for x, y in zip(signs, signs[1:]))
        if la + lb == L:
            assert skew(la) == 0
            assert all((s < la) == (skew(s) < 0) for s in grid if s != la)
        else:
            assert all(x > 0 for x in signs) or all(x < 0 for x in signs)


def test_exact_elongation():
    r = c = Fraction(1)
    a = Node((Fraction(0), Fraction(0)), Fraction(1), Fraction(4), [])
    b = Node((Fraction(1), Fraction(0)), Fraction(1), Fraction(0), [])
    m = merge(a, b, r, c)
    (_, la), (_, lb) = m.kids
    assert (la, lb, m.pt, m.t) == (0, 2, (0, 0), 4)
    assert m.cap == 1 + 1 + 2


def test_example_of_the_page():
    sinks = [((5, 7), 3), ((2, 0), 2), ((6, 2), 1), ((6, 8), 2)]
    r, c = Fraction(1), Fraction(1)
    root = zero_skew_tree(sinks, ((0, 1), (2, 3)), r, c)
    (left, ll), (right, lr) = root.kids
    assert left.pt == (2, Fraction(16, 3)) and left.t == Fraction(224, 9) and left.cap == 15
    assert right.pt == (6, Fraction(16, 3)) and right.t == Fraction(80, 9) and right.cap == 9
    assert (ll, lr, root.pt, root.t, root.cap) == (1, 3, (3, Fraction(16, 3)), Fraction(727, 18), 28)
    assert wirelength(root) == 20
    delays = elmore_to_sinks(root, r, c)
    assert set(delays.values()) == {Fraction(727, 18)}

History

Ren-Song Tsay presented exact zero skew at ICCAD 1991 and in IEEE Transactions on Computer-Aided Design in 1993. Before it, clock routers such as the method of means and medians of Jackson, Srinivasan and Kuh (1990) balanced path lengths, which does not give zero skew in general. In 1992 Chao, Hsu, Ho, Boese and Kahng gave deferred-merge embedding, which keeps Tsay's balance and lowers the wire length for a fixed topology.

References

  1. Ren-Song Tsay, An exact zero-skew clock routing algorithm, IEEE Transactions on Computer-Aided Design 12(2), 242 to 249, 1993, the tapping point formula under the Elmore delay, the wire elongation when the point falls outside the segment, and the bottom-up merge
  2. Ren-Song Tsay, Exact zero skew, Proceedings of ICCAD 1991, 336 to 339, the conference version of the method
  3. Andrew B. Kahng, Jens Lienig, Igor L. Markov and Jin Hu, VLSI Physical Design, From Graph Partitioning to Timing Closure, Springer, 2011, Chapter 7, Specialized Routing, Section 7.5.1, Constructing Trees with Zero Global Skew (exact zero skew)
  4. Ting-Hai Chao, Yu-Chin Hsu, Jan-Ming Ho, Kenneth D. Boese and Andrew B. Kahng, Zero skew clock routing with minimum wirelength, IEEE Transactions on Circuits and Systems II 39(11), 799 to 814, 1992, the comparison with deferred-merge embedding, which keeps zero skew and uses less wire for the same topology

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.

LadderLevelWhat the next level needs
Human proofH2 full proof
  • correctness: no review record reviews/J8K07F/proof-correctness.yaml
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
  • a scene preset for the example