Minimum wordlength fixed-point filter
Hq = minimizecoeffwl(Hd)
Hq = minimizecoeffwl(Hd,...,'NoiseShaping',NSFlag)
Hq = inimizecoeffwl(Hd,...,'NTrials',N)
Hq = minimizecoeffwl(Hd,...'Apasstol',Apasstol)
Hq = minimizecoeffwl(Hd,...,'Astoptol',Astoptol)
Hq = minimizecoeffwl(Hd,...,'MatchrefFilter',RefFiltFlag)
Hq = minimizecoeffwl(Hd) returns the minimum wordlength fixed-point filter object Hq that meets the design specifications of the single-stage or multistage FIR filter object Hd. Hd must be generated using fdesign and design. If Hd is a multistage filter object, the procedure minimizes the wordlength for each stage separately. minimizecoeffwl uses a stochastic noise-shaping procedure by default to minimize the wordlength. To obtain repeatable results on successive function calls, initialize the uniform random number generator rand.
Hq = minimizecoeffwl(Hd,...,'NoiseShaping',NSFlag) enables or disables the stochastic noise-shaping procedure in the minimization of the wordlength. By default NSFlag is true. Setting NSFlag to false minimizes the wordlength without using noise-shaping.
Hq = inimizecoeffwl(Hd,...,'NTrials',N) specifies the number of Monte Carlo trials to use in the minimization. Hq is the filter with the minimum wordlength among the N trials that meets the specifications in Hd. 'NTrials' defaults to one.
Hq = minimizecoeffwl(Hd,...'Apasstol',Apasstol) specifies the passband ripple tolerance in dB. 'Apasstol' defaults to 1e-4.
Hq = minimizecoeffwl(Hd,...,'Astoptol',Astoptol) specifies the stopband tolerance in dB. 'Astoptol' defaults to 1e-2.
Hq = minimizecoeffwl(Hd,...,'MatchrefFilter',RefFiltFlag) determines whether the fixed-point filter matches the filter order and transition width of the floating-point design. Setting 'MatchRefFilter' to true returns a fixed-point filter with the same order and transition width as Hd. The 'MatchRefFilter' property defaults to false and the resulting fixed-point filter may have a different order and transition width than the floating-point design Hd.
You must have the Fixed-Point Designer™ software installed to use this function.
Minimize wordlength for lowpass FIR equiripple filter:
f=fdesign.lowpass('Fp,Fst,Ap,Ast',0.2,0.3,1,60); % Design filter with double-precision floating point Hd=design(f,'equiripple'); % Find minimum wordlength fixed-point filter % with 0.15 dB stopband tolerance Hq=minimizecoeffwl(Hd,'MatchRefFilter',true,'Astoptol',0.15); Hq1=minimizecoeffwl(Hd,'Astoptol',0.15); % Hq.coeffwordlength is 14 bits. % Hq1.coeffwordlength is 11 bits hfvt=fvtool(Hd,Hq,Hq1,'showreference','off'); legend(hfvt,'44 coefficients floating-point',... '44 coefficients 14 bits','48 coefficients 11 bits');