Algorithm Search⌘K

Algorithmadvanced

Clock skew scheduling

Also called useful skew, Fishburn skew optimization, clock schedule optimization.

Fishburn's choice of clock arrival times at registers to shorten the clock period, a system of difference constraints solved by linear programming or cycle ratio.

Time
O(R n m) totalO(n^3 m Δ) integer_dataO(n m) per_round
Space
O(n + m) extra
Where
R = the number of rounds; m = the number of register-to-register paths; n = the number of registers; Δ = the least period minus the start period, for integer delays
Properties
deterministicexactiterative
Origin
John P. Fishburn, 1990

Clock skew scheduling chooses, for each register of a synchronous circuit, the time at which the clock edge reaches it, so that the clock period can be shorter than the longest path delay. The setup and hold constraints of every register-to-register path become difference constraints on these clock arrival times. John Fishburn stated the problem as a linear program in 1990. The least period is a cycle ratio of the constraint graph, and the page computes it exactly by raising the period to the ratio of each negative cycle that Bellman-Ford finds, until none is left.

In plain words

With a single clock, every register normally gets the clock edge at the same time. Then the clock period must be at least the slowest path between two registers. But some paths are fast and some are slow. If the clock reaches the end of a slow path a little later, that path gets more time, and the path that starts at that register gets less time. When the slow and the fast paths alternate, the clock period can go down.

There are limits. A path that is too fast can let the new data overwrite the old data before the next register has read it, so a register cannot be shifted too far. Each limit says that the clock time of one register minus that of another is at most some amount. A period works exactly when no loop of these limits adds up to a contradiction.

The problem

Registers are 1,…,n1, \ldots, n. A path pp from register ii to register jj has a largest delay dmax⁡(p)d_{\max}(p) and a smallest delay dmin⁡(p)d_{\min}(p), from the clock pin of ii to the data pin of jj. The registers have setup time tst_s and hold time tht_h. With clock arrival times c1,…,cnc_1, \ldots, c_n and period TT, each path must meet, in the notation of the setup and hold page with claunch=cic_{\text{launch}} = c_i and ccapture=cjc_{\text{capture}} = c_j,

ci+dmax⁡(p)+ts≤cj+T,ci+dmin⁡(p)≥cj+th.c_i + d_{\max}(p) + t_s \le c_j + T, \qquad c_i + d_{\min}(p) \ge c_j + t_h.

The task is the least TT for which some cc meets all constraints, and such a cc. The difference ci−cjc_i - c_j is the skew between the two registers. With all cic_i equal (zero skew), the least period is max⁡p(dmax⁡(p)+ts)\max_p (d_{\max}(p) + t_s), valid when every dmin⁡(p)≥thd_{\min}(p) \ge t_h.

Each constraint has the form cu−cv≤wc_u - c_v \le w. In the constraint graph it is an edge v→uv \to u of weight ww: a setup edge j→ij \to i of weight T−dmax⁡(p)−tsT - d_{\max}(p) - t_s and a hold edge i→ji \to j of weight dmin⁡(p)−thd_{\min}(p) - t_h. By the theorem of difference constraints, TT is valid if and only if no cycle has negative weight. A cycle CC with kCk_C setup edges has weight kCT−SCk_C T - S_C, where SCS_C is the sum of dmax⁡+tsd_{\max} + t_s over its setup edges minus the sum of dmin⁡−thd_{\min} - t_h over its hold edges. So the least period is the largest cycle ratio

T∗=max⁡C, kC≥1SCkC,T^* = \max_{C,\ k_C \ge 1} \frac{S_C}{k_C},

provided that no cycle of hold edges alone is negative; if one is, no period works. This is a fractional programming problem over the cycles of a graph.

The algorithm

  1. CLOCK-SKEW-SCHEDULE(registers, paths, t_s, t_h)
  2. 1if Bellman-Ford finds a negative cycle among the hold edges alone then return "no period works"
  3. 2T ← max over paths p of d_max(p) − d_min(p) + t_s + t_h
  4. 3loop
  5. 4run Bellman-Ford on the constraint graph at period T, from distance 0 at every node
  6. 5if no negative cycle is found then
  7. 6return T and c ← the distances, shifted so that the smallest is 0
  8. 7C ← the negative simple cycle found; k ← its number of setup edges; S ← k T − weight(C)
  9. 8T ← S / k

