---
title: Logical effort
heading: Sizing a chain of gates for the least delay
eyebrow: C7 · Lesson 9 · Logical effort
xp: 40
---

::: hook
A small gate can't drive a large load quickly, and a large gate is itself a large load for whatever drives it. So how big should each gate in a path be, and how many gates should the path have? The method of logical effort answers both with a few multiplications, and its answers are surprising: driving a big load fastest usually means adding inverters, and every stage should carry about the same effort, near four.

::: play
- The curve is the delay of a chain of N inverters driving a load H times bigger than the first inverter's input, in units of a fixed inverter delay τ, with each stage sized to share the effort equally.
- One inverter driving the whole load is slow. Add stages: the delay falls, then rises again.
- Change H and watch where the minimum moves. It sits near the N that makes each stage's effort about 4.
:::
:::

```sim plot
view: graph
x: N = 1..10
y: D = 0..80
slider: H = 4..10000 = 64 log
plot: N*H^(1/N) + N | label: delay of an N-stage chain | samples: 300
readout: best number of stages = log(H)/log(4) | digits: 3
readout: delay with that many stages = log(H)/log(4)*H^(1/(log(H)/log(4))) + log(H)/log(4) | digits: 3
```

::: predict
## An inverter must drive a load 64 times its own input capacitance. Which is faster: one inverter, or three in a chain sized 1, 4 and 16?

- [ ] One inverter: fewer gates, less delay
- [x] Three inverters, by more than four times
- [ ] They're the same
- [ ] Three inverters, by about 10%

::: reveal
Three, about four times faster. One inverter has an electrical effort of 64, so its delay is 64 + 1 = 65τ. Three stages each drive a load four times their input: 3 × (4 + 1) = 15τ. Spreading the effort over stages turns a product into a sum, and with a large load that's a big win.
:::
:::

::: nameit
## The delay of one gate

In units of τ (the delay of an ideal inverter driving an identical one, without parasitics),

$$d = gh + p,$$

- **logical effort** g: how much more input capacitance the gate needs than an inverter to deliver the same current. Inverter 1, NAND2 $\frac43$, NOR2 $\frac53$, in general $\frac{n + 2}{3}$ for an n-input NAND and $\frac{2n + 1}{3}$ for a NOR;
- **electrical effort** $h = \frac{C_\text{out}}{C_\text{in}}$: the load relative to the gate's own input;
- **parasitic delay** p: the gate's own capacitance, 1 for an inverter, about n for an n-input NAND or NOR.

An inverter driving four copies of itself, the **fanout-of-4 (FO4)** delay, takes 4 + 1 = 5τ, a common yardstick for a process's speed.

## A path

For N gates in a row, the **path effort** is

$$F = GBH, \qquad G = \prod g_i, \quad H = \frac{C_\text{out}}{C_\text{in}},$$

with B the product of any branching (fanout to other paths). The delay is least when every stage bears the same effort $f = F^{1/N}$, and then

$$D = NF^{1/N} + \sum p_i.$$

The best number of stages is near $\log_4F$, where each stage's effort is about 4. To size the gates, work backward from the load: each gate's input capacitance is $C_\text{in} = \frac{g\,C_\text{out}}{f}$.
:::

::: example
## Size a three-inverter chain to drive a load 64 times the first inverter's input. What delay results?

::: solution
1. **Stage effort.** F = H = 64, so
   $$\begin{aligned} f &= 64^{1/3} \\ &= 4 \end{aligned}$$
2. **Size backward from the load.** Working back from the load of 64, the last inverter's input is $\frac{64}{4}$ = 16, the middle one's $\frac{16}{4}$ = 4, and the first is 1.
3. **Delay.**
   $$\begin{aligned} D &= 3 \times 4 + 3 \times 1 \\ &= 15\tau \end{aligned}$$
   against 65τ for one inverter.
4. **In picoseconds.** With τ = 5 ps that's 75 ps instead of 325 ps.

