*日前因为使用MATLAB设计FIR滤波器并将系数文件导入到XILINX滤波器的IP core中涉及quantizing filter特摘录该选项卡内容如下*

Quantizing Filters in the Filter Design and Analysis Tool

On this page…

Setting Quantization Parameters

Coefficients Options

Input/Output Options

Filter Internals Options

Filter Internals Options for CIC Filters

### Setting Quantization Parameters

Quantized filters have properties that define how they quantize data you filter. Use the **Set Quantization Parameters** dialog box in FDATool to set the properties. Using options in the **Set Quantization Parameters** dialog box, FDATool lets you perform a number of tasks:

Create a quantized filter from a double-precision filter after either importing the filter from your workspace, or using FDATool to design the prototype filter.

Create a quantized filter that has the default structure (Direct form II transposed) or any structure you choose, and other property values you select.

Change the quantization property values for a quantized filter after you design the filter or import it from your workspace.

When you click **Set Quantization Parameters**, and then change **Filter Arithmetic** to `Fixed-point`

, the quantized filter panel opens in FDATool, with the coefficient quantization options set to default values. In this image, you see the options for an SOS filter. Some of the options shown apply only to SOS filters. Other filter structures present a subset of the options you see here.

language=Javascript>updateSectionId("f3-5827"); language=Javascript>addTopOfPageButtons(); Back to Top

### Coefficients Options

To let you set the properties for the filter coefficients that make up your quantized filter, FDATool lists options for numerator word length (and denominator word length if you have an IIR filter). The following table lists each coefficients option and a short description of what the option setting does in the filter.

Option Name

When Used

Description

Numerator Word Length

FIR filters only

Sets the word length used to represent numerator coefficients in FIR filters.

Numerator Frac. Length

FIR/IIR

Sets the fraction length used to interpret numerator coefficients in FIR filters.

Numerator Range (+/-)

FIR/IIR

Lets you set the range the numerators represent. You use this instead of the Numerator Frac. Length option to set the precision. When you enter a value x, the resulting range is -x to x. Range must be a positive integer.

Coefficient Word Length

IIR filters only

Sets the word length used to represent both numerator and denominator coefficients in IIR filters. You cannot set different word lengths for the numerator and denominator coefficients.

Denominator Frac. Length

IIR filters

Sets the fraction length used to interpret denominator coefficients in IIR filters.

Denominator Range (+/-)

IIR filters

Lets you set the range the denominator coefficients represent. You use this instead of the Denominator Frac. Length option to set the precision. When you enter a value x, the resulting range is -x to x. Range must be a positive integer.

Best-precision fraction lengths

All filters

Directs FDATool to select the fraction lengths for numerator (and denominator where available) values to maximize the filter performance. Selecting this option disables all of the fraction length options for the filter.

Scale Values frac. length

SOS IIR filters

Sets the fraction length used to interpret the scale values in SOS filters.

Scale Values range (+/-)

SOS IIR filters

Lets you set the range the SOS scale values represent. You use this with SOS filters to adjust the scaling used between filter sections. Setting this value disables the Scale Values frac. length option. When you enter a value x, the resulting range is -x to x. Range must be a positive integer.

Use unsigned representation

All filters

Tells FDATool to interpret the coefficients as unsigned values.

Scale the numerator coefficients to fully utilize the entire dynamic range

All filters

Directs FDATool to scale the numerator coefficients to effectively use the dynamic range defined by the numerator word length and fraction length format.

language=Javascript>updateSectionId("f3-10807"); language=Javascript>addTopOfPageButtons(); Back to Top

### Input/Output Options

The options that specify how the quantized filter uses input and output values are listed in the table below. In the following picture you see the options for an SOS filter.

Option Name

When Used

Description

Input Word Length

All filters

Sets the word length used to represent the input to a filter.

Input fraction length

All filters

Sets the fraction length used to interpret input values to filter.

Input range (+/-)

All filters

Lets you set the range the inputs represent. You use this instead of the Input fraction length option to set the precision. When you enter a value x, the resulting range is -x to x. Range must be a positive integer.

Output word length

All filters

Sets the word length used to represent the output from a filter.

Avoid overflow

All filters

Directs the filter to set the fraction length for the input to prevent the output values from exceeding the available range as defined by the word length. Clearing this option lets you set Output fraction length.

Output fraction length

All filters

Sets the fraction length used to represent output values from a filter.

Output range (+/-)

All filters

Lets you set the range the outputs represent. You use this instead of the Output fraction length option to set the precision. When you enter a value x, the resulting range is -x to x. Range must be a positive integer.

Stage input word length

SOS filters only

Sets the word length used to represent the input to an SOS filter section.

Avoid overflow

SOS filters only

Directs the filter to use a fraction length for stage inputs that prevents overflows in the values. When you clear this option, you can set Stage input fraction length.

Stage input fraction length

SOS filters only

Sets the fraction length used to represent input to a section of an SOS filter.

Stage output word length

SOS filters only

Sets the word length used to represent the output from an SOS filter section.

Avoid overflow

SOS filters only

Directs the filter to use a fraction length for stage outputs that prevents overflows in the values. When you clear this option, you can set Stage output fraction length.

Stage output fraction length

