---
title: Logic levels and noise margins
heading: How a continuous voltage becomes a clean 0 or 1
eyebrow: C7 · Lesson 1 · Logic levels
xp: 40
---

::: hook
Digital circuits are analog circuits that agree to ignore most of the voltage range. Anything near ground means 0, anything near the supply means 1, and the region in between is forbidden. Every logic gate restores signals as they pass through it: a slightly degraded 1 goes in, a crisp 1 comes out. The gap between what a gate guarantees to output and what the next gate needs to see is the **noise margin**, and it's why digital signals survive noise that would ruin an analog one.

::: play
- The curve is an inverter's output voltage against its input voltage. Its steep middle is where it amplifies; the flat ends are where it saturates.
- The markers are $V_{IL}$ and $V_{IH}$, where the curve's slope is −1: inputs below $V_{IL}$ count as 0, above $V_{IH}$ as 1.
- Make the gain steeper. What happens to the forbidden region and the noise margins?
:::
:::

```sim plot
view: graph
x: Vin = 0..5 V
y: Vout = 0..5.5 V
slider: VDD = 1..5 step 0.1 = 3.3 V
slider: k = 4..40 step 1 = 12
plot: VDD/(1 + exp(k*(Vin - VDD/2))) | label: inverter output
plot: Vin | dashed | color: ch2 | label: Vout = Vin
marker: x = VDD/2 + ln((1 - (1 + sqrt(1 - 4/(k*VDD)))/2)/((1 + sqrt(1 - 4/(k*VDD)))/2))/k | label: V_IL
marker: x = VDD/2 + ln((1 - (1 - sqrt(1 - 4/(k*VDD)))/2)/((1 - sqrt(1 - 4/(k*VDD)))/2))/k | label: V_IH
readout: V_IL = VDD/2 + ln((1 - (1 + sqrt(1 - 4/(k*VDD)))/2)/((1 + sqrt(1 - 4/(k*VDD)))/2))/k V
readout: V_IH = VDD/2 + ln((1 - (1 - sqrt(1 - 4/(k*VDD)))/2)/((1 - sqrt(1 - 4/(k*VDD)))/2))/k V
readout: low noise margin = VDD/2 + ln((1 - (1 + sqrt(1 - 4/(k*VDD)))/2)/((1 + sqrt(1 - 4/(k*VDD)))/2))/k - VDD*(1 - sqrt(1 - 4/(k*VDD)))/2 V
readout: high noise margin = VDD*(1 + sqrt(1 - 4/(k*VDD)))/2 - (VDD/2 + ln((1 - (1 - sqrt(1 - 4/(k*VDD)))/2)/((1 - sqrt(1 - 4/(k*VDD)))/2))/k) V
```

::: predict
## A 3.3 V CMOS chip's output, guaranteed to be at least 2.4 V when high, drives a 5 V CMOS input that needs at least 3.5 V to read 1. Will it work reliably?

- [ ] Yes: 2.4 V is plenty for a 1
- [x] No: 2.4 V falls in the 5 V input's forbidden region
- [ ] Only at low speed
- [ ] It depends on the current

::: reveal
No. A 5 V CMOS input with $V_{IH} = 0.7 \times 5 = 3.5$ V can't promise to read 2.4 V as a 1: it's in the undefined zone, so the result could be 0, 1 or anything in between, and the input might draw extra current. Mixing logic families needs a **level shifter**, or a receiving family with a lower $V_{IH}$, like TTL's 2.0 V.
:::
:::

::: nameit
## Logic levels

**Four numbers define a logic family:**

- $V_{OH}$, the lowest voltage an output guarantees for a 1;
- $V_{OL}$, the highest it guarantees for a 0;
- $V_{IH}$, the lowest voltage an input promises to read as 1;
- $V_{IL}$, the highest it promises to read as 0.

Between $V_{IL}$ and $V_{IH}$ is the forbidden region.

**Noise margins** are how much noise can be added before a valid output becomes an invalid input:

$$NM_H = V_{OH} - V_{IH} \qquad NM_L = V_{IL} - V_{OL}$$

**From the transfer curve.** $V_{IL}$ and $V_{IH}$ are conventionally the input voltages where the inverter's slope is −1; beyond them, a change at the input is shrunk at the output. That shrinking is what restores logic levels at each stage: a gain greater than 1 in the middle and less than 1 at the ends.

**Common families:**