Line L2 is a lower bound: adding the setup and hold constraint of one path gives T≥dmax⁡−dmin⁡+ts+thT \ge d_{\max} - d_{\min} + t_s + t_h. Line L7 always has k≥1k \ge 1, because line L1 removed the case of a negative cycle with no setup edge. Line L8 raises TT to the value at which the cycle CC has weight exactly 0. This is the iteration of Dinkelbach applied to the cycle ratio: each round either proves the current period valid or finds a cycle with a larger ratio.

Example

Three registers R1,R2,R3R_1, R_2, R_3 have ts=th=1t_s = t_h = 1 and four paths:

path dmax⁡d_{\max} dmin⁡d_{\min} setup edge and weight hold edge and weight
R1→R2R_1 \to R_2 9 5 R2→R1R_2 \to R_1, T−10T - 10 R1→R2R_1 \to R_2, 44
R2→R3R_2 \to R_3 3 2 R3→R2R_3 \to R_2, T−4T - 4 R2→R3R_2 \to R_3, 11
R3→R1R_3 \to R_1 4 1 R1→R3R_1 \to R_3, T−5T - 5 R3→R1R_3 \to R_1, 00
R1→R3R_1 \to R_3 6 2 R3→R1R_3 \to R_1, T−7T - 7 R1→R3R_1 \to R_3, 11

With zero skew the period is 9+1=109 + 1 = 10. Line L2 starts at T=6T = 6, from the paths R1→R2R_1 \to R_2 and R1→R3R_1 \to R_3.

round TT negative cycle found kk SS new TT
1 6 setup edges R1→R3→R2→R1R_1 \to R_3 \to R_2 \to R_1 3 19 19/3
2 19/3 hold R1→R3R_1 \to R_3, setup R3→R2→R1R_3 \to R_2 \to R_1 2 13 13/2
3 13/2 none

The least period is T∗=13/2T^* = 13/2, with the schedule c=(0,7/2,1)c = (0, 7/2, 1). At this schedule the setup constraints of R1→R2R_1 \to R_2 (0+9+1=7/2+13/20 + 9 + 1 = 7/2 + 13/2) and R2→R3R_2 \to R_3 (7/2+3+1=1+13/27/2 + 3 + 1 = 1 + 13/2) and the hold constraint of R1→R3R_1 \to R_3 (0+2=1+10 + 2 = 1 + 1) are tight. These three form the critical cycle of round 2. The short path R1→R3R_1 \to R_3 stops the schedule from moving R3R_3 later, which would help the slow path R1→R2→R3R_1 \to R_2 \to R_3. Without the hold constraints the answer would be 19/319/3, the mean of dmax⁡+tsd_{\max} + t_s over the loop R1→R2→R3→R1R_1 \to R_2 \to R_3 \to R_1. The period drops from 10 to 6.5, by 35 percent, so the clock frequency can rise by a factor of 10/6.5≈1.5410 / 6.5 \approx 1.54.

Correctness

The proof is in proofs/correctness.md. By the theorem of difference constraints a period is valid exactly when no simple cycle of the constraint graph is negative, so the valid periods form the half line T≥T∗T \ge T^*. The start T0T_0 is at most T∗T^*, and each round moves TT to the ratio SC/kCS_C / k_C of a cycle that is negative at the current TT, which is larger than TT and at most T∗T^*. So T≤T∗T \le T^* holds all the time, and when Bellman-Ford finds no negative cycle, TT is valid, so T=T∗T = T^*. The distances of Bellman-Ford are a valid schedule.

Proof: Cycle ratio iteration returns the least clock period of a skew schedule and stopsfull

Registers are 1,…,n1, \ldots, n. Each path pp from register ii to register jj has delays dmin⁡(p)≤dmax⁡(p)d_{\min}(p) \le d_{\max}(p), and tst_s, tht_h are the setup and hold times. A schedule c∈Qnc \in \mathbb{Q}^n and a period TT are valid when every path meets

