Forum Discussion
Quantization Problem...Help Please
Hi i'm working on a 2 Channel QMF perfect reconstruction Filter bank using a tutorial in Matlab and i'm trying to implement the design on a Cyclone II FPGA board. after setting everything up i notice that i wasnt getting the expected results. so i decided to simulate it in Simulink. i notice that the filter is fine and works as expected, but when i changed the arithmetic to fixed point the filter started to behave differently, i'm not sure how to fix this problem. i have images and code Please help.[CODE]N = 99;
[H0,H1,G0,G1] = firpr2chfb(N,.45);
% Analysis filters (decimators).
Hlp = mfilt.firdecim(2,H0);
Hhp = mfilt.firdecim(2,H1);
% Synthesis filters (interpolators).
Glp = mfilt.firinterp(2,G0);
Ghp = mfilt.firinterp(2,G1);
Hlp.arithmetic = 'fixed';
Hlp.InputWordLength = 16;
Hlp.InputFracLength = 15;
Hlp.FilterInternals = 'FullPrecision';
%Hlp.OutputWordLength = 16;
%Hlp.OutputFracLength = 14;
Hlp.CoeffWordLength = 16;
Hlp.signed = true;
%Hlp.AccumWordLength = 20;
% Hlp.NumStateWordLength = 20;
% Hlp.DenStateWordLength = 20;
%Hlp.CastBeforeSum = false;
%Hlp.RoundMode = 'nearest';
%Hlp.OverflowMode = 'wrap';
%----------------------------------------------------------
Hhp.arithmetic = 'fixed';
Hhp.InputWordLength = 16;
Hhp.InputFracLength = 15;
Hhp.FilterInternals = 'FullPrecision';
%Hhp.OutputWordLength = 16;
Hhp.signed = true;
%Hhp.OutputFracLength = 14;
Hhp.CoeffWordLength = 16;
%Hhp.AccumWordLength = 20;
% Hhp.NumStateWordLength = 20;
% Hhp.DenStateWordLength = 20;
%Hhp.CastBeforeSum = false;
%Hhp.RoundMode = 'nearest';
%Hhp.OverflowMode = 'wrap';
%----------------------------------------------------------
Glp.arithmetic = 'fixed';
Glp.InputWordLength = 34;
Glp.InputFracLength = 33;
Glp.FilterInternals = 'FullPrecision';
%Glp.OutputWordLength = 32;
Glp.signed = true;
%Glp.OutputFracLength = 29;
Glp.CoeffWordLength = 16;
%Glp.AccumWordLength = 32;
% Glp.NumStateWordLength = 20;
% Glp.DenStateWordLength = 20;
% Glp.CastBeforeSum = false;
%Glp.RoundMode = 'nearest';
%Glp.OverflowMode = 'wrap';
%-----------------------------------------------------------
Ghp.arithmetic = 'fixed';
Ghp.InputWordLength = 34;
Ghp.InputFracLength = 33;
Ghp.FilterInternals = 'FullPrecision';
Ghp.signed = true;
%Ghp.OutputWordLength = 32;
%Ghp.OutputFracLength = 29;
Ghp.CoeffWordLength = 16;
%Ghp.AccumWordLength = 32;
% Ghp.NumStateWordLength = 20;
% Ghp.DenStateWordLength = 20;
% Ghp.CastBeforeSum = false;
%Ghp.RoundMode = 'nearest';
%Ghp.OverflowMode = 'wrap';
/CODE]
19 Replies
- Altera_Forum
Honored Contributor
I can only see few figures in hex. Fin hits a minimum of 401h = 1025 and this is unexpected for an input of 16 bits signed for which dynamic range would be between 32767 & -32767 max.
There are no figures for output. Remember you are looking at display and could be scaled in a way that depends on bitwidth. So you better check actual min/max of your signals before judging on the performance. - Altera_Forum
Honored Contributor
I thought the problem was that i wasnt using enough bits to represent the magnitude of the sinusoid i was using as my input so i redesigned the filter to use less bits as the fraction bits thinking it would work...but i pretty much got the same results. i'm stumped. here is the image of th input and output in hexidecimal.
f_sin01 is the input, and out is the output. as u can see they are no where near each other. - Altera_Forum
Honored Contributor
The scaling of your signaltap display is not there and so it is difficult to see what is going on.
Can you post the signaltap results as digits and do you know what is your targetted fin value and how sure are you about its value. I mean if you fin is near cutoff of filter it will be attenuated. - Altera_Forum
Honored Contributor
Can you please explain that more clearly i didnt quite get it...i fixed the problem in the simulation but i'm not getting the same result in the implementation.
- Altera_Forum
Honored Contributor
Software engineers (our friendly makers of wonderful tools) regard 1 as a loose representation in digits. In fact you can represent 1 as any suitable roof value. but truncation is all that is important to match the meaning. For example if your multiplicand is meant to be .3 then you can use .3*1024 = 307 representation, multiply by input then truncate 10 bits off result.
In your tool 1 means max hardware representation and 5 can't be understood by it !! in short the soft 1 = 2^n-1 hard 1 - Altera_Forum
Honored Contributor
Thank you very much it worked. i simply changed the amplitude now it perfectly reconstructs like the non-quantized example.
really appreciate it Kaz. - Altera_Forum
Honored Contributor
Did you try setting input to +/- 1 instead of 5
- Altera_Forum
Honored Contributor
for some reason..it wont let me post on my own post.
well it uses a special function in matlab called firpr2chfb to create the filters. but the .45 is the passband edge, and the stopband edge is 1-.45. they use the coefficients from that design to design the interpolator and decimator. a QMF filterbank is merely suppose to reconstruct the signal u sent through it originally at it's output. - Altera_Forum
Honored Contributor
Your post lacks essential info e.g. cutoff points of your filters and what actually you are trying to do with decimation/interpolation. Why did you choose this particular plan. Many of us never heard of QMF. If you help us clarify then we can help.
Edit: your input is set to +/- 5 and is possibley causing saturation.make it +/- 1