---
title: "Capstone: design a gate and close its timing"
heading: Sizing a chain of logic gates for the least delay with the method of logical effort, path effort from logical, branching and electrical effort, the best effort per stage, sizing each gate backward from the load, checking the delay against the clock and fixing a path that misses
eyebrow: D7 · Lesson 7 · Capstone
xp: 80
---

::: hook
A critical path on a chip is a chain of gates that must drive a large load, perhaps a long wire or a bank of flip-flops, within one clock period. Make every gate tiny and the last one can't drive the load; make them all huge and the first one can't drive its neighbor. Ivan Sutherland and Bob Sproull's **logical effort** turns this into arithmetic: each gate's delay is its effort plus its parasitic delay, and the whole path is fastest when every stage bears the same effort. This capstone sizes a four-gate path that way, then checks whether it meets a 100 ps clock.
:::

::: play
- A path of an inverter, a NAND2, a NOR2 and an inverter (logical efforts 1, 4/3, 5/3, 1) driving H times its own input capacitance, with extra inverters added in pairs to keep the polarity.
- The stems give the least delay, in units of τ (one inverter's intrinsic delay), with N stages: $D = NF^{1/N} + P$.
- For a light load the four logic gates alone are fastest. For a heavy load, adding buffer stages pays off: the best number is about $\log_4F$.
:::

```sim plot
view: graph
x: N = 4..14
y: D = 0..60
slider: H = 4..2000 = 64 log
plot: (N*(20/9*H)^(1/N) + N + 2)*step(0.5 - abs(N/2 - round(N/2))) | stems | label: least path delay, τ (N stages)
readout: path effort F = 20/9*H | digits: 4
readout: best stage count, log₄ F = ln(20/9*H)/ln(4) | digits: 3
readout: delay with the four logic gates alone, τ = 4*(20/9*H)^(1/4) + 6 | digits: 4
```

::: predict
## The path drives 64 times its input capacitance. Its logical efforts multiply to 20/9. What effort should each of its four stages bear?

- [ ] 16
- [ ] 64
- [x] About 3.45
- [ ] 4

::: reveal
The path effort is F = G × B × H = 20/9 × 1 × 64 = 142.2, and the least delay comes from sharing it equally: $\hat f = F^{1/4}$ = 3.45 per stage. The delay is then 4 × 3.45 + 6 = 19.8 τ: 99.1 ps if τ = 5 ps, just inside a 100 ps clock.
:::
:::

::: nameit
## Logical effort

A gate's delay, in units of τ, is

$$d = gh + p$$

- **logical effort** g: how much worse the gate is at driving current than an inverter with the same input capacitance (inverter 1, NAND2 4/3, NOR2 5/3);
- **electrical effort** h = $C_\text{out}/C_\text{in}$;
- **parasitic delay** p (inverter 1, two-input gates 2).

## A path

For a path, multiply: $G = \prod g_i$, the branching effort $B = \prod b_i$ (where a stage also drives other gates, $b = (C_\text{on path} + C_\text{off path})/C_\text{on path}$), and $H = C_\text{out}/C_\text{in}$ for the whole path. The **path effort** is F = GBH and the least delay is

$$D = N\hat f + P, \qquad \hat f = F^{1/N}$$

reached when every stage bears the same effort $\hat f$, ideally around 4.

## Sizing

Work backward from the load: each stage's input capacitance is

$$C_{\text{in},i} = \frac{g_ib_iC_{\text{out},i}}{\hat f}$$

and the first stage lands exactly on the path's input capacitance.

## Closing timing

The slack is the clock period minus the path's delay. A path that misses can be fixed by adding buffer stages (when F is large), restructuring logic to lower G, splitting the load to lower B, or moving logic across flip-flops.
:::

::: example
## Size the four-stage path for H = 64 with a unit input capacitance.

::: solution
1. **Stage effort.**
   $$\begin{aligned} \hat f &= 142.2^{1/4} \\ &= 3.453 \end{aligned}$$
2. **Last inverter.** Work back from the load, dividing by $\hat f$ and multiplying by each gate's g:
   $$\frac{64}{3.453} = 18.53$$
3. **NOR2.**
   $$\frac{5}{3} \times \frac{18.53}{3.453} = 8.94$$
4. **NAND2.**
   $$\frac{4}{3} \times \frac{8.94}{3.453} = 3.45$$
5. **First inverter.**
   $$\frac{3.45}{3.453} = 1.00$$
   as it must be.

**Answer:** input capacitances of 1.00, 3.45, 8.94 and 18.53 from the first stage to the last.
:::
:::

::: example
## With τ = 5 ps, does the path meet a 100 ps clock? What if the load doubles?

::: solution
1. **Delay of the path.**
   $$\begin{aligned} D &= 4\hat f + 6 \\ &= 19.81\,\tau \\ &= 99.07\ \text{ps} \end{aligned}$$
   a slack of 0.93 ps.
2. **Twice the load.** F = 284.4, so $\hat f$ = 4.11:
   $$\begin{aligned} D &= 4\hat f + 6 \\ &= 22.43\,\tau \\ &= 112.1\ \text{ps} \end{aligned}$$
   so it misses by 12.1 ps.
3. **What would help.** Six stages wouldn't (23.4 τ); restructuring the logic or splitting the load would.

**Answer:** the path meets the 100 ps clock with 0.93 ps of slack; with twice the load it misses by 12.1 ps.
:::
:::

::: example
## What if a single inverter drove the path's whole load (H = 64) directly?

::: solution
1. **One stage.**
   $$\begin{aligned} d &= (gh + p)\tau \\ &= (1 \times 64 + 1)\tau \\ &= 65\tau \\ &= 325\ \text{ps} \end{aligned}$$
2. **Compare.** The sized four-stage path takes 99 ps. Spreading the effort over stages, each with an effort near 4, is what makes big loads fast.

**Answer:** 325 ps, against 99 ps for the sized four-stage path.
:::
:::

::: check
kind: python

## Compute the path effort and least delay, size every stage, and check the slack.

```python starter
import numpy as np

def path_effort(g, b, H):
    # Path effort F = G*B*H: the product of the logical efforts g, the product of the
    # branching efforts b, and the electrical effort H = C_out/C_in of the whole path.
    return 0.0

def path_delay(F, p):
    # Least delay, in units of tau, of a path with N = len(p) stages, total path effort F and
    # stage parasitic delays p: D = N*F**(1/N) + sum(p).
    return 0.0

def size_path(g, b, cin, cout):
    # Input capacitance of each stage when every stage bears the same effort f = F**(1/N),
    # working back from the load: stage i's input is g[i]*b[i]*C_next/f, where C_next is the
    # next stage's input capacitance (cout for the last stage). Return the list, first stage first.
    return [cin]*len(g)

def slack(F, p, tau, period):
    # Timing slack in ps for a clock period in ps: period - path_delay(F, p)*tau.
    return 0.0
```

```python solution
import numpy as np

def path_effort(g, b, H):
    return float(np.prod(g)*np.prod(b)*H)

def path_delay(F, p):
    N = len(p)
    return N*F**(1.0/N) + sum(p)

def size_path(g, b, cin, cout):
    N = len(g)
    f = path_effort(g, b, cout/cin)**(1.0/N)
    sizes = [0.0]*N
    c = cout
    for i in range(N - 1, -1, -1):
        c = g[i]*b[i]*c/f
        sizes[i] = c
    return sizes

def slack(F, p, tau, period):
    return period - path_delay(F, p)*tau
```

```python tests
_g = [1, 4/3, 5/3, 1]
_b = [1, 1, 1, 1]
_p = [1, 2, 2, 1]
_F = path_effort(_g, _b, 64)
assert abs(_F - 64*20/9) < 1e-9, f"Inverter, NAND2, NOR2, inverter driving 64 times the input: F = 64 x 20/9 = 142.2; got {_F:.3f}."
assert abs(path_effort([1, 1], [3, 1], 10) - 30) < 1e-12, "A branch of 3 multiplies the path effort by 3."
_D = path_delay(_F, _p)
assert abs(_D - 19.813) < 1e-3, f"The four-stage path's least delay is 19.81 tau; got {_D:.4f}."
_s = size_path(_g, _b, 1.0, 64.0)
assert len(_s) == 4 and abs(_s[0] - 1.0) < 1e-9, f"Sizing back from the load must land on the path's own input capacitance, 1.0; got {_s[0]:.6f}."
assert abs(_s[1] - 3.4532) < 1e-3 and abs(_s[2] - 8.9445) < 1e-3 and abs(_s[3] - 18.5327) < 1e-3, f"The stage inputs should be 1, 3.453, 8.945 and 18.53; got {[round(x, 3) for x in _s]}."
assert abs(slack(_F, _p, 5.0, 100.0) - 0.9328) < 1e-3, f"At tau = 5 ps and a 100 ps clock, the slack is 0.93 ps; got {slack(_F, _p, 5.0, 100.0):.3f}."
assert slack(_F*2, _p, 5.0, 100.0) < 0, "Doubling the load should make the path miss timing."
```

::: right
Right. The path takes 19.81 τ, sized 1, 3.45, 8.94 and 18.53, and meets the 100 ps clock by 0.93 ps.
:::
:::

::: check
given: H = 16 | 64 | 256; b = 1 | 2
answer: 20/9*b*H
tolerance: 0.5%

## A path of an inverter, NAND2, NOR2 and inverter (logical efforts 1, 4/3, 5/3, 1) has a branching effort of {b} and drives {H} times its input capacitance. What's its path effort?

::: right
Right. F = GBH = {answer}.
:::

::: misses
- [b*H] Multiply in the logical efforts, G = 20/9.
- [any] Not yet. Logical times branching times electrical effort.
:::
:::

::: check
given: F = 20 | 142.2 | 1000; N = 3 | 4 | 5
answer: F^(1/N)
tolerance: 0.5%

## A path has effort {F} and {N} stages. What effort should each stage bear for the least delay?

::: right
Right. $F^{1/N}$ = {answer}.
:::

::: misses
- [F/N] Efforts multiply along the path: take the Nth root.
- [any] Not yet. Share the effort equally.
:::
:::

::: check
given: F = 20 | 142.2 | 1000; N = 4 | 6; P = 6 | 8
answer: N*F^(1/N) + P
tolerance: 0.5%

## A path has effort {F}, {N} stages and total parasitic delay {P}. What's its least delay, in units of τ?

::: right
Right. $NF^{1/N} + P$ = {answer} τ.
:::

::: misses
- [N*F^(1/N)] Add the parasitic delays.
- [any] Not yet. N stages each with effort delay $\hat f$, plus P.
:::
:::

::: check
given: g = 1.333 | 1.667 | 2.333; C = 20 | 64; f = 3 | 4
answer: g*C/f
tolerance: 0.5%

## A stage with logical effort {g} drives {C} units of capacitance, with a stage effort of {f}. What should its input capacitance be?

::: right
Right. $gC_\text{out}/\hat f$ = {answer}.
:::

::: misses
- [C/f] Multiply by the gate's logical effort.
- [any] Not yet. Invert $\hat f = gC_\text{out}/C_\text{in}$.
:::
:::

::: check
kind: parts
given: H = 16 | 64 | 256; N = 2 | 3 | 4

## A chain of {N} inverters drives a load {H} times its input capacitance.

::: part
answer: H^(1/N)
tolerance: 0.5%

### What is the best stage effort?

::: misses
- [any] $H^{1/N}$.
:::
:::

::: part
answer: N*(H^(1/N) + 1)
unit: τ
tolerance: 0.5%

### What is the path delay, $N(\hat f + p)$ with p = 1?

::: misses
- [any] $N(\hat f + 1)$.
:::
:::
:::

::: check
kind: parts
given: H = 16 | 64 | 256; t = 3 | 5

## A single inverter drives a load {H} times its input, with τ = {t} ps.

::: part
answer: (H + 1)*t
unit: ps
tolerance: 0.5%

### What is its delay?

::: misses
- [any] $(gh + p)\tau$ with g = p = 1.
:::
:::

::: part
answer: round(ln(H)/ln(4))
tolerance: 0

### About how many stages would be best, at a stage effort near 4?

::: misses
- [any] $\log_4 H$.
:::
:::
:::

::: check
kind: parts
given: G = 1 | 1.333 | 2.222; B = 1 | 2; H = 20 | 64

## A path has total logical effort {G}, branching effort {B} and electrical effort {H}, over 4 stages.

::: part
answer: G*B*H
tolerance: 0.5%

### What is its path effort F?

::: misses
- [any] $F = GBH$.
:::
:::

::: part
answer: (G*B*H)^(1/4)
tolerance: 0.5%

### What is the best stage effort?

::: misses
- [any] $F^{1/N}$.
:::
:::
:::

::: check
kind: parts
given: D = 18 | 20 | 23; t = 4 | 5; T = 100 | 110

## A path's delay is {D} τ with τ = {t} ps; the clock period is {T} ps.

::: part
answer: D*t
unit: ps
tolerance: 0.5%

### What is its delay?

::: misses
- [any] D × τ.
:::
:::

::: part
answer: T - D*t
unit: ps
tolerance: 0.5%

### What is its slack (negative if it fails)?

::: misses
- [any] Period less delay.
:::
:::
:::

::: explain
## Why is a chain of gates fastest when every stage bears the same effort?

::: model
Each stage's delay is its effort plus a fixed parasitic part, and the efforts of all the stages must multiply to the path's total effort, which is fixed by the logic and the load. Minimizing a sum of numbers whose product is fixed is achieved when they're all equal: if one stage had more effort than another, shifting some of it to the lighter stage would lower the larger delay by more than it raises the smaller one. So the best design gives each stage the Nth root of the path effort, sizing each gate in turn so that it drives a load that many times its own input. If that per-stage effort comes out much larger than about four, adding buffer stages lowers the total delay.
:::
:::

::: practice

::: check
given: F = 2 | 10000; N = 2 | 3 | 4 | 5 | 6 | 7 | 8
answer: F^(1/N)
tolerance: 0.5%

## Stage effort: F = {F}, N = {N}?

::: misses
- [any] $F^{1/N}$.
:::
:::

::: check
given: F = 2 | 10000; N = 2 | 4 | 6 | 8; P = 2 | 12
answer: N*F^(1/N) + P
tolerance: 0.5%

## Least delay: F = {F}, N = {N}, P = {P}?

::: misses
- [any] $NF^{1/N} + P$.
:::
:::
:::
