Algorithmadvanced
Statistical static timing analysis
Also called SSTA.
Propagates delays as random variables, often linear in shared Gaussian sources of variation, through the timing graph by sum and statistical max.
- Solves
- Longest path problem
- Time
- Θ((V + E) m) worst · average · best
- Space
- Θ(V m) extra
- Where
- E = the number of edges; V = the number of vertices (pins) of the timing graph; m = the number of global sources of variation
- Model
- Real RAM
- Properties
- deterministicnot exactiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Chandu Visweswariah, Kaushik Ravindran, Kerim Kalafala, Steven G. Walker, Sambasivan Narayan, 2004
Statistical static timing analysis (SSTA) is static timing analysis in which the delays are random variables instead of numbers. Variations of the manufacturing process, such as the gate length or the oxide thickness, change all delays on a chip together, and random effects change each gate on its own. In the block-based method of Visweswariah and his colleagues (2004), each delay and each arrival time is a linear function of a few shared standard normal sources and one private normal term, the canonical form. The forward pass adds forms along the edges and combines the in-edges at a vertex by a statistical max, which uses Clark's (1961) formulas for the max of two Gaussians. The pass is linear in the size of the timing graph. The sum is exact. The max keeps the mean, the variance and the correlations, but the true max is not Gaussian, so the result is an approximation.
In plain words
Plain STA asks how late a signal can arrive. On a real chip, the delays change from chip to chip, and many of them change together. SSTA asks for the distribution of the arrival time: its mean, its spread and how it moves with each shared cause of variation.
Each delay is written as "mean plus some amount of each shared cause plus some private noise". Adding two delays adds these amounts. Taking the later of two arrivals is harder, because the later of two bell curves is not a bell curve. SSTA replaces it by the bell curve that has the same mean and the same spread, and that depends on each shared cause the same way. At the end, the distribution at an output gives the fraction of chips that meet the clock period.
The problem
The input is a timing graph that is a DAG, a canonical form for each edge delay and for the arrival time at each start point, all over the same global sources . A canonical form is
where the and are independent standard normal variables, and is private: it is independent of the private term of every other form. So and . The sources often come from a principal component analysis of correlated parameters, which makes them independent.
The true arrival time at is the random variable over all paths from a start point to , as in the longest path problem, but with random delays. The goal is its distribution, or at least its mean, its variance and its covariance with each , and from these the timing yield at each endpoint for a clock period .
The algorithm
SSTA(G, d, AT0)- 1
order ← a topological order of G (stop with an error if G has a cycle) - 2
for each vertex v in order do - 3
if v has no in-edge then AT(v) ← AT0(v) - 4
else for each in-edge (u, v), in a fixed order, do S ← ADD(AT(u), d(u, v)) - 5
AT(v) ← S for the first in-edge, else MAX(AT(v), S) - 6
return AT ADD(A, B)- 7
c_i ← a_i + b_i for i = 1 .. m - 8
return (μ_A + μ_B, c, sqrt(r_A² + r_B²)) MAX(A, B)- 9
if θ² = σ_A² + σ_B² − 2 Σ a_i b_i is 0 then - 10
return A if μ_A ≥ μ_B else B ▷ A − B is a constant - 11
θ ← sqrt(θ²); α ← (μ_A − μ_B) / θ - 12
T ← Φ(α) ▷ tightness probability P(A > B) - 13
μ ← μ_A T + μ_B (1 − T) + θ φ(α) - 14
s ← (μ_A² + σ_A²) T + (μ_B² + σ_B²)(1 − T) + (μ_A + μ_B) θ φ(α) - 15
c_i ← T a_i + (1 − T) b_i for i = 1 .. m - 16
r ← sqrt(s − μ² − Σ c_i²) ▷ the variance is matched - 17
return (μ, c, r)
Here and are the standard normal distribution function and density. Line L13 is Clark's mean of and line L14 its second moment. Line L15 is the covariance of with , which Clark's formula gives as the tightness-weighted mix of the two inputs. Line L16 puts the rest of the variance into the private term. The timing yield of an endpoint is for its form.
Example
Two independent standard normals. For in distribution, standard normal and independent (, ): , , , and line L13 gives . Line L14 gives , so the variance is . These are the exact mean and variance of the max of two independent standard normals.
A diamond with one global source. Vertex 0 has arrival time 0 and two paths lead to vertex 3, through 1 and through 2. The edge delays are , , and , where each is a different private variable.
| step | form | std. dev. |
|---|---|---|
| L4 on | 0.7 | |
| L4 on | 0.6708 | |
| L11 | , , | |
| L12 | ||
| L13 to L17 | 0.6288 |
STA with the mean delays gives 5.1. The mean of the max is larger, 5.3235, because a max of random variables has a mean at least the max of the means (Jensen's inequality). Path is the later one with probability 0.44, although its mean is smaller, because it has the larger spread. Here only one max is taken, of two path sums with separate private terms, so the mean, the variance and the coefficient of are exact (see Correctness). A Monte Carlo run with 200000 samples (Python random.Random(7)) gives mean 5.3246 and standard deviation 0.6285, within its sampling error. The shape is not exact: the timing yield at is 0.6105 from the form and 0.6129 from Monte Carlo; at both are 0.859.
Correctness
The proof shows the following.
- Clark's formulas. For jointly Gaussian and , lines L12 to L15 give exactly , the mean and the second moment of , and its covariance with every .
- The max form matches the first two moments. The value under the root in line L16 is never negative, by Bessel's inequality, and the form has the mean, the variance and the covariances with the of the true max of its two inputs. If , the max is exact.
- The sum is exact. ADD gives the exact joint distribution of and the .
- Chains are exact. If no vertex has two in-edges, every arrival time is exact.
- No variation gives STA. With all coefficients 0, the algorithm is static timing analysis.
What is not proved is how close the result is on a general DAG. Two approximations add up there: each max is replaced by a Gaussian, and the private terms of later forms are taken as independent although they share earlier ones. As a measurement only: on 60 random DAGs with 4 to 8 vertices, 1 to 3 global sources and edge delays with means from 1 to 4 and coefficients up to 0.5 (seed 1), the mean of the endpoint form was within 0.05 standard deviations of a Monte Carlo estimate with 4000 samples, and its standard deviation within 0.04 standard deviations. The tests use a tolerance of 0.12 standard deviations with 3000 samples.
Proof: The canonical sum is exact, and Clark's statistical max keeps the mean, the variance and the covariance with each global source of the true max of two Gaussian inputsfull
Setting. Let be independent standard normal variables (the global sources). A canonical form is a random variable
where and is a standard normal variable that is independent of and of the private variables of all other canonical forms in use. Its variance is , and . For two canonical forms and with coefficients and , the pair is jointly Gaussian with . Write and for the standard normal distribution function and density.
What is proved here is a statement about each operation on Gaussian inputs. The statement that the arrival times of a whole DAG are close to the true distributions is not proved; the algorithm page reports it as a measurement.
Lemma 1 (truncated moments). Let with standard normal, , and let . Then
Proof. if and only if , which has probability . Since , we get , and by parts . With and the symmetry of , the first moment gives . For the second, , and , which gives the formula.
Lemma 2 (regression on ). Let be jointly Gaussian with . Then with , where has mean 0 and is independent of . Consequently, for every function with and , .
Proof. is Gaussian with mean 0 and . Jointly Gaussian variables with covariance 0 are independent. Then , which gives the second claim.
Lemma 3. With as in Lemma 1 and , .
Proof. . By Lemma 1, . Subtracting times this from the third formula of Lemma 1 leaves .
Theorem 1 (Clark 1961). Let be jointly Gaussian with means , variances and covariance , with . Let , and . Then and
and for every such that is jointly Gaussian,
Proof. Let , so , and . Then by Lemma 1.
Mean: by Lemma 1, which is the formula.
Covariance: . By Lemmas 2 and 3, . Adding gives the formula.
Second moment: . Here . By the covariance formula with applied to , , so . By Lemma 1, . Collect terms. The terms with are . The terms with are times
With from , this is the formula.
Theorem 2 (the canonical max). Let and be canonical forms with , and let be the form built in lines L11 to L17: mean and second moment from Theorem 1, coefficients and . Then the expression under the root is non-negative, and has the same mean, the same variance and the same covariance with each as . If , lines L9 and L10 return itself.
Proof. Each is jointly Gaussian, so by Theorem 1 with , . The are orthonormal in the space of square-integrable variables with the covariance as inner product, so Bessel's inequality gives . So is real. Then , and . If , then has variance 0, so it is the constant , and is when and otherwise.
The form is Gaussian and is not, unless or one input almost surely exceeds the other. This is the only approximation of a single max step. A second one comes from the model: the private term of is treated as independent of all other private terms, although depends on the private terms of and . On a DAG with reconvergent paths, both effects add up, and no bound on the total error is proved here.
Theorem 3 (the sum). For canonical forms and , the form of lines L7 and L8, with mean , coefficients and private coefficient , has the same distribution as , and the same joint distribution with .
Proof. . The last term is Gaussian with mean 0 and variance , and independent of the , so it has the same distribution as for a new standard normal that is independent of the .
Theorem 4 (chains are exact). Suppose every vertex of the DAG has at most one in-edge, the start arrival times and the edge delays are canonical forms, and the private variables of all of them are independent. Then the arrival time that the algorithm computes at each vertex has the same joint distribution with as the true arrival time, the sum of the delays on the unique path from a start point.
Proof. With one in-edge per vertex, line L5 never calls MAX. By induction along the topological order, the true arrival time at is , where depends only on the private variables of the edges on the path to and of its start point, which are independent of the private variable of . Theorem 3 applies at each step.
The same argument shows that the algorithm is exact in mean, variance and covariance with each at a vertex where only one max is taken, of two path sums whose private variables are disjoint, as in the diamond example of the algorithm page.
Theorem 5 (no variation gives STA). If all coefficients and all private terms are 0, the algorithm computes the arrival times of static timing analysis.
Proof. All forms are constants. ADD adds the means. In MAX, , so lines L9 and L10 return the input with the larger mean, which is the max of two numbers. So lines L2 to L5 are lines L2 to L4 of STA.
Theorem 6 (running time). On a timing graph with vertices, edges and global sources, the algorithm takes arithmetic operations and evaluations of , and the square root, and extra space for the forms.
Proof. The topological order takes . Each edge is used once in line L4 and at most once in line L5, and ADD and MAX each take operations and a constant number of function evaluations. Each vertex stores one form of size .
Complexity
- Time. Line L1 takes . Each edge causes one ADD and at most one MAX, each with operations and a constant number of evaluations of , and the square root. In total , compared with for STA.
- Space. One form of numbers per vertex, .
- Comparison with Monte Carlo. A Monte Carlo analysis runs STA once per sample, so samples cost . Its error falls like , so thousands of samples are needed for the tails. SSTA does one pass.
Properties
- Approximate, not a bound. The result is not an upper bound on the true distribution, and it is not exact on a DAG with reconvergent paths. In practice its error is small compared with the spread of the delays, as the measurement above shows.
- Correlations are kept. Since each form keeps its coefficients of the global sources, reconvergent paths that share variation are not treated as independent, and the arrival times at different endpoints stay correlated. This is what makes the yield of a whole chip computable.
- Order of the in-edges. MAX of three or more forms is done in pairs, and the result depends slightly on the order.
- Block-based. Like STA, the cost does not depend on the number of paths, and the analysis can be updated incrementally after a change.
Variants and improvements
- Required times and criticality. A backward pass with a statistical min gives required times and slacks as forms. The tightness probabilities of line L12, multiplied along paths, give the probability that each edge is on the critical path (the criticality), which guides optimization.
- Path-based SSTA. Enumerate the worst paths of STA and compute the distribution of each path delay exactly as a sum, then the max over the few paths. This avoids the errors of repeated max steps but may miss paths.
- Non-Gaussian and non-linear models. Quadratic canonical forms, or forms with non-Gaussian sources, follow strongly non-linear delays better, at a higher cost per operation.
- Monte Carlo. Sampling the sources and running STA per sample is the reference method. It is exact in the limit and costly.
- Statistical libraries. The coefficients of the cell delays come from libraries with sensitivities or standard deviations next to each table of a nonlinear delay model.
When to use it
- When the variation of the delays is large compared with the margins, so that corner-based STA, which assumes every delay at its worst value at once, is too pessimistic or misses correlations.
- To estimate the timing yield of a design and to find the edges that are most often critical.
- Not when a guaranteed bound is required. Sign-off with STA at corners gives bounds under its assumptions, and SSTA gives an estimate of a distribution.
Pitfalls
- Reading the result as exact. The max of Gaussians is not Gaussian. Far in the tails, where yield is decided, the error of the shape can matter even when the mean and the variance are right.
- Ignoring correlation. Treating all delays as independent makes the variance of long paths far too small and the yield far too high. The global sources in the forms are there to prevent this.
- Clamping. In exact arithmetic the value in line L16 is not negative. With rounding it can be a tiny negative number, so implementations clamp it at 0; a large negative value means a bug.
- Mixing modes. The hold check needs a statistical min of early arrival times, with the same care about correlation, not the late forms.
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/statistical-static-timing-analysis/. The authors are listed in prov/XMR9Q0.jsonl.
import math
from collections import deque
from typing import Mapping, NamedTuple, Sequence
class Canonical(NamedTuple):
"""A delay or arrival time in first-order canonical form.
The value is mean + sum(coeffs[i] * Z_i) + rand * R, where the Z_i are the
shared (global) sources of variation and R is a private source. All of
them are independent standard normal variables, and R is independent of
the private source of every other canonical form.
"""
mean: float
coeffs: tuple
rand: float
def variance(self) -> float:
return sum(c * c for c in self.coeffs) + self.rand * self.rand
def std(self) -> float:
return math.sqrt(self.variance())
def constant(value: float, m: int) -> Canonical:
return Canonical(float(value), (0.0,) * m, 0.0)
def pdf(x: float) -> float:
return math.exp(-0.5 * x * x) / math.sqrt(2.0 * math.pi)
def cdf(x: float) -> float:
return 0.5 * (1.0 + math.erf(x / math.sqrt(2.0)))
def add(a: Canonical, b: Canonical) -> Canonical:
"""Sum of two canonical forms. Exact: means and coefficients add, and the
private parts are independent, so their variances add."""
coeffs = tuple(x + y for x, y in zip(a.coeffs, b.coeffs)) # @line L7
return Canonical(a.mean + b.mean, coeffs, math.hypot(a.rand, b.rand)) # @line L8
def clark_max(a: Canonical, b: Canonical):
"""Statistical max of two canonical forms by Clark's formulas.
Returns (c, t) where c is the canonical form and t the tightness
probability P(A > B). The mean, the variance and the covariance with
every global source are those of the true max(A, B) of the two Gaussian
inputs; only the shape (Gaussian) is an approximation.
"""
cov = sum(x * y for x, y in zip(a.coeffs, b.coeffs))
va, vb = a.variance(), b.variance()
theta2 = va + vb - 2.0 * cov
if theta2 <= 1e-300: # @line L9
# A - B is a constant, so the max is exactly the one with the larger mean.
return (a, 1.0) if a.mean >= b.mean else (b, 0.0) # @line L10
theta = math.sqrt(theta2) # @line L11
alpha = (a.mean - b.mean) / theta
t = cdf(alpha) # @line L12
p = pdf(alpha)
mean = a.mean * t + b.mean * (1.0 - t) + theta * p # @line L13
second = (a.mean ** 2 + va) * t + (b.mean ** 2 + vb) * (1.0 - t) + (a.mean + b.mean) * theta * p # @line L14
coeffs = tuple(t * x + (1.0 - t) * y for x, y in zip(a.coeffs, b.coeffs)) # @line L15
rest = second - mean * mean - sum(c * c for c in coeffs)
rand = math.sqrt(max(0.0, rest)) # @line L16
return Canonical(mean, coeffs, rand), t # @line L17
def topological_order(n: int, edges: Sequence[tuple]) -> list:
"""Kahn's algorithm. Raises ValueError if the graph has a cycle."""
indeg = [0] * n
out = [[] for _ in range(n)]
for u, v, _ in edges:
out[u].append(v)
indeg[v] += 1
queue = deque(v for v in range(n) if indeg[v] == 0)
order = []
while queue:
u = queue.popleft()
order.append(u)
for v in out[u]:
indeg[v] -= 1
if indeg[v] == 0:
queue.append(v)
if len(order) != n:
raise ValueError("the timing graph has a cycle")
return order
def statistical_static_timing_analysis(
n: int,
edges: Sequence[tuple],
at_start: Mapping[int, Canonical],
) -> list:
"""Block-based SSTA: the canonical arrival time of every vertex.
The vertices are 0 .. n-1, each edge is (u, v, d) with d a Canonical, and
at_start gives the canonical arrival time of every vertex with no in-edge.
In-edges are combined in the order in which they appear in edges.
"""
order = topological_order(n, edges) # @line L1
into = [[] for _ in range(n)]
for u, v, d in edges:
into[v].append((u, d))
at = [None] * n
for v in order: # @line L2
if not into[v]:
if v not in at_start:
raise ValueError("no arrival time for start point %d" % v)
at[v] = at_start[v] # @line L3
continue
x = None
for u, d in into[v]:
s = add(at[u], d) # @line L4
x = s if x is None else clark_max(x, s)[0] # @line L5
at[v] = x
return at # @line L6
def timing_yield(x: Canonical, deadline: float) -> float:
"""P(X <= deadline) under the Gaussian form of X."""
sd = x.std()
if sd == 0.0:
return 1.0 if x.mean <= deadline else 0.0
return cdf((deadline - x.mean) / sd)
test_statistical_static_timing_analysis.py 208 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/statistical-static-timing-analysis/. The authors are listed in prov/XMR9Q0.jsonl.
import math
import random
import pytest
from statistical_static_timing_analysis import (
Canonical,
add,
cdf,
clark_max,
constant,
pdf,
statistical_static_timing_analysis,
timing_yield,
)
def sample(x, z, rng):
"""One sample of canonical form x for the global values z and a fresh private value."""
return x.mean + sum(c * zi for c, zi in zip(x.coeffs, z)) + x.rand * rng.gauss(0.0, 1.0)
def monte_carlo(n, edges, at_start, m, samples, rng, target):
"""Sample every delay and compute the exact longest path to target per sample.
The vertices are numbered in topological order."""
into = [[] for _ in range(n)]
for u, v, d in edges:
into[v].append((u, d))
values = []
for _ in range(samples):
z = [rng.gauss(0.0, 1.0) for _ in range(m)]
at = [0.0] * n
for v in range(n):
if not into[v]:
at[v] = sample(at_start[v], z, rng)
else:
at[v] = max(at[u] + sample(d, z, rng) for u, d in into[v])
values.append(at[target])
mu = sum(values) / samples
sd = math.sqrt(sum((x - mu) ** 2 for x in values) / (samples - 1))
return mu, sd, values
def random_dag(rng, n, m, spread):
edges = []
for v in range(1, n):
for u in rng.sample(range(v), min(v, rng.randint(1, 3))):
d = Canonical(rng.uniform(1.0, 4.0), tuple(rng.uniform(0.0, spread) for _ in range(m)),
rng.uniform(0.0, spread))
edges.append((u, v, d))
return edges
def test_max_of_two_independent_standard_normals():
c, t = clark_max(Canonical(0.0, (), 1.0), Canonical(0.0, (), 1.0))
assert t == pytest.approx(0.5)
assert c.mean == pytest.approx(1.0 / math.sqrt(math.pi), abs=1e-12)
assert c.variance() == pytest.approx(1.0 - 1.0 / math.pi, abs=1e-12)
def test_max_with_itself_and_with_a_shift_is_exact():
a = Canonical(2.0, (0.3, -0.4), 0.0)
c, t = clark_max(a, a)
assert c == a and t == 1.0
b = Canonical(1.5, (0.3, -0.4), 0.0) # a - b is the constant 0.5
c, t = clark_max(b, a)
assert c == a and t == 0.0
def test_clark_moments_and_covariance_against_monte_carlo():
rng = random.Random(3)
a = Canonical(1.0, (0.8, 0.1), 0.5)
b = Canonical(1.2, (0.3, 0.6), 0.4)
c, t = clark_max(a, b)
samples = 100000
xs, z0s = [], []
for _ in range(samples):
z = [rng.gauss(0.0, 1.0), rng.gauss(0.0, 1.0)]
xs.append(max(sample(a, z, rng), sample(b, z, rng)))
z0s.append(z[0])
mu = sum(xs) / samples
var = sum((x - mu) ** 2 for x in xs) / (samples - 1)
cov0 = sum((x - mu) * z for x, z in zip(xs, z0s)) / (samples - 1)
se = math.sqrt(var / samples)
assert abs(c.mean - mu) < 4 * se
assert abs(c.variance() - var) < 0.02 * var
assert abs(c.coeffs[0] - cov0) < 0.02
assert abs(c.coeffs[0] - (t * 0.8 + (1 - t) * 0.3)) < 1e-12
def test_residual_is_never_clamped():
# Bessel's inequality: Var(max) >= sum of squared covariances with the
# independent unit sources, so the private term needs no clamping.
rng = random.Random(5)
for _ in range(2000):
m = rng.randint(0, 4)
a = Canonical(rng.uniform(-2, 2), tuple(rng.uniform(-1, 1) for _ in range(m)), rng.uniform(0, 1))
b = Canonical(rng.uniform(-2, 2), tuple(rng.uniform(-1, 1) for _ in range(m)), rng.uniform(0, 1))
c, t = clark_max(a, b)
cov = sum(x * y for x, y in zip(a.coeffs, b.coeffs))
theta2 = a.variance() + b.variance() - 2 * cov
if theta2 <= 1e-300:
continue
theta = math.sqrt(theta2)
alpha = (a.mean - b.mean) / theta
second = ((a.mean ** 2 + a.variance()) * cdf(alpha) + (b.mean ** 2 + b.variance()) * cdf(-alpha)
+ (a.mean + b.mean) * theta * pdf(alpha))
assert c.variance() == pytest.approx(second - c.mean ** 2, abs=1e-9)
def all_path_lengths(n, edges, v):
"""Brute force: lengths of all paths from a start point to v."""
into = [[] for _ in range(n)]
for u, w, d in edges:
into[w].append((u, d))
if not into[v]:
return [0.0]
return [x + d.mean for u, d in into[v] for x in all_path_lengths(n, edges, u)]
def test_deterministic_delays_give_the_longest_path():
rng = random.Random(11)
for _ in range(200):
n = rng.randint(2, 8)
m = rng.randint(0, 2)
edges = []
for v in range(1, n):
for u in rng.sample(range(v), min(v, rng.randint(0, 3))):
edges.append((u, v, constant(rng.randint(-3, 9), m)))
rng.shuffle(edges)
start = {v: constant(0, m) for v in range(n) if all(w != v for _, w, _ in edges)}
at = statistical_static_timing_analysis(n, edges, start)
for v in range(n):
assert at[v].variance() == 0.0
assert at[v].mean == max(all_path_lengths(n, edges, v))
def test_chain_is_exact():
rng = random.Random(13)
m = 2
edges = [(k, k + 1, Canonical(rng.uniform(1, 3), (rng.uniform(0, 0.5), rng.uniform(-0.5, 0.5)),
rng.uniform(0, 0.5))) for k in range(6)]
at = statistical_static_timing_analysis(7, edges, {0: constant(1.0, m)})
mean = 1.0 + sum(d.mean for _, _, d in edges)
coeffs = [sum(d.coeffs[i] for _, _, d in edges) for i in range(m)]
rand2 = sum(d.rand ** 2 for _, _, d in edges)
assert at[6].mean == pytest.approx(mean, abs=1e-12)
assert list(at[6].coeffs) == pytest.approx(coeffs, abs=1e-12)
assert at[6].rand ** 2 == pytest.approx(rand2, abs=1e-12)
mu, sd, _ = monte_carlo(7, edges, {0: constant(1.0, m)}, m, 20000, rng, 6)
assert abs(mu - mean) < 4 * sd / math.sqrt(20000)
assert abs(sd - at[6].std()) < 0.03 * sd
def test_diamond_example():
edges = [(0, 1, Canonical(3.0, (0.4,), 0.3)), (0, 2, Canonical(2.6, (0.1,), 0.5)),
(1, 3, Canonical(2.0, (0.2,), 0.2)), (2, 3, Canonical(2.5, (0.3,), 0.2))]
at = statistical_static_timing_analysis(4, edges, {0: constant(0.0, 1)})
out = at[3]
assert out.mean == pytest.approx(5.3235, abs=1e-4)
assert out.coeffs[0] == pytest.approx(0.4883, abs=1e-4)
assert out.std() == pytest.approx(0.6288, abs=1e-4)
# Only one max of two jointly Gaussian path delays: the moments are exact.
rng = random.Random(7)
mu, sd, values = monte_carlo(4, edges, {0: constant(0.0, 1)}, 1, 50000, rng, 3)
assert abs(mu - out.mean) < 4 * sd / math.sqrt(50000)
assert abs(sd - out.std()) < 0.02 * sd
# The shape is not Gaussian, so the yield is close but not exact.
for q in (5.5, 6.0, 6.5):
empirical = sum(x <= q for x in values) / len(values)
assert abs(empirical - timing_yield(out, q)) < 0.01
def test_random_dags_against_monte_carlo():
# Measured tolerance, not a theorem: mean and standard deviation within
# 0.12 standard deviations of a Monte Carlo estimate with 3000 samples.
rng = random.Random(1)
for _ in range(12):
n = rng.randint(4, 8)
m = rng.randint(1, 3)
edges = random_dag(rng, n, m, 0.5)
at = statistical_static_timing_analysis(n, edges, {0: constant(0.0, m)})
mu, sd, _ = monte_carlo(n, edges, {0: constant(0.0, m)}, m, 3000, rng, n - 1)
assert abs(at[-1].mean - mu) < 0.12 * sd
assert abs(at[-1].std() - sd) < 0.12 * sd
def test_sum_and_yield():
a = Canonical(1.0, (0.3, 0.4), 1.2)
b = Canonical(2.0, (0.1, -0.4), 0.5)
s = add(a, b)
assert s.mean == 3.0 and s.coeffs == pytest.approx((0.4, 0.0))
assert s.rand == pytest.approx(1.3)
assert timing_yield(s, 3.0) == pytest.approx(0.5)
assert timing_yield(constant(2.0, 2), 2.0) == 1.0
assert timing_yield(constant(2.0, 2), 1.9) == 0.0
def test_errors():
d = constant(1.0, 0)
with pytest.raises(ValueError):
statistical_static_timing_analysis(2, [(0, 1, d), (1, 0, d)], {})
with pytest.raises(ValueError):
statistical_static_timing_analysis(2, [(0, 1, d)], {})
History
Clark (1961) derived the mean and the variance of the max of two jointly normal variables, and the correlation of the max with a third normal variable, to analyse PERT networks with random activity times. Visweswariah, Ravindran, Kalafala, Walker and Narayan presented the first-order canonical form at DAC 2004, with the incremental analysis and the tightness probabilities, as a tool used at IBM. The journal version appeared in 2006.
References
- Chandu Visweswariah, Kaushik Ravindran, Kerim Kalafala, Steven G. Walker and Sambasivan Narayan, First-order incremental block-based statistical timing analysis, Proceedings of the 41st Design Automation Conference, 331 to 336, 2004, the canonical first-order form, the sum and the max operations, tightness probabilities and the incremental analysis
- Chandu Visweswariah, Kaushik Ravindran, Kerim Kalafala, Steven G. Walker, Sambasivan Narayan and others, First-order incremental block-based statistical timing analysis, IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 25(10), from page 2170, 2006, the journal version, with the criticality probabilities and the results on IBM designs
- Charles E. Clark, The greatest of a finite set of random variables, Operations Research 9(2), 145 to 162, 1961, the mean and the variance of the max of two jointly normal variables, and its correlation with a third normal variable
- J. Bhasker and Rakesh Chadha, Static Timing Analysis for Nanometer Designs, A Practical Approach, Springer, 2009, Section 10.9, Statistical Static Timing Analysis
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 XMR9Q0 Edit this page History Report an error Markdown