**Answer:** input sizes of 1, 4 and 16 give a delay of 15τ (75 ps at τ = 5 ps), against 65τ for one inverter.
:::
:::

::: example
## A path is a NAND2, then a NOR2, then an inverter driving a load 20 times the NAND2's input. Find the least delay and the gate sizes.

::: solution
1. **Path effort.**
   $$\begin{aligned} G &= \frac43 \times \frac53 \times 1 \\ &= \frac{20}{9} \\ F &= \frac{20}{9} \times 20 \\ &= 44.4 \end{aligned}$$
2. **Stage effort.**
   $$\begin{aligned} f &= 44.4^{1/3} \\ &= 3.54 \end{aligned}$$
3. **Least delay.** The parasitic delays are 2 + 2 + 1, so
   $$\begin{aligned} D &= 3 \times 3.54 + 5 \\ &= 15.6\tau \end{aligned}$$
4. **Size backward.** The inverter's input and then the NOR2's are
   $$\begin{aligned} C_\text{inv} &= \frac{1 \times 20}{3.54} \\ &= 5.65 \\ C_\text{NOR} &= \frac{5/3 \times 5.65}{3.54} \\ &= 2.66 \end{aligned}$$
5. **Check.** The NAND2's comes out at 1.00, the input we started with, which checks the arithmetic.

**Answer:** the least delay is 15.6τ, with inputs of 1 for the NAND2, 2.66 for the NOR2 and 5.65 for the inverter.
:::
:::

::: example
## A path effort of 1000 must be driven. How many stages are best, and how much does using 3 instead cost?

::: solution
1. **Best number of stages.**
   $$\log_41000 = 4.98$$
   so 5 stages.
2. **Delay with five stages.** With inverters, p = 1 each:
   $$\begin{aligned} D &= 5 \times 1000^{1/5} + 5 \\ &= 24.9\tau \end{aligned}$$
3. **Delay with six.** Six stages give 25.0τ, nearly the same: the optimum is flat.
4. **Delay with three.**
   $$\begin{aligned} D &= 3 \times 10 + 3 \\ &= 33\tau \end{aligned}$$
   33% slower.
5. **What that says.** Adding inverters to a path is cheap when they buy that much.

**Answer:** 5 stages, for 24.9τ; using 3 gives 33τ, 33% slower.
:::
:::

::: check
kind: parts
given: g = 1 | 1.333 | 1.667; h = 2 | 4 | 8; p = 1 | 2

## A gate with logical effort {g} and parasitic delay {p} drives a load {h} times its input.

::: part
answer: g*h + p
tolerance: 0.5%

### What's its delay, in τ?

::: misses
- [g*h] Add the parasitic delay.
- [any] $d = gh + p$.
:::
:::

::: part
answer: (g*h + p)*5
unit: ps
tolerance: 0.5%

### In picoseconds, with τ = 5 ps?

::: misses
- [any] Multiply by τ.
:::
:::
:::

::: check
kind: parts
given: H = 16 | 100 | 400; N = 2 | 3 | 4

## A chain of N = {N} inverters drives a load {H} times the first one's input.

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

### What effort should each stage bear?

::: misses
- [H/N] The efforts multiply, so each is the Nth root.
- [any] $f = H^{1/N}$.
:::
:::

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

### What's the total delay, in τ?

::: misses
- [N*H^(1/N)] Add each inverter's parasitic delay of 1.
- [any] $NH^{1/N} + N$.
:::
:::
:::

::: check
given: F = 16 | 64 | 256 | 4096
answer: log(F)/log(4)
tolerance: 0.5%

## About how many stages minimize the delay of a path with effort {F}?

::: right
Right. $\log_4F$ = {answer}, making each stage's effort about 4.
:::

::: misses
- [log(F)/log(2)] Each stage should carry an effort near 4, not 2.
- [any] $\log_4F$.
:::
:::

::: check
kind: parts
given: n = 2 | 3 | 4

## Gates with n = {n} inputs.

