Forums

How to interpret polyphase coefficients generated in MATLAB

Started by vizziee July 6, 2009
Hello everyone,

I am trying to design a low pass decimator filter in MATLAB. I am
supposed to decimate a signal sampled at 200MHz down to 10MHz. The
signal bandwidth is 8 MHz and the signal spectra is centred at the
sampling frequency.

I began with the following code:
---------------------------------------------------------------
Fs_adc = 200e6;       % ADC Sampling Frequency
Fpass1 = 4e6;          % Passband Frequency
Fstop1 = 5e6;          % Stopband Frequency
Astop1 = 80;           % Aliasing Attenuation(dB)
M1     = 20;           % Decimation Factor
TW1    = Fstop1 - Fpass1;  % Transition Width (Hz)
dlow1  = fdesign.decimator(M1, 'nyquist', M1, TW1, Astop1, Fs_adc);
hlow1  = design(dlow1); % Lowpass prototype
Hlpf1  = mfilt.firdecim(M1, hlow1.Numerator);
fs_ds = dlow1.Fs_out;
decimated_signal = filter(Hlpf1, sampled_signal);
---------------------------------------------------------------

This gave me a Direct Form FIR Polyphase Decimator. Now when I look at
the Hbpf1 variable, it shows me 1005 coefficients (Hbpf1.Numerator
variable). Considering I have to implement this filter on FPGA, this
appears to be a very huge number for the taps.

A little reading on Polyphase FIR filters indicated me that the total
number of taps *per every sub-filter* in a polyphase structure should
be ceil(1005/M1) = 50 and so I would have M1=20 such filters. Would
this mean that implementing the above filter in polyphase form has
reduced the number of taps? I still have 1005 different coefficients
in the polyphase structure.

Or is it that since I would only be using 50 taps at a time, I only
need 50 multipliers in the hardware which should be time-multiplexed
with 20 sets of 50 coefficients, hence saving the hardware on a XILINX
Virtex5 FPGA. Further the rate of time-multiplexing the filter
coefficients is 10 MHz.

Or if this is not the good way to decimate the signal while also
achieving a good quality of output signal, kindly let me know other
ideas. I have also tried CIC-Compensator-HalfBand combination but I
really liked the response of the Polyphase FIR Decimator.

Or should I try more than one stage of polyphase FIR Decimator (say,
decimate by 5 followed by decimate by 4) to further reduce the number
of taps?

Regards,

vizziee.

vizziee wrote:

