---
title: Line codes and pulse shaping
heading: Line codes and their spectra, intersymbol interference, the Nyquist criterion, raised-cosine and root-raised-cosine pulses, bandwidth against rolloff, and eye diagrams
eyebrow: S8 · Lesson 9 · Line codes and pulse shaping
xp: 50
---

::: hook
Sending bits means sending pulses, and the shape of the pulse decides two things at once: how much bandwidth the signal takes, and whether neighboring pulses blur into each other. Rectangular pulses are easy to make but spread their spectrum over ten times the bit rate. Squeezing the spectrum smears each pulse into its neighbors' time slots, intersymbol interference, unless the pulse has zeros at exactly the right instants. Harry Nyquist worked out in 1928 which pulses do, and the raised-cosine family he found sets the bandwidth of nearly every modem, cellphone and cable link today.
:::

::: play
- The eye diagram of binary data sent with raised-cosine pulses of rolloff β through a channel with the given cutoff (in units of the symbol rate), at the given Eb/N0.
- With an ideal channel and high Eb/N0 the eye is wide open at the sampling instant: the pulses' zeros fall exactly on their neighbors' samples.
- Narrow the channel or reduce β and the eye closes: intersymbol interference and timing sensitivity grow. Larger β opens the eye's sides at the cost of bandwidth $(1 + \beta)R_s/2$.
:::
:::

```sim plot
view: eye
levels: 2
pulse: rc
slider: beta = 0..1 = 0.35 step 0.05
slider: EbN0 = 4..30 = 20 dB step 1
slider: fc = 0.2..2 = 2 step 0.05
rolloff: beta
ebn0: EbN0
channel: fc
```

::: predict
## A 1 MHz-wide baseband channel carries binary data with raised-cosine pulses, rolloff 0.25. What's the highest bit rate it supports without ISI?

- [ ] 1 Mb/s
- [x] 1.6 Mb/s
- [ ] 2 Mb/s
- [ ] 4 Mb/s

::: reveal
A raised-cosine pulse occupies $(1 + \beta)R_s/2$, so $R_s = 2B/(1 + \beta)$ = 2/1.25 = 1.6 Mbaud, and binary carries one bit per symbol: 1.6 Mb/s. The ideal sinc pulse (β = 0) would reach 2 Mb/s, the Nyquist rate, but its slowly decaying tails make it impractical.
:::
:::

::: nameit
## Line codes

- **Unipolar NRZ**: 1 → +A, 0 → 0. Has a DC component and a spectral line at DC.
- **Polar NRZ**: ±A. No DC line, first null at $R_b$.
- **RZ** (return to zero): pulses half a bit wide, twice the bandwidth, with clock content.
- **Manchester**: a transition in every bit; no DC, easy clock recovery, first null at $2R_b$.
- **AMI** (bipolar): 1s alternate ±A; no DC, a null at DC, errors detectable as violations.

## Intersymbol interference and Nyquist's criterion

Sampling the received pulse train at the symbol instants gives zero ISI if the overall pulse p(t) satisfies $p(kT) = 0$ for every k ≠ 0, which in frequency means

$$\sum_kP\left(f - \frac{k}{T}\right) = \text{constant}$$

The narrowest such spectrum is the rectangle of width $R_s/2$ (a sinc pulse): the **Nyquist bandwidth** $R_s/2$, i.e. 2 symbols per second per hertz.

## Raised cosine

With rolloff 0 ≤ β ≤ 1, the spectrum is flat to $(1 - \beta)/2T$, rolls off as a half cosine, and ends at $(1 + \beta)/2T$:

$$B = \frac{(1 + \beta)R_s}{2}\text{ (baseband)}, \qquad (1 + \beta)R_s\text{ (passband)}$$

The pulse's tails decay as $1/t^3$, so timing errors cause little ISI. Splitting it as a **root raised cosine** at the transmitter and a matched one at the receiver (lesson 13) gives zero ISI and the optimal matched filter together.

## The eye diagram

Overlaying the received signal, one or two symbols wide, shows the **eye opening** (noise margin), its width (timing margin) and the slope at its sides (timing sensitivity).
:::

::: example
## A 10 Mbaud link uses raised-cosine pulses with β = 0.35. What bandwidth does it need at baseband and at passband?

::: solution
1. **Baseband.**
   $$\begin{aligned} B &= \frac{1.35 \times 10}{2}\ \text{MHz} \\ &= 6.75\ \text{MHz} \end{aligned}$$