ci−cj≤T−dmax⁡(p)−ts(setup),cj−ci≤dmin⁡(p)−th(hold).c_i - c_j \le T - d_{\max}(p) - t_s \quad \text{(setup)}, \qquad c_j - c_i \le d_{\min}(p) - t_h \quad \text{(hold)}.

The constraint graph GG has the registers as nodes, for each path a setup edge j→ij \to i of weight T−dmax⁡(p)−tsT - d_{\max}(p) - t_s, and a hold edge i→ji \to j of weight dmin⁡(p)−thd_{\min}(p) - t_h. Each edge weight has the form aT+ba T + b with a∈{0,1}a \in \{0, 1\}. For a cycle CC of GG let kCk_C be its number of setup edges and bCb_C the sum of the constants bb, so its weight at period TT is wC(T)=kCT+bCw_C(T) = k_C T + b_C. Write SC=−bCS_C = -b_C.

Lemma 1 (validity and cycles). A period TT has a valid schedule if and only if wC(T)≥0w_C(T) \ge 0 for every simple cycle CC of GG.

Proof. This is the theorem of difference constraints. If cc is valid, each edge v→uv \to u of weight ww has cu−cv≤wc_u - c_v \le w, and the sum around a cycle telescopes to 0≤wC(T)0 \le w_C(T). Conversely, if no cycle is negative, add a node zz with an edge of weight 0 to every register. No cycle through zz exists, so shortest path distances δ\delta from zz are finite, and δ(u)≤δ(v)+w\delta(u) \le \delta(v) + w for every edge, so c=δc = \delta is valid. A closed walk of negative weight contains a simple cycle of negative weight, so simple cycles suffice. □\square

Lemma 2 (the set of valid periods). If some simple cycle CC has kC=0k_C = 0 and SC>0S_C > 0, no period is valid. Otherwise, and when there is at least one path, the valid periods are exactly the T≥T∗T \ge T^* with

T∗=max⁡{SCkC:C a simple cycle of G, kC≥1}.T^* = \max \Big\{ \frac{S_C}{k_C} : C \text{ a simple cycle of } G,\ k_C \ge 1 \Big\}.

Proof. A cycle with kC=0k_C = 0 has weight −SC-S_C for every TT, so the first case is clear by Lemma 1. In the other case the cycles with kC=0k_C = 0 never fail, and a cycle with kC≥1k_C \ge 1 holds if and only if T≥SC/kCT \ge S_C / k_C. A path pp from ii to j≠ij \ne i gives the 2-cycle of its two edges, with kC=1k_C = 1, and a path from ii to ii gives a setup loop with kC=1k_C = 1, so the maximum is over a nonempty finite set. □\square

Lemma 3 (the start is a lower bound). Let T0=max⁡p(dmax⁡(p)−dmin⁡(p)+ts+th)T_0 = \max_p (d_{\max}(p) - d_{\min}(p) + t_s + t_h). Then T0≤T∗T_0 \le T^*.

Proof. Take a valid pair (T∗,c)(T^*, c) and a path pp from ii to jj. Adding its setup and hold inequalities gives 0≤T∗−dmax⁡(p)−ts+dmin⁡(p)−th0 \le T^* - d_{\max}(p) - t_s + d_{\min}(p) - t_h. □\square

Lemma 4 (Bellman-Ford). With all distances set to 0 at the start, Bellman-Ford at a fixed TT either makes no change in some round among the first nn, and then the distances form a valid schedule, or it changes a distance in round nn, and then the walk back along the predecessor edges from that node reaches a simple cycle of negative weight.

Proof. The start with all distances 0 is the state after one round from the extra node zz of Lemma 1. A round with no change means every edge satisfies δ(u)≤δ(v)+w\delta(u) \le \delta(v) + w, which is validity. If no cycle is negative, every shortest path from zz has at most nn edges, so all distances are final after n−1n - 1 more rounds and round nn makes no change. If round nn makes a change, the standard argument of negative cycle detection applies: the predecessor graph then holds a cycle, every cycle of the predecessor graph has negative weight, and walking back nn steps from a node changed in round nn ends on that cycle. □\square

