S3 · Lesson 31 · DSP in hardware
FIR filter structures, folding, CIC filters, polyphase decimation and CORDIC
A software filter runs one multiply after another; a hardware filter can do all of them at once, every clock. That's why radios, radar, video and network chips do their signal processing in dedicated logic. Designing it means matching the arithmetic to the sample rate: a 64-tap filter at 48 kHz needs only three million multiply-accumulates a second, which one multiplier handles easily, while the same filter on a 500 MHz radio stream needs all 64 multipliers running in parallel. Clever structures cut the cost further: symmetric coefficients halve the multipliers, a CIC filter decimates with no multipliers at all, and CORDIC computes sines and rotations with nothing but shifts and adds.
- The magnitude response of a moving-average filter of N taps (all coefficients 1/N), in dB, against frequency in cycles per sample. M stages in cascade make a CIC filter, which hardware builds from adders and registers alone.
- Nulls fall at multiples of 1/N cycles per sample, exactly where the aliases land when the output is decimated by N.
- Add stages: each one deepens the stopband by the same number of dB, at the cost of more droop in the passband.
Predict
A 64-tap FIR filter processes audio at 48 kHz in an FPGA clocked at 100 MHz. How many hardware multipliers does it need?
One. The filter needs 64 × 48,000 = 3.07 million multiply-accumulates a second, and one multiplier at 100 MHz can do 100 million. There are 2,083 clock cycles between samples, so a single multiplier stepping through the taps uses only 64 of them. This is folding: hardware is time-shared when the clock is much faster than the sample rate, and replicated when it isn't.
Name it
FIR structures
An N-tap FIR filter computes : N multiplies and N − 1 additions per output.
- Direct form: a delay line of samples, a multiplier per tap and an adder tree. The adder tree sets the critical path.
- Transposed form: each input is multiplied by every coefficient at once, and the products ripple through a chain of registered adders. The critical path is one multiply and one add, whatever N is.
- Linear-phase symmetry: with , pairs of samples are added before multiplying, so only multipliers are needed. Linear phase means a delay of samples at every frequency.
Folding
The work per second is multiply-accumulates. With a clock , the number of multipliers needed is . Each output's accumulator needs bits to never overflow.
Decimation
- Polyphase: when only every Dth output is kept, compute only those, splitting the filter into D phases: multiplies per input sample, and the arithmetic runs at the low rate.
- CIC (cascaded integrator-comb): M integrators at the high rate, decimation by R, then M combs at the low rate. Its response is the moving average's to the Mth power, with no multipliers. The registers must grow by bits (D the comb's differential delay, usually 1), and wraparound in two's complement keeps it exact.
CORDIC
Rotates a vector by a sequence of fixed angles , each step using only shifts and adds. It gains about one bit of accuracy per iteration and computes sines, cosines, magnitudes and phases. The vector grows by ≈ 1.6468, a constant corrected once.
Worked example
A 64-tap symmetric FIR with 16-bit data and 16-bit coefficients runs at 48 kHz on a 100 MHz FPGA. How many multipliers, how wide an accumulator, and what delay?
Show the solution
- Work. so one multiplier is ample (with symmetry, 32 multiplies per output, after pre-adding pairs).
- Accumulator. Data, coefficient and guard bits: With symmetry the pre-adder adds one bit to the data, but there are only 32 products to sum, so bits as well.
- Delay. which is 656 µs at 48 kHz, the same at every frequency.
Answer one multiplier, a 38-bit accumulator, and a delay of 31.5 samples (656 µs).
Worked example
A CIC decimator with 4 stages, R = 64 and D = 1 takes 12-bit samples. How wide must its registers be, and where does its response first null?
Show the solution
- Register width. The growth is bits: for the integrators and combs.
- Nulls. The response is a 64-tap moving average to the 4th power, with nulls at multiples of 1/64 of the input rate: the frequencies that alias onto DC after decimating by 64.
- Sidelobes. The first sidelobes are about dB down.
- Droop. A short FIR at the low rate usually follows to flatten the passband droop.
Answer 36-bit registers, and the first null is at 1/64 of the input rate.
Worked example
A 128-tap FIR runs at 10 MS/s on a 250 MHz clock. How many multipliers does it need, and how many if its coefficients are symmetric?
Show the solution
- Work. multiplies a second.
- Multipliers. Each does 250 million a second: multipliers, each time-shared over about 21 taps.
- With symmetric coefficients. Pairs of samples are added first, leaving 64 multiplies per output:
Answer 6 multipliers, or 3 with symmetric coefficients.
Check
A 64-tap FIR runs at 48 kHz. How many million multiply-accumulates per second does it need?
Check
A 96-tap FIR filters a 2 MHz stream on a 400 MHz clock. How many multipliers are needed if they're time-shared?
Check
A linear-phase FIR has 64 symmetric taps. How many multiplies does each output need?
Check
A 500-tap FIR has 12-bit data and 14-bit coefficients. How wide must its accumulator be to never overflow?
Check
A CIC decimator has 4 stages, decimation 8 and differential delay 1, with 14-bit input. How wide must its registers be?
Check
A 20-tap moving average runs at 48 kHz. Where is its first null?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
A linear-phase FIR of 63 taps runs at 8 kHz. What's its delay?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
Check
A CORDIC runs 12 iterations, i = 0 to 12 − 1, with micro-rotations of . What's the smallest rotation angle, in degrees?
Check
A 64-tap FIR takes 16-bit samples and 16-bit coefficients at 1 MS/s, on a 300 MHz clock.
(a)
How many multiply-accumulates a second does it need, in millions?
(b)
How many multipliers does it need?
(c)
How wide must the accumulator be to never overflow?
Check
An N-tap filter decimates by D; separately, a CIC filter has M stages and decimates by R (differential delay 1).
Step 1
How many multiplies per input sample does the polyphase form need?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
How many bits must the CIC's registers grow?
Explain why
Why does a transposed-form FIR filter run at a higher clock than a direct-form one with the same coefficients?
In the direct form, every product for one output is formed at once and then summed through an adder tree, so the path from a register through a multiplier and the whole tree to the output register grows with the number of taps. The transposed form moves the registers into the adder chain: each new input is multiplied by every coefficient at once, and each product is added to a running partial sum that's registered before passing to the next adder. The longest path between registers is one multiplier and one adder no matter how many taps there are, so the clock can be as fast as a single multiply-add allows, while the filter computes the same outputs.
Practice
Keep practicing
12 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.