| Family | $V_{OH}$ | $V_{OL}$ | $V_{IH}$ | $V_{IL}$ |
|---|---|---|---|---|
| 5 V TTL | 2.4 V | 0.4 V | 2.0 V | 0.8 V |
| CMOS (supply $V_{DD}$) | near $V_{DD}$ | near 0 | $0.7V_{DD}$ | $0.3V_{DD}$ |
| 3.3 V LVCMOS | 2.4 V | 0.4 V | 2.0 V | 0.8 V |

**Why it works.** An analog signal accumulates noise at every stage. A digital one is cleaned up at every gate, as long as the noise stays within the margins.
:::


::: example
## A logic family guarantees $V_{OH}$ = 2.4 V and $V_{OL}$ = 0.4 V, and its inputs accept $V_{IH}$ = 2.0 V and $V_{IL}$ = 0.8 V. Find its noise margins.

::: solution
1. **High noise margin.**
   $$\begin{aligned} NM_H &= V_{OH} - V_{IH} \\ &= 2.4 - 2.0 \\ &= 0.4\ \text{V} \end{aligned}$$
2. **Low noise margin.**
   $$\begin{aligned} NM_L &= V_{IL} - V_{OL} \\ &= 0.8 - 0.4 \\ &= 0.4\ \text{V} \end{aligned}$$
3. **What that means.** Any noise smaller than 0.4 V on a wire between two gates can't flip a bit.

**Answer:** both noise margins are 0.4 V.
:::
:::

::: example
## A 3.3 V chip whose high output is guaranteed to be 2.9 V drives a 5 V CMOS input. Will it work?

::: solution
1. **The 5 V input's threshold.**
   $$\begin{aligned} V_{IH} &= 0.7 \times 5\ \text{V} \\ &= 3.5\ \text{V} \end{aligned}$$
2. **High noise margin.**
   $$\begin{aligned} NM_H &= 2.9 - 3.5 \\ &= -0.6\ \text{V} \end{aligned}$$
   so a 1 may not be read as 1.
3. **The fix.** A level shifter, or a 5 V input that accepts lower thresholds, is needed.

**Answer:** no. The high noise margin is −0.6 V, so it needs a level shifter or a 5 V input that accepts lower thresholds.
:::
:::

::: example
## A CMOS output with about 50 Ω of on-resistance drives 10 pF of wiring plus some number of inputs at 5 pF each. How many inputs can it drive before its 50% delay exceeds 5 ns?

::: solution
1. **Set up the delay.** The output charges the total capacitance $C = (10 + 5N)$ pF through its on-resistance, and an RC step reaches 50% after $0.69RC$:
   $$0.69 \times 50\ \Omega \times C \le 5\ \text{ns}$$
2. **Solve for the capacitance.**
   $$\begin{aligned} C &\le \frac{5\ \text{ns}}{0.69 \times 50\ \Omega} \\ &= 144.93\ \text{pF} \end{aligned}$$
3. **Solve for N.**
   $$\begin{aligned} 10 + 5N &\le 144.93 \\ N &\le 26.99 \end{aligned}$$
   so N ≤ 26.
4. **What sets the limit.** CMOS inputs draw no DC current, so the static fan-out is unlimited; it's the capacitance, and with it the delay, that limits how many inputs one output should drive.

**Answer:** up to 26 inputs.
:::
:::

::: check
given: VOH = 2.4 | 2.7 | 3.1; VIH = 2 | 2.2
answer: VOH - VIH
unit: V
tolerance: 0.5%

## An output guarantees $V_{OH}$ = {VOH} V; the input it drives needs $V_{IH}$ = {VIH} V. What's the high noise margin?

::: right
Right. $NM_H = V_{OH} - V_{IH}$ = {answer}.
:::

::: misses
- [VIH - VOH] It's the output's guarantee minus the input's need.
- [any] Not yet. $NM_H = V_{OH} - V_{IH}$.
:::
:::

::: check
given: VIL = 0.8 | 1; VOL = 0.2 | 0.4 | 0.5
answer: VIL - VOL
unit: V
tolerance: 0.5%

## An input reads anything below $V_{IL}$ = {VIL} V as 0; the output driving it guarantees $V_{OL}$ = {VOL} V. What's the low noise margin?

::: right
Right. $NM_L = V_{IL} - V_{OL}$ = {answer}.
:::

::: misses
- [VOL - VIL] It's the input's limit minus the output's guarantee.
- [any] Not yet. $NM_L = V_{IL} - V_{OL}$.
:::
:::

::: check
given: VDD = 1.8 | 3.3 | 5
answer: 0.7*VDD
unit: V
tolerance: 0.5%

## A CMOS input runs from a {VDD} V supply. Using the usual 70% rule, what's its $V_{IH}$?