Theorem 1 (correctness). If the hold edges alone have a negative cycle, the algorithm returns that no period is valid, and this is true. Otherwise it returns T∗T^* and a valid schedule for T∗T^*.

Proof. The first part is Lemma 2, since a cycle of hold edges has kC=0k_C = 0, and Lemma 4 run on the hold edges finds such a cycle when there is one (their weights do not depend on TT). Now assume no such cycle. We show the invariant T≤T∗T \le T^*. It holds at the start by Lemma 3. Suppose Bellman-Ford finds a negative simple cycle CC at the current TT. Then kC≥1k_C \ge 1, since cycles with kC=0k_C = 0 are all hold cycles, which are not negative. So kCT−SC<0k_C T - S_C < 0, and the new period T′=SC/kCT' = S_C / k_C satisfies T<T′≤T∗T < T' \le T^*, the second by the definition of T∗T^*. When Bellman-Ford finds no negative cycle, TT is valid with the schedule of Lemma 4, so T≥T∗T \ge T^* by Lemma 2, and with the invariant T=T∗T = T^*. Subtracting the smallest distance from all of them keeps every difference, so the shifted schedule is valid and has min⁡c=0\min c = 0. □\square

Theorem 2 (termination). The loop stops after at most as many rounds as GG has simple cycles, plus one.

Proof. In each round that does not stop, the period becomes SC/kCS_C / k_C for the cycle CC found, and it only grows later. So in every later round wC(T)≥0w_C(T) \ge 0, and CC is not found again. GG has finitely many simple cycles. □\square

Theorem 3 (round bound for integer data). If all delays and the setup and hold times are integers, the number of rounds is at most 1+n2(T∗−T0)1 + n^2 (T^* - T_0), and each round takes O(nm)O(n m) time for mm paths.