SOS filters only

Sets the fraction length used to represent the output from a section of an SOS filter.

language=Javascript>updateSectionId("f3-10546"); language=Javascript>addTopOfPageButtons(); Back to Top

### Filter Internals Options

The options that specify how the quantized filter performs arithmetic operations are listed in the table after the figure. In the following picture you see the options for an SOS filter.

Option

Equivalent Filter Property (Using Wildcard *)

Description

**Round towards**

`RoundMode`

Sets the mode the filter uses to quantize numeric values when the values lie between representable values for the data format (word and fraction lengths). Choose from one of:

`Ceiling`

— round up to the nearest allowable quantized value.`Floor`

— round down to the next allowable quantized value.`Nearest`

— round to the nearest allowable quantized value. Numbers that are halfway between the two nearest allowable quantized values are rounded up.`Nearest(convergent)`

— round to the next allowable quantized value. For numbers that lie halfway between the two nearest allowable values, round up to the nearest value only when the least significant bit after rounding would be a 1.`Round`

— round towards nearest. Ties round up in absolute value.`Zero`

— round negative numbers and positive numbers towards zero to the next allowable quantized value

**Overflow Mode**

`OverflowMode`

Sets the mode used to respond to overflow conditions in fixed-point arithmetic. Choose from either `saturate`

(limit the output to the largest positive or negative representable value) or `wrap`

(set overflowing values to the nearest representable value using modular arithmetic.

**Filter Product (Multiply) Options**

**Product Mode**

`ProductMode`

Determines how the filter handles the output of product operations. Choose from full precision (`FullPrecision`

), or whether to keep the most significant bit (`KeepMSB`

) or least significant bit (`KeepLSB`

) in the result when you need to shorten the word length. `Specify all`

lets you set the fraction length applied to the results of product operations.

**Product word length**

`*ProdWordLength`

Sets the word length applied to interpret the results of multiply operations.

**Num. fraction length**

`NumProdFracLength`

Sets the fraction length used to interpret the results of product operations that involve numerator coefficients.

**Den. fraction length**

`DenProdFracLength`

Sets the fraction length used to interpret the results of product operations that involve denominator coefficients.

**Filter Sum Options**

**Accum. mode**

`AccumMode`

Determines how the accumulator outputs stored values. Choose from full precision (`FullPrecision`

), or whether to keep the most significant bits (`KeepMSB`

) or least significant bits (`KeepLSB`

) when output results need shorter word length than the accumulator supports. To let you set the word length and the precision (the fraction length) used by the output from the accumulator, set this to `Specify all`

.

**Accum. word length**

`*AccumWordLength`

Sets the word length used to store data in the accumulator/buffer.

**Num. fraction length**

`NumAccumFracLength`

Sets the fraction length used to interpret the numerator coefficients.

**Den. fraction length**

`DenAccumFracLength`

Sets the fraction length the filter uses to interpret denominator coefficients.

**Cast signals before sum**

`CastBeforeSum`

Specifies whether to cast numeric data to the appropriate accumulator format (as shown in the signal flow diagrams for each filter structure) before performing sum operations.

**Filter State Options**

**State word length**

`*StateWordLength`

Sets the word length used to represent the filter states. Applied to both numerator- and denominator-related states

**Avoid overflow**

None

Prevent overflows in arithmetic calculations by setting the fraction length appropriately.

**State fraction length**

`*StateFracLength`

Lets you set the fraction length applied to interpret the filter states. Applied to both numerator- and denominator-related states

language=Javascript>updateSectionId("f3-34792"); language=Javascript>addTopOfPageButtons(); Back to Top

### Filter Internals Options for CIC Filters

CIC filters use slightly different options for specifying the fixed-point arithmetic in the filter. The next table shows and describes the options.

#### Example — Quantize Double-Precision Filters

When you are quantizing a double-precision filter by switching to fixed-point or single-precision floating point arithmetic, follow these steps.

Click

**Set Quantization Parameters**to display the**Set Quantization Parameters**pane in FDATool.Select

`Single-precision floating point`

or`Fixed-point`

from**Filter arithmetic**.When you select one of the optional arithmetic settings, FDATool quantizes the current filter according to the Settings of the options in the Set Quantization Parameter panes, and changes the information displayed in the analysis area to show quantized filter data.

In the quantization panes, set the options for your filter. Set options for

**Coefficients**,**Input/Output**, and**Filter Internals**.Click

**Apply**.FDATool quantizes your filter using your new settings.

Use the analysis features in FDATool to determine whether your new quantized filter meets your requirements.

#### Example — Change the Quantization Properties of Quantized Filters

When you are changing the settings for the quantization of a quantized filter, or after you import a quantized filter from your MATLAB workspace, follow these steps to set the property values for the filter:

Verify that the current filter is quantized.

Click

**Set Quantization Parameters**to display the**Set Quantization Parameters**panel.Review and select property settings for the filter quantization:

**Coefficients**,**Input/Output**, and**Filter Internals**. Settings for options on these panes determine how your filter quantizes data during filtering operations.Click

**Apply**to update your current quantized filter to use the new quantization property settings from Step 3.Use the analysis features in FDATool to determine whether your new quantized filter meets your requirements.