A 12-tap low-pass that decimates by 4 can filter every input and throw three outputs in four away. Or its taps can be sorted into four short branches that each run at the low rate. Watch the two bars of work per kept output: 48 multiplies against 12, for the same outputs.
Split the taps by phase, run each part slowly
A 12-tap low-pass decimating by M = 4: filter then discard, against four 3-tap branches.
Direct: filter every input sample (12 multiplies each), then keep one output in 4. Per kept output: 48 multiplies, 36 of them thrown away.
Describe this picture
Two stacked panels for a 12-tap low-pass decimating by . The first shows the taps, from 0 to 11, as stems whose heads show their phase : a dot for 0, a square for 1, a diamond for 2 and a triangle for 3. Each phase’s name, “E₀” to “E₃”, sits at its first tap. The second, “work per kept output”, is a bar chart from 0 to 50 multiplies with two bars, “filter then discard” and “polyphase”; the part of the first bar that is thrown away is hatched and labelled “thrown away”. The readouts are the multiplies per output and how many are thrown away. There is no control. The clip opens on the direct form: 12 multiplies for every input, then one output kept in 4, so 48 per kept output, 36 of them thrown away. Then the stems slide into four rows, one per phase: E₀ holds taps 0, 4, 8, E₁ taps 1, 5, 9, and so on, and the axis becomes the tap within the branch, 0 to 2. Last the second bar fills: the four branches add up to the same output, sample for sample, at 12 multiplies per output with nothing thrown away.
Split the taps by phase, run each part slowly
In Downsampling and decimation (22.1) a decimator filters every input sample and then keeps one output in . The other outputs are computed and thrown away, so of its multiplies are wasted. In Upsampling and interpolation (22.2) the interpolator wastes work the other way: most of its multiplies meet the zeros it inserted.
On this page I move the rate change past the filter, so that nothing is computed for nothing. In block diagrams I draw downsampling by as a box marked ↓M, and upsampling by as a box marked ↑L.
The noble identity
Take any filter and replace every by . Then every delay becomes delays:
Its taps sit only at multiples of , with zeros between. Feed it and keep every -th output, the one at :
Every sample it touches is one that ↓M keeps, so it acts exactly like on the kept samples. This is the noble identity: followed by ↓M equals ↓M followed by . The filter can move after the rate drop, where it runs times less often.
A decimation filter is not of the form : its taps sit at every . So I split it into parts that are. Sort the taps by , the remainder when is divided by . Tap goes to part , for :
Here is the -th polyphase component: the filter whose taps are , , , and so on. “Phase” here means the remainder .
Every branch after the downsampler
Each term is a delay of followed by a filter in . Keeping every -th sample of a sum is the sum of the kept samples, so ↓M can go into each branch. By the noble identity it then passes , which becomes .
So branch delays the input by , keeps every -th sample, , and filters it with at the low rate. In the time domain, put in the decimator’s sum:
The inner sum is branch . In hardware the delays and downsamplers at the front are often drawn as one switch, the commutator. It deals the input samples round the branches, one each, so every branch gets every -th sample. Once each branch has its sample, the branch outputs are added into one output.
Think of four cashiers, each serving every fourth customer. The other way is one cashier doing all the work, with supervisors throwing most of it away. The picture at the top of the page does this with a 12-tap low-pass and : four branches of 3 taps.
Notice what its end caption claims: the outputs are the same in both forms. Nothing is approximated. The polyphase form only skips the outputs that the direct form throws away.
The interpolator, the other way round
The interpolator of 22.2 inserts zeros, ↑L, and then filters. There is a second noble identity for it: ↑L followed by equals followed by ↑L. The taps of are apart. At the outputs they meet only original samples, and in between only zeros, so the result is ‘s output with zeros inserted.
Split the same way, with in place of . Then output number is made by branch alone:
For 12 taps and , each output comes from one branch of taps, so no multiply ever meets an inserted zero. Here the commutator sits at the output: it collects one sample from each branch in turn.
The table “Multiplies per output” counts the work for the jobs of this chapter.
| Job | Filter | Direct form | Polyphase |
|---|---|---|---|
| decimate by 4 | 12 taps | 48 | 12 |
| interpolate by 4 | 12 taps | 12, 9 of them by zero | 3 |
| decimate by 4 (22.1) | 75 taps | 300 | 75 |
| 44.1 → 48 kHz (22.3) | 3201 taps | 470 547 | 20 or 21 |
The decimator’s cost per output falls from to , the filter’s length. The interpolator’s falls from to . The 44.1 to 48 kHz converter of Resampling by any factor (22.3) gains both ways at once: it skips the zeros and the discarded outputs. That leaves one branch, 20 or 21 taps, for each output.
The maths behind it · block-Toeplitz matrices
The polyphase split is a permutation of the taps: stack them in an -row matrix, row holding . Group the input into blocks of samples, and a decimating filter becomes a product with a block-Toeplitz matrix. Each block is one column of the tap matrix, one tap from every branch. Filter banks are analysed in this form (Filter banks, 23.1).
No multiplications: integrators and combs
A decimator at megahertz rates wants something cheaper still, with no multiplier at all. Two pieces built from adders and delays will do it.
The first is the running sum of Operations on amplitude (2.2), . By The z-transform (16.1) a delay is , so . I call an integrator.
The second is the feed-forward comb of Resonators, notches and combs (17.4), , which is . I just call it a comb. Put the two in a row:
This is 6.1’s geometric sum, and it is an -point running sum. It is times the -point moving average of Simple smoothing filters (18.2).
Now the noble identity again. The comb is with , so it can move after ↓M and become at the low rate. The integrator stays at the high rate.
Use integrators, then ↓M, then combs. Here counts stages, not points: the average has points. Moved back in front of ↓M, the combs and integrators make the filter
and it has only adders and delays. It is a CIC filter, short for cascaded integrator–comb.
Its gain is a moving average’s gain, to the power . By Frequency response of discrete-time systems (12.4), the -point average has gain , with zeros at . So the CIC, scaled to 1 at 0 Hz, has
On a dB scale the power becomes a factor : each stage adds the same number of dB.
The instrument takes , from 64 kHz to 8 kHz, and keeps 0 to 1 kHz. After ↓8 the rate is 8 kHz, so a component folds onto 0 to 1 kHz if it lies within 1 kHz of 8, 16, 24 or 32 kHz.
The nearest such frequency is 7 kHz, and the gain there is the largest of all those bands. So the gain at 7 kHz is the one number to watch. In , 7 kHz is .
Think of stacking identical sieves. Each one catches the same share of what is left. Besides the gain at 7 kHz I watch the droop: the loss inside the kept band, at its top edge.
No multiplications: integrators and combs
CIC decimator, M = 8, from 64 kHz to 8 kHz; keep 0 to 1 kHz.
N = 1: one integrator, one comb: an 8-point moving average. At 7 kHz, −16.95 dB.
Describe this picture
Two stacked panels for a CIC decimator with , from 64 kHz to 8 kHz, keeping 0 to 1 kHz. The first draws the structure: integrator boxes marked “1/(1 − z⁻¹)”, a box “↓8”, then comb boxes marked “1 − z⁻¹”; boxes appear as grows. The second is the gain, from −120 to 5 dB against frequency from 0 to 32 kHz, a solid curve floored at −120 dB. Hatched bands at 7 to 9, 15 to 17, 23 to 25 and 31 to 32 kHz are labelled “folds onto 0–1 kHz”, and a dotted vertical line marks 7 kHz. The readouts are the number of stages , the gain at 7 kHz and the droop at 1 kHz. The clip steps from 1 to 4. One stage, one integrator and one comb, is an 8-point moving average: −16.95 dB at 7 kHz and −0.221 dB of droop. Two stages give −33.91 and −0.442 dB, three −50.86 and −0.663 dB, and four −67.82 and −0.884 dB, with no multiplier anywhere. After the clip a slider named “Stages N” sets from 1 to 6. At 5 the caption reads “N = 5: −84.77 dB at 7 kHz, droop −1.105 dB.” At 6 it is −101.73 dB and −1.325 dB.
Notice the two readouts as grows. Each stage adds another −16.95 dB at 7 kHz, but only −0.221 dB at 1 kHz. The clip’s end caption says why: each stage multiplies the gain by the same moving-average curve, so its dB add.
What it costs
The CIC has no multipliers, but it pays in register size. At 0 Hz the -point running sum has gain , so the CIC has gain : here up to . The gain panel divides by this, which is why 0 Hz sits at 0 dB.
The registers must hold numbers times bigger than the input. That takes extra bits: 3 per stage here, from 3 bits for one stage to 18 for six.
The integrators are a worry. A running sum of a signal that does not average to zero grows without end, so in fixed point it overflows. In the two’s complement arithmetic of Finite word-length effects (21.3), it wraps round.
Here that does no harm, as long as each register has those extra bits. In a register of bits, a wrap changes a value by a whole multiple of . Adds and subtracts carry such an error through unchanged, so the combs’ output is off by a multiple of at most.
The true output fits in bits, so the last wrap lands it exactly on the true value. The combs undo the integrators’ wrapping exactly.
The droop grows with too, −0.884 dB at 1 kHz for four stages. A short FIR after the CIC, running at the low rate, lifts the top of the kept band back up. It is called a compensation filter.
The maths behind it · the central limit theorem
A CIC with stages is moving averages in a row. Its impulse response is a box convolved with itself times. As grows, that shape tends to a Gaussian: the central limit theorem, in filter form.
Worked example
1. Counting multiplies. A decimator with taps that filters every input does multiplies per kept output; in polyphase form it does . For 12 taps and that is 48 against 12, and for 22.1’s 75 taps it is 300 against 75. An interpolator with 12 taps and does 12 multiplies per output directly, 9 of them by zero, and 3 in polyphase form.
2. The CIC gain at 7 kHz, by hand. With at 64 kHz, at 7 kHz, and . One stage gives , which is −16.95 dB. At 1 kHz the top is , also 0.38268, and the bottom is . That gives 0.97489, or −0.221 dB.
3. How many stages for 60 dB? Each stage gives 16.95 dB at 7 kHz, and . So gives −50.86 dB, not enough, and gives −67.82 dB. Take 4 stages: the droop at 1 kHz is −0.884 dB, and the registers need extra bits.
4. Register width. An 8-bit input through that 4-stage CIC needs registers of bits. The largest output is , which fits in 20 bits but not in 19.
Where you’ll meet this
Sigma-delta converters (Oversampling and noise shaping, 11.3) sample at megahertz rates, and their first decimation stages are usually CIC filters. So are the first stages of software radios. At those rates a multiplier is expensive and an adder is cheap. A polyphase FIR then does the last, sharper stages at the lower rate.
SciPy’s upfirdn and resample_poly work in polyphase form, which is why 22.3’s 44.1 to 48 kHz job costs about 20 multiplies per output. The Farrow structure of 22.3 is close kin: it works like a polyphase filter with a branch for every fractional position , its taps computed from rather than stored.
In Filter banks (23.1), the polyphase components of one prototype filter build a whole bank of band filters at once.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Noble identity (down) | then ↓M = ↓M then | filter after the rate drop |
| Noble identity (up) | ↑L then = then ↑L | filter before the zeros go in |
| Polyphase split | , taps | branches at the low rate |
| Cost per output | (decimator), (interpolator) | instead of , |
| CIC | no multipliers; gain at 0 Hz | |
| CIC gain re 0 Hz | times one stage’s dB | |
| CIC growth | bits | wrap-around is harmless with them |