2. **Passband.** Double-sided around the carrier:
   $$2 \times 6.75 = 13.5\ \text{MHz}$$
3. **With β = 0.22.** As some cable and satellite standards use, it would be
   $$\begin{aligned} B &= \frac{1.22 \times 10}{2}\ \text{MHz} \\ &= 6.1\ \text{MHz} \end{aligned}$$
   and 12.2 MHz at passband.

**Answer:** 6.75 MHz at baseband and 13.5 MHz at passband.
:::
:::

::: example
## At what frequency is a β = 0.35, 1 Mbaud raised-cosine spectrum at half its peak, and what's its value at 0.6 MHz?

::: solution
1. **Half its peak.** Exactly at the Nyquist frequency $R_s/2$ = 0.5 MHz the spectrum is half its flat value. This symmetry about $1/2T$ is what makes the folded spectra sum to a constant.
2. **At 0.6 MHz.**
   $$\begin{aligned} \frac{\pi}{0.35}(0.6 - 0.325) &= 2.468\ \text{rad} \\ \tfrac12\left[1 + \cos(2.468)\right] &= 0.109 \end{aligned}$$
   of the peak.
3. **Where it ends.** It reaches zero at 0.675 MHz.

**Answer:** the spectrum is at half its peak at 0.5 MHz, and at 0.6 MHz it's 0.109 of the peak.
:::
:::

::: example
## A 64-QAM link runs at 30 Mbaud with root-raised-cosine pulses, β = 0.25. What bandwidth, bit rate and spectral efficiency does it have?

::: solution
1. **Bandwidth.** At passband:
   $$\begin{aligned} B &= (1 + \beta)R_s \\ &= 1.25 \times 30\ \text{MHz} \\ &= 37.5\ \text{MHz} \end{aligned}$$
2. **Bit rate.** 6 bits per symbol give
   $$\begin{aligned} R_b &= 6 \times 30\ \text{Mb/s} \\ &= 180\ \text{Mb/s} \end{aligned}$$
3. **Spectral efficiency.**
   $$\begin{aligned} \eta &= \frac{180}{37.5} \\ &= 4.8\ \text{b/s/Hz} \end{aligned}$$
4. **A smaller rolloff.** It would raise the efficiency toward 6 b/s/Hz but lengthen the pulses' tails and make timing errors costlier.

**Answer:** 37.5 MHz of bandwidth, 180 Mb/s and 4.8 b/s/Hz.
:::
:::

::: check
given: R = 1 | 10 | 30; b = 0.2 | 0.35 | 0.5
answer: (1 + b)*R/2
unit: MHz
tolerance: 0.5%

## A {R} Mbaud baseband signal uses raised-cosine pulses with rolloff {b}. What bandwidth does it occupy?

::: right
Right. $(1 + \beta)R_s/2$ = {answer} MHz.
:::

::: misses
- [(1 + b)*R] That's the passband bandwidth; at baseband it's half.
- [R/2] That's the Nyquist minimum, with β = 0.
- [any] Not yet. $B = (1 + \beta)R_s/2$.
:::
:::

::: check
given: B = 1 | 6 | 20; b = 0.2 | 0.35 | 0.5
answer: 2*B/(1 + b)
unit: MHz
tolerance: 0.5%

## A {B} MHz baseband channel uses raised-cosine pulses with rolloff {b}. What's the highest symbol rate without ISI?

::: right
Right. $R_s = 2B/(1 + \beta)$ = {answer} Mbaud.
:::

::: misses
- [2*B] That's the Nyquist rate for β = 0.
- [B/(1 + b)] Baseband pulses use only $(1 + \beta)R_s/2$.
- [any] Not yet. Invert $B = (1 + \beta)R_s/2$.
:::
:::

::: check
given: b = 0.25 | 0.35 | 0.5; f = 0.55 | 0.6
answer: 0.5*(1 + cos(pi/b*(f - (1 - b)/2)))
tolerance: 0.5%

## A raised cosine with rolloff {b} at 1 baud: what's its spectrum, relative to its peak, at {f} Hz?

::: right
Right. $\frac{1}{2}[1 + \cos(\frac{\pi}{\beta}(f - \frac{1 - \beta}{2}))]$ = {answer}.
:::

::: misses
- [any] Not yet. The rolloff region runs from $(1 - \beta)/2$ to $(1 + \beta)/2$.
:::
:::

::: check
given: R = 1 | 10 | 100
answer: 2*R
unit: MHz
tolerance: 0.5%