Proof. Every period after the first is SC/kCS_C / k_C with SCS_C an integer and 1≤kC≤n1 \le k_C \le n, since a simple cycle has at most nn edges. Two distinct such values a/ka / k and a′/k′a' / k' differ by ∣ak′−a′k∣/(kk′)≥1/n2|a k' - a' k| / (k k') \ge 1 / n^2. The periods after the first round strictly increase and lie in (T0,T∗](T_0, T^*], so there are at most n2(T∗−T0)n^2 (T^* - T_0) of them. Bellman-Ford does nn rounds over 2m2m edges. □\square

Corollary (no hold constraints). If only the setup edges are present, every cycle consists of setup edges, so kCk_C is its length and T∗T^* is the largest mean of dmax⁡(p)+tsd_{\max}(p) + t_s over the cycles of paths. This is a maximum mean cycle, which Karp's algorithm finds in O(nm)O(n m) time after negating the weights.

Complexity

Each round is one run of Bellman-Ford over the 2m2m constraint edges, O(nm)O(n m) time. A cycle found in one round has weight at least 0 in every later round, so no cycle comes back, and the loop stops. For integer delays and setup and hold times, every ratio is S/kS / k with 1≤k≤n1 \le k \le n, two distinct ratios differ by at least 1/n21 / n^2, and the number of rounds is at most 1+n2(T∗−T0)1 + n^2 (T^* - T_0). This bound is pseudo-polynomial; the page does not claim a polynomial bound on the rounds of this iteration. Polynomial methods exist: a binary search on the answer with one Bellman-Ford test per step, ended by rounding to the nearest fraction with denominator at most nn, or parametric search. The extra space is O(n+m)O(n + m).

Properties

  • Exact. The returned period is the least valid period for the given delays, and the schedule meets every constraint at it.
  • Deterministic, with exact rational arithmetic.
  • The schedule is not unique. Any schedule of the polytope of valid schedules at T∗T^* works, and adding a constant to all cic_i changes nothing.
  • The least period is never more than the zero skew period when zero skew is valid, since zero skew is one choice of cc.
  • Without hold constraints, T∗T^* is the largest mean of dmax⁡+tsd_{\max} + t_s over the cycles of register-to-register paths, which Karp's algorithm finds in O(nm)O(n m) time after the weights are negated.

Variants and improvements

  • Linear program. Fishburn minimizes TT subject to the constraints, a linear program in n+1n + 1 variables. He also maximizes the smallest safety margin of all constraints at a fixed period, which gives a schedule more robust against delay variation.
  • Parametric shortest paths. Shenoy, Brayton and Sangiovanni-Vincentelli treat TT as the parameter of a parametric shortest path problem on the constraint graph.
  • Maximum mean cycle. Albrecht, Korte, Schietke and Vygen show that, with setup constraints only, the least period is a maximum mean weight cycle, and they study fast algorithms for it on the graphs of large chips.
  • Bounded skew windows. In practice each cic_i must lie in a window that the clock tree can deliver. A window li≤ci≤uil_i \le c_i \le u_i is two more difference constraints with a fixed reference node, so the same algorithm applies.

When to use it

Use it when the registers are fixed and the clock tree can be built to deliver chosen arrival times, and when the paths around a loop of registers are unbalanced. If the clock tree must have zero skew, use retiming instead, which moves the registers across the logic and keeps the clock; minimum-area retiming does so with the fewest registers. Both methods reduce to difference constraints, but retiming changes the circuit while skew scheduling changes only the clock times.

Pitfalls

  • Ignoring the hold constraints gives a shorter period that the circuit cannot use. In the example the setup constraints alone give 19/319/3, but no schedule meets the hold constraints at that period.
  • A cycle of hold edges alone with negative weight makes every period invalid. No skew can fix a race of that kind; the short paths must be made slower.
  • A schedule computed for nominal delays has zero margin on its critical cycle. Variation of the clock tree delays breaks it, so a schedule for a real chip keeps a margin, for example with Fishburn's second linear program at a period above T∗T^*.
  • The word "skew" here is the difference of clock arrival times at two registers of one chip. In distributed systems, clock skew means the offset between the clocks of two processes, a different idea.
  • Floating point Bellman-Ford can report a tiny negative cycle at T∗T^* itself and loop. Use exact rationals or stop when the increase of TT is below a tolerance.

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.

clock_skew_scheduling.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/clock-skew-scheduling/. The authors are listed in prov/K3PCDZ.jsonl.
"""Clock skew scheduling: the least clock period and a clock schedule.

Registers are 0 to n - 1. A path (i, j, dmax, dmin) is a combinational path
from register i to register j with largest delay dmax and smallest delay
dmin. With clock arrival times c, the period T is valid when every path has

    setup:  c_i + dmax + t_setup <= c_j + T
    hold:   c_i + dmin >= c_j + t_hold

Each is a difference constraint x_u - x_v <= w, an edge v -> u of weight w,
and the weight of an edge is a T + b with a in {0, 1}. The period T is valid
if and only if the graph has no negative cycle. The least valid period is
found by cycle ratio iteration: while Bellman-Ford finds a negative cycle at
the current T, raise T to the ratio at which that cycle has weight 0.

All arithmetic is exact with Fractions or integers.
"""

from fractions import Fraction


def constraint_edges(n, paths, t_setup, t_hold):
    """Edges (v, u, a, b) meaning c_u - c_v <= a T + b."""
    edges = []
    for i, j, dmax, dmin in paths:
        edges.append((j, i, 1, -(dmax + t_setup)))  # setup: c_i - c_j <= T - dmax - t_setup
        edges.append((i, j, 0, dmin - t_hold))  # hold: c_j - c_i <= dmin - t_hold
    return edges


def bellman_ford(n, edges, T):
    """Return (None, dist) when no cycle is negative at period T, else
    (cycle, None) with the edge indices of one negative simple cycle."""
    dist = [Fraction(0)] * n
    pred = [None] * n
    last = None
    for _ in range(n):
        last = None
        for k, (v, u, a, b) in enumerate(edges):
            w = a * T + b
            if dist[v] + w < dist[u]:
                dist[u] = dist[v] + w
                pred[u] = k
                last = u
        if last is None:
            return None, dist
    x = last
    for _ in range(n):
        x = edges[pred[x]][0]
    cycle, y = [], x
    while True:
        k = pred[y]
        cycle.append(k)
        y = edges[k][0]
        if y == x:
            break
    cycle.reverse()
    return cycle, None


def min_period(n, paths, t_setup=0, t_hold=0):
    """Return (T, c, rounds): the least clock period, a clock schedule that
    meets it with min(c) = 0, and the number of Bellman-Ford rounds. Return
    None when the hold constraints alone have a negative cycle, since then
    no period works."""
    edges = constraint_edges(n, paths, t_setup, t_hold)
    hold = [e for e in edges if e[2] == 0]
    cyc, _ = bellman_ford(n, hold, Fraction(0))
    if cyc is not None:  # @line L1
        return None
    if not paths:
        return Fraction(0), [Fraction(0)] * n, 0
    # start at the largest bound of a 2-cycle (the setup and hold edge of one path)
    T = max(Fraction(dmax - dmin + t_setup + t_hold) for _, _, dmax, dmin in paths)  # @line L2
    rounds = 0
    while True:  # @line L3
        rounds += 1
        cyc, dist = bellman_ford(n, edges, T)  # @line L4
        if cyc is None:  # @line L5
            low = min(dist)
            return T, [d - low for d in dist], rounds  # @line L6
        k = sum(edges[e][2] for e in cyc)  # @line L7
        s = -sum(edges[e][3] for e in cyc)
        T = Fraction(s, k)  # @line L8
test_clock_skew_scheduling.py 143 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/clock-skew-scheduling/. The authors are listed in prov/K3PCDZ.jsonl.

import random
from fractions import Fraction

from clock_skew_scheduling import constraint_edges, min_period


def simple_cycles(n, edges):
    """Every simple cycle of the multigraph, as a list of edge indices, each
    found once from its smallest node."""
    out = []
    adj = [[] for _ in range(n)]
    for k, (v, u, _, _) in enumerate(edges):
        adj[v].append((u, k))

    def dfs(start, v, seen, path):
        for u, k in adj[v]:
            if u == start:
                out.append(path + [k])
            elif u > start and u not in seen:
                seen.add(u)
                dfs(start, u, seen, path + [k])
                seen.discard(u)

    for s in range(n):
        dfs(s, s, {s}, [])
    return out


def exact_by_cycles(n, paths, ts, th):
    """The least period from the cycle condition: every cycle with k setup
    edges and constant part b needs k T + b >= 0."""
    edges = constraint_edges(n, paths, ts, th)
    best = None
    for cyc in simple_cycles(n, edges):
        k = sum(edges[e][2] for e in cyc)
        b = sum(edges[e][3] for e in cyc)
        if k == 0:
            if b < 0:
                return "infeasible"
        else:
            r = Fraction(-b, k)
            best = r if best is None or r > best else best
    return best


def negative_cycle_fw(n, paths, ts, th, T):
    """Independent test of a negative cycle at period T (Floyd-Warshall)."""
    INF = None
    d = [[INF] * n for _ in range(n)]
    for v, u, a, b in constraint_edges(n, paths, ts, th):
        w = a * T + b
        if d[v][u] is None or w < d[v][u]:
            d[v][u] = w
    for m in range(n):
        for i in range(n):
            if d[i][m] is None:
                continue
            for j in range(n):
                if d[m][j] is None:
                    continue
                w = d[i][m] + d[m][j]
                if d[i][j] is None or w < d[i][j]:
                    d[i][j] = w
    return any(d[i][i] is not None and d[i][i] < 0 for i in range(n))


def meets(paths, ts, th, T, c):
    return all(c[i] + dmax + ts <= c[j] + T and c[i] + dmin >= c[j] + th for i, j, dmax, dmin in paths)


def random_instance(rng, n, m):
    paths = []
    for _ in range(m):
        i, j = rng.randrange(n), rng.randrange(n)
        dmin = rng.randint(0, 6)
        paths.append((i, j, dmin + rng.randint(0, 6), dmin))
    return paths, rng.randint(0, 2), rng.randint(0, 2)


def test_against_cycle_enumeration(rng=random.Random(3141)):
    infeasible = 0
    for _ in range(400):
        n = rng.randint(1, 5)
        paths, ts, th = random_instance(rng, n, rng.randint(1, 7))
        want = exact_by_cycles(n, paths, ts, th)
        got = min_period(n, paths, ts, th)
        if want == "infeasible":
            assert got is None
            infeasible += 1
            continue
        T, c, _ = got
        assert T == want
        assert meets(paths, ts, th, T, c)
        assert min(c) == 0
        assert not negative_cycle_fw(n, paths, ts, th, T)
        assert negative_cycle_fw(n, paths, ts, th, T - Fraction(1, 1000))
    assert infeasible > 0


def test_grid_search_two_registers(rng=random.Random(27)):
    # with two registers a simple cycle has at most 2 setup edges, so the
    # optimum is a multiple of 1/2; search T and c_1 - c_0 on that grid
    for _ in range(60):
        paths, ts, th = random_instance(rng, 2, rng.randint(1, 4))
        got = min_period(2, paths, ts, th)
        bound = 2 * sum(dmax + ts + th + 1 for _, _, dmax, _ in paths)
        found = None
        for t2 in range(0, 2 * bound + 1):
            T = Fraction(t2, 2)
            for x2 in range(-2 * bound, 2 * bound + 1):
                if meets(paths, ts, th, T, [Fraction(0), Fraction(x2, 2)]):
                    found = T
                    break
            if found is not None:
                break
        if got is None:
            assert found is None
        else:
            assert got[0] == found


def test_zero_skew_period_is_an_upper_bound(rng=random.Random(5)):
    for _ in range(100):
        n = rng.randint(1, 5)
        paths, ts, th = random_instance(rng, n, rng.randint(1, 7))
        got = min_period(n, paths, ts, th)
        if got is None or any(dmin < th for _, _, _, dmin in paths):
            continue
        zero = max(dmax + ts for _, _, dmax, _ in paths)
        assert got[0] <= zero


def test_example_of_the_page():
    paths = [(0, 1, 9, 5), (1, 2, 3, 2), (2, 0, 4, 1), (0, 2, 6, 2)]
    T, c, rounds = min_period(3, paths, 1, 1)
    assert (T, c, rounds) == (Fraction(13, 2), [0, Fraction(7, 2), 1], 3)
    assert exact_by_cycles(3, paths, 1, 1) == T
    assert meets(paths, 1, 1, T, c)
    assert not meets(paths, 1, 1, Fraction(10) - Fraction(1, 100), [0, 0, 0])
    assert meets(paths, 1, 1, Fraction(10), [0, 0, 0])

History

Fishburn published clock skew optimization in IEEE Transactions on Computers in 1990, with the setup and hold constraints of each pair of registers and the linear program for the least period. Shenoy, Brayton and Sangiovanni-Vincentelli gave graph algorithms based on the constraint graph at ICCAD 1992. Albrecht, Korte, Schietke and Vygen presented the link to the maximum mean weight cycle at ICCAD 1999 and in the journal version in Discrete Applied Mathematics in 2002.

References

  1. John P. Fishburn, Clock skew optimization, IEEE Transactions on Computers 39(7), 945 to 951, 1990, the setup (zero clocking) and hold (double clocking) constraints on each pair of registers, and the linear program for the least period
  2. Narendra Shenoy, Robert K. Brayton and Alberto L. Sangiovanni-Vincentelli, Graph algorithms for clock schedule optimization, Proceedings of ICCAD 1992, 132 to 136, the constraint graph of the clock schedule and the parametric shortest path view of the least period
  3. Christoph Albrecht, Bernhard Korte, Jürgen Schietke and Jens Vygen, Maximum mean weight cycle in a digraph and minimizing cycle time of a logic chip, Discrete Applied Mathematics 123(1-3), 103 to 127, 2002, the least period as a maximum mean weight cycle when only the setup constraints are present

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 proofH1 sketch
  • a full proof of time.integer_data
  • a full proof of time.per_round
  • a full proof of time.total
  • a full proof of space.extra
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