Main Content

constraincoeffwl

Constrain coefficient word length

Syntax

Hq = constraincoeffwl(Hd,wordlength)
Hq = constraincoeffwl(Hd,wordlength,'Ntrials',N)
Hq = constraincoeffwl(Hd,wordlength,...,'NoiseShaping',NSFlag)
Hq = constraincoeffwl(Hd,wordlength,...,'Apasstol',Apasstol)
Hq = constraincoeffwl(Hd,wordlength,...,'Astoptol',Astoptol)

Description

Hq = constraincoeffwl(Hd,wordlength) returns a fixed-point filter Hq meeting the design specifications of the single-stage or multistage FIR filter object Hd with a wordlength of at most wordlength bits. For multistage filters, wordlength can either be a scalar or vector. If wordlength is a scalar, the same word length is used for all stages. If wordlength is a vector, each stage uses the corresponding element in the vector. The vector length must equal the number of stages. Hd must be generated using fdesign and design. constraincoeffwl 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 = constraincoeffwl(Hd,wordlength,'Ntrials',N) specifies the number of Monte Carlo trials to use. Hq is first filter among the trials to meet the specifications in Hd with a wordlength of at most wordlength.

Hq = constraincoeffwl(Hd,wordlength,...,'NoiseShaping',NSFlag) enables or disables the stochastic noise-shaping procedure in the constraint of the word length. By default NSFlag is true. Setting NSFlag to false constrains the word length without using noise-shaping.

Hq = constraincoeffwl(Hd,wordlength,...,'Apasstol',Apasstol) specifies the passband ripple tolerance in dB. 'Apasstol' defaults to 1e-4.

Hq = constraincoeffwl(Hd,wordlength,...,'Astoptol',Astoptol) specifies the stopband tolerance in dB. 'Astoptol' defaults to 1e-2

You must have the Fixed-Point Designer™ software installed to use this function.

Examples

collapse all

Design fixed-point filter with a word length of at most 11 bits using constraincoeffwl.

Hf = fdesign.lowpass('Fp,Fst,Ap,Ast',.4,.5,1,60);
Hd = design(Hf,'equiripple'); % 43 coefficients
Hq = constraincoeffwl(Hd,11); % 45 11-bit coefficients
hfvt = fvtool(Hd,Hq);
legend(hfvt,'Floating-point Filter','Fixed-point Filter');

{"String":"Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB) contains 4 objects of type line. These objects represent Floating-point Filter, Fixed-point Filter: Quantized, Fixed-point Filter: Reference.","Tex":"Magnitude Response (dB)","LaTex":[]}

Version History

Introduced in R2011a