::: right
Right. $0.7V_{DD}$ = {answer}.
:::

::: misses
- [0.3*VDD] That's $V_{IL}$, the 0 threshold.
- [any] Not yet. $V_{IH} = 0.7V_{DD}$.
:::
:::

::: check
given: VOH = 2.4 | 2.9 | 3.3; VDD = 5
answer: step(VOH - 0.7*VDD)
tolerance: 0.01

## A {VOH} V output (its guaranteed high) drives a 5 V CMOS input. Will a 1 always read as 1? Enter 1 for yes, 0 for no.

::: right
Right. It works only if $V_{OH} \geq 0.7 \times 5 = 3.5$ V.
:::

::: misses
- [1 - step(VOH - 0.7*VDD)] Compare $V_{OH}$ with $0.7V_{DD}$ = 3.5 V.
- [any] Not yet. Compare $V_{OH}$ with $V_{IH}$.
:::
:::

::: check
kind: choice

## Why does a chain of logic gates restore a degraded signal instead of letting noise build up?

- [ ] Each gate filters out high frequencies
- [x] Near 0 and 1 each gate's gain is less than 1, so small deviations at its input shrink at its output
- [ ] The power supply cleans the signal
- [ ] Gates average their inputs

::: right
Right. The flat ends of the transfer curve squash deviations; only the steep middle amplifies.
:::

::: misses
- [1] Filtering isn't the mechanism; the transfer curve's shape is.
- [3] The supply sets the levels, but the gate's curve does the restoring.
- [4] A gate doesn't average.
:::
:::

::: check
kind: parts
given: R = 25 | 50 | 100; Cw = 5 | 20; Ci = 2 | 5; t = 2 | 5 | 10

## A CMOS output of {R} Ω drives {Cw} pF of wiring plus N inputs of {Ci} pF each, and must keep its 50% delay under {t} ns.

::: part
answer: 0.69*R*Cw*1e-12*1e9
unit: ns
tolerance: 0.5%

### What's the delay with no inputs at all?

::: misses
- [R*Cw*1e-12*1e9] A step reaches 50% at $0.69RC$.
- [any] $0.69RC_w$.
:::
:::

::: part
answer: (t*1e-9/(0.69*R) - Cw*1e-12)/(Ci*1e-12)
tolerance: 0.5%

### What's the largest N, before rounding down?

::: misses
- [any] Solve $0.69R(C_w + NC_i) = t$.
:::
:::
:::

::: check
kind: derivation
vars: H = 1..5, h = 0.5..4, L = 0..1, l = 0.1..2

## A logic family guarantees $V_{OH}$ = H and $V_{OL}$ = L, and its inputs need $V_{IH}$ = h and $V_{IL}$ = l.

::: step
answer: H - h

### What's the high noise margin?
:::

::: step
answer: l - L

### The low noise margin?
:::

::: right
Right. Noise smaller than both margins can't flip a bit.
:::
:::

::: explain
## Why do digital signals tolerate noise that would corrupt an analog signal?

::: model
An analog signal carries its information in its exact voltage, so any noise added along the way becomes part of the signal and can't be separated out. A digital signal only has to land on the correct side of a threshold. As long as the noise is smaller than the noise margin, the receiving gate still reads the right value, and because its output is driven to a clean level near the supply or ground, the noise is removed rather than passed on to the next stage.
:::
:::

::: practice

::: check
given: VOH = 2.4 | 2.5 | 2.7 | 3 | 3.3 | 4.4; VIH = 2
answer: VOH - VIH
unit: V
tolerance: 0.5%

## $V_{OH}$ = {VOH} V, $V_{IH}$ = {VIH} V. $NM_H$?

::: misses
- [any] $V_{OH} - V_{IH}$.
:::
:::

::: check
given: VDD = 1.2 | 3.3 | 5
answer: 0.3*VDD
unit: V
tolerance: 0.5%

## CMOS $V_{IL}$ (30% rule) at {VDD} V?

::: misses
- [0.7*VDD] That's $V_{IH}$.
- [any] $0.3V_{DD}$.
:::
:::

::: check
kind: choice

## An input sits at a voltage between $V_{IL}$ and $V_{IH}$. What does it read?

- [ ] 0
- [ ] 1
- [x] Nothing guaranteed: it's in the forbidden region
- [ ] The previous value

::: right
Right. The family makes no promise there.
:::

::: misses
- [1] Only below $V_{IL}$.
- [2] Only above $V_{IH}$.
- [4] Only latches remember; a plain input doesn't.
:::
:::
:::