::: part
answer: (n + 2)/3
tolerance: 0.5%

### What's an n-input NAND's logical effort?

::: misses
- [any] $\frac{n + 2}{3}$.
:::
:::

::: part
answer: (2*n + 1)/3
tolerance: 0.5%

### And a NOR's?

::: misses
- [(n + 2)/3] That's the NAND's; the NOR's series PMOS make it worse.
- [any] $\frac{2n + 1}{3}$.
:::
:::
:::

::: check
kind: derivation
vars: G = 1..20, B = 1..10, H = 1..1000, N = 1..10, P = 1..20

## A path has logical effort G, branching B, electrical effort H and N stages with total parasitic delay P.

::: step
answer: G*B*H

### What's the path effort?
:::

::: step
answer: (G*B*H)^(1/N)

### What's the best stage effort?
:::

::: step
answer: N*(G*B*H)^(1/N) + P

### What's the least delay?
:::

::: right
Right. Equal efforts make the product of stage efforts fixed while minimizing their sum.
:::
:::

::: check
kind: python

## Write `size_path(gs, ps, H)` returning `(D, f, cins)` for a path of gates with logical efforts `gs` and parasitics `ps`, driving a load H times the first gate's input (no branching): the least delay, the stage effort, and each gate's input capacitance from first to last (the first is 1).

```python starter
def size_path(gs, ps, H):
    N = len(gs)
    return N * H + sum(ps), H, [1.0] * N

print(size_path([4/3, 5/3, 1], [2, 2, 1], 20))
```

```python solution
import math

def size_path(gs, ps, H):
    N = len(gs)
    F = math.prod(gs) * H
    f = F ** (1 / N)
    D = N * f + sum(ps)
    cins = [0.0] * N
    cout = H
    for i in range(N - 1, -1, -1):
        cins[i] = gs[i] * cout / f
        cout = cins[i]
    return D, f, cins

print(size_path([4/3, 5/3, 1], [2, 2, 1], 20))
```

```python tests
D, f, c = size_path([4/3, 5/3, 1], [2, 2, 1], 20)
assert abs(D - 15.6266) < 1e-3 and abs(f - 3.5422) < 1e-3, f"Expected 15.6τ and f = 3.54; got {D}, {f}"
assert abs(c[0] - 1) < 1e-9 and abs(c[1] - 2.6566) < 1e-3 and abs(c[2] - 5.6462) < 1e-3, f"Sizes 1, 2.66, 5.65; got {c}"
D3, f3, c3 = size_path([1, 1, 1], [1, 1, 1], 64)
assert abs(D3 - 15) < 1e-9 and [round(x, 9) for x in c3] == [1, 4, 16], "Three inverters for H = 64: 15τ, sizes 1, 4, 16."
```

::: right
Right. Sizing backward from the load lands exactly on the first gate's input, a built-in check.
:::
:::

::: explain
## Why does adding inverters to a path that drives a large load make it faster?

::: model
A gate's delay grows in proportion to the load it drives relative to its own size. One small gate driving a huge load has an enormous electrical effort, and its delay is that whole ratio. Splitting the job among several stages, each a few times larger than the one before, means each stage faces only a modest ratio, and the delays add instead of the ratio being borne by one gate. Because the efforts multiply to the same total while the delays add, the sum is smallest when the stages share the effort equally, and each extra stage costs only its own small parasitic delay. The best number of stages makes each stage's effort about four.
:::
:::

::: practice

::: check
given: H = 9 | 125 | 1000; N = 2 | 3 | 5
answer: N*H^(1/N) + N
tolerance: 0.5%

## {N} inverters drive H = {H}. Least delay, in τ?

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

::: check
given: g = 1.333 | 1.667 | 2; h = 3 | 6; p = 1 | 3
answer: g*h + p
tolerance: 0.5%

## g = {g}, h = {h}, p = {p}. Delay in τ?

::: misses
- [any] $gh + p$.
:::
:::
:::