> Hello everyone, > > I am trying to design a low pass decimator filter in MATLAB.
"MATLAB does all thinking for us" (TM)
> I am > supposed to decimate a signal sampled at 200MHz down to 10MHz. The > signal bandwidth is 8 MHz and the signal spectra is centred at the > sampling frequency.
How do you manage 8 MHz of bandwidth at 10 MHz sampling rate? VLV
> be ceil(1005/M1) = 50 and so I would have M1=20 such filters. Would
A correction here: ceil(1005/M1) = 51. Regards, vizziee.
On Jul 6, 11:50&#2013266080;am, Vladimir Vassilevsky <antispam_bo...@hotmail.com>
wrote:
> > I am > > supposed to decimate a signal sampled at 200MHz down to 10MHz. The > > signal bandwidth is 8 MHz and the signal spectra is centred at the > > sampling frequency. > > How do you manage 8 MHz of bandwidth at 10 MHz sampling rate? > > VLV
Thanks VLV for your reply. The sampling rate is 200MHz. So an 8MHz BW signal occupies -pi/25 to pi/25 frequency range. When I downsample this signal by 20, the signal occupies -4pi/5 to 4pi/5 frequency range at 10MHz. Is there something that I am missing here? vizziee
vizziee wrote:
> On Jul 6, 11:50 am, Vladimir Vassilevsky <antispam_bo...@hotmail.com> > wrote: >>> I am >>> supposed to decimate a signal sampled at 200MHz down to 10MHz. The >>> signal bandwidth is 8 MHz and the signal spectra is centred at the >>> sampling frequency. >> How do you manage 8 MHz of bandwidth at 10 MHz sampling rate? >> >> VLV > > Thanks VLV for your reply. > > The sampling rate is 200MHz. So an 8MHz BW signal occupies -pi/25 to > pi/25 frequency range. When I downsample this signal by 20, the signal > occupies -4pi/5 to 4pi/5 frequency range at 10MHz. Is there something > that I am missing here?
Yes. The bandwidth is not changed by downsampling. The 8 MHz signal lies between 196 and 204 MHz when sampled and between 6 and 14 MHz after downsampling. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
> Yes. The bandwidth is not changed by downsampling. The 8 MHz signal lies > between 196 and 204 MHz when sampled and between 6 and 14 MHz after > downsampling. > > Jerry
Thanks Jerry. I think I did a mistake in my description. The signal bandwidth is 8 MHz and the signal spectrum is centred at zero rather than the sampling frequency. So, initially the signal lies between -4MHz and 4MHz in the -100MHz to 100MHz range of sampled signal spectrum. So, after downsampling by 20, the spectrum should lie between -4MHz and 4MHz in the -5MHz to 5MHz range of downsampled signal spectrum. Does this make sense now? Regards, vizziee.
vizziee wrote:
>> Yes. The bandwidth is not changed by downsampling. The 8 MHz signal lies >> between 196 and 204 MHz when sampled and between 6 and 14 MHz after >> downsampling. >> >> Jerry > > Thanks Jerry. I think I did a mistake in my description. The signal > bandwidth is 8 MHz and the signal spectrum is centred at zero rather > than the sampling frequency. > So, initially the signal lies between -4MHz and 4MHz in the -100MHz to > 100MHz range of sampled signal spectrum. So, after downsampling by 20, > the spectrum should lie between -4MHz and 4MHz in the -5MHz to 5MHz > range of downsampled signal spectrum. Does this make sense now?
That part does. Are you complex shifting? If not, how do you separate positive from negative frequencies? The usual way, a sample raye exceeding twice the bandwidth, evidently doesn't apply. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
> That part does. Are you complex shifting? If not, how do you separate > positive from negative frequencies? The usual way, a sample raye > exceeding twice the bandwidth, evidently doesn't apply.
The signal is symmetric in spectrum. So the entire information is available in one half of the spectrum. So coming to my original question, how should I interpret the polyphase coefficients. Regards, vizziee.
>>A little reading on Polyphase FIR filters indicated me that the total >>number of taps *per every sub-filter* in a polyphase structure should >>be ceil(1005/M1) = 50 and so I would have M1=20 such filters. Would >>this mean that implementing the above filter in polyphase form has >>reduced the number of taps? I still have 1005 different coefficients >>in the polyphase structure.
The polyphase implementation will certainly reduce the hardware complexity. But polyphase length of 51 is still very demanding in terms of both power and area consumption. You can read this document : http://www.altera.com/literature/hb/stx/ch_7_vol_2.pdf starting from page 17. It really helped me to understand how polyphase filters are implemented in FPGAs. You can also use MATLAB generatehdl function, provided that You have the corresponding license, and examine the HDL code generated for the mfilt object. Matlab generates quite readable code for the polyphase interpolators (some manual tuning is necessary, of course), and I believe that the same applies to decimators as well. -- Alexander
On Jul 6, 3:49 pm, vizziee <vizz...@gmail.com> wrote:
> > That part does. Are you complex shifting? If not, how do you separate > > positive from negative frequencies? The usual way, a sample raye > > exceeding twice the bandwidth, evidently doesn't apply. > > The signal is symmetric in spectrum. So the entire information is > available in one half of the spectrum. > > So coming to my original question, how should I interpret the > polyphase coefficients. > > Regards, > vizziee.
It has been quite a while since I have designed a poly phase fir filter, but if you are going to decimate by 20, don't you need a multiple of 20 coefficients? Otherwise you can't distribute the taps between the phases. A poly phase filter does not reduce the number of taps. It simply takes advantage of the fact that when you decimate the output of the FIR filter, you only need to calculate the outputs that you will be retaining. This reduces the number of calculations performed. If you had 100 taps and the filter produced an output for every input, you would perform 100 multiplies and 99 adds for each output point. The poly phase filter calculates the filter output in pieces so that for a 20x decimation the filter only does 5 multiplies and 4 adds for each input value, but still does 100 multiplies and 99 adds (counting the combining of the phases) for each output. So I don't see how you can use 1005 coefficients in a 20x polyphase filter. I may be missing something, but I don't think so. Also note that for most FIR filters you don't need to store the full number of coefficients. I don't recall the requirement to make this true, but often the coefficients are symmetrical so that coef(0) = coef (n-1). This can be true even if you have an odd number of taps, the middle coefficient is not used twice. To picture what is happening in a poly phase filter, try drawing a diagram of some sort showing which inputs are multiplied by which coefficients and how the phases are added to produce an output. When I did my first poly phase filter I didn't have this fully in hand and I mixed up the phases. The result was not pretty and hard to debug. Rick