## A Manchester-coded signal runs at {R} Mb/s. Where is its first spectral null?

::: right
Right. Manchester puts a transition in every bit, doubling the first null to $2R_b$: {answer} MHz.
:::

::: misses
- [R] That's NRZ's first null.
- [any] Not yet. Manchester's pulses are half a bit wide.
:::
:::

::: check
given: b = 0.2 | 0.35 | 0.5 | 1
answer: 1/(1 + b)
tolerance: 0.5%

## A passband signal uses raised-cosine pulses with rolloff {b}. How many symbols per second does it carry per hertz of occupied bandwidth?

::: right
Right. $R_s/[(1 + \beta)R_s] = 1/(1 + \beta)$ = {answer}.
:::

::: misses
- [2/(1 + b)] At passband the occupied bandwidth is $(1 + \beta)R_s$, twice the baseband value.
- [any] Not yet. Passband bandwidth is $(1 + \beta)R_s$.
:::
:::

::: check
given: a = 0.05 | 0.1 | 0.2 | 0.3
answer: 1 - 2*a
tolerance: 0.5%

## A binary pulse's samples at the neighboring symbol instants, one before and one after, are each {a} of its peak. What fraction of the ideal eye opening remains in the worst case?

::: right
Right. Both neighbors can subtract: 1 − 2a = {answer}.
:::

::: misses
- [1 - a] Both neighbors interfere, one on each side.
- [any] Not yet. The worst case lines up both neighbors against the symbol.
:::
:::

::: check
kind: parts
given: M = 4 | 16 | 256; R = 5 | 20; b = 0.2 | 0.35

## An M = {M} QAM link runs at {R} Mbaud with rolloff {b}.

::: part
answer: (1 + b)*R
unit: MHz
tolerance: 0.5%

### What passband bandwidth does it occupy?

::: misses
- [(1 + b)*R/2] That's the baseband bandwidth; passband is twice it.
- [any] $(1 + \beta)R_s$.
:::
:::

::: part
answer: log(M)/log(2)/(1 + b)
unit: b/s/Hz
tolerance: 0.5%

### What spectral efficiency does it reach?

::: misses
- [any] $\log_2M/(1 + \beta)$.
:::
:::
:::

::: check
kind: derivation
vars: R = 1e3..1e9, b = 0..1, M = 2..1024

## An M-ary passband signal runs at R symbols per second with rolloff b.

::: step
answer: (1 + b)*R/2

### What is its baseband-equivalent bandwidth?
:::

::: step
answer: (1 + b)*R

### What is its passband bandwidth?
:::

::: step
answer: R*log(M)/log(2)/((1 + b)*R)

### What is its spectral efficiency?
:::

::: right
Right. Rolloff costs bandwidth in proportion; more levels buy efficiency logarithmically.
:::
:::

::: explain
## Why does a narrower spectrum force a pulse to spread into its neighbors' time slots?

::: model
A pulse's duration and its spectrum's width trade against each other: confining the spectrum to a narrow band forces the pulse to ring out over a long time. Squeezing the bandwidth of a train of pulses toward half the symbol rate therefore makes each pulse spread over many symbol periods, overlapping all its neighbors. That overlap is harmless only if each pulse passes through zero exactly at its neighbors' sampling instants, which is Nyquist's criterion. The sinc pulse does this with the least bandwidth, but its tails die so slowly that any timing error picks up large contributions from distant symbols. The raised cosine spends a little extra bandwidth to make its tails decay much faster, so small timing errors cause little interference.
:::
:::

::: practice

::: check
given: R = 5 | 25; b = 0.25 | 0.4
answer: (1 + b)*R/2
unit: MHz
tolerance: 0.5%

## Baseband bandwidth: {R} Mbaud, β {b}?

::: misses
- [any] $(1 + \beta)R_s/2$.
:::
:::

::: check
given: B = 3 | 12; b = 0.15 | 0.5
answer: 2*B/(1 + b)
unit: MHz
tolerance: 0.5%

## Highest symbol rate in {B} MHz with β {b}?

::: misses
- [any] $2B/(1 + \beta)$.
:::
:::

::: check
given: b = 0.3 | 0.5; f = 0.4 | 0.65
answer: 0.5*(1 + cos(pi/b*(f - (1 - b)/2)))
tolerance: 0.5%

## RC spectrum at {f} Hz for β {b}, 1 baud?

::: misses
- [any] The half-cosine rolloff.
:::
:::
:::
