# getFixedPointInfo

Get fixed-point word and fraction lengths

## Description

example

[WLs, FLs] = getFixedPointInfo(cicObj,nt) returns all the word lengths and fraction lengths of the fixed-point sections and the output of the CIC filter System objects, dsp.CICDecimator and dsp.CICInterpolator, based on the input numeric type, nt. For locked objects or when the FixedPointDataType property of the unlocked CIC filter object is set to 'Specify word and fraction lengths', the input numeric type argument, nt, is optional.

## Examples

collapse all

Using the getFixedPointInfo function, you can determine the word lengths and fraction lengths of the fixed-point sections and the output of the dsp.CICDecimator and dsp.CICInterpolator System objects. The data types of the filter sections and the output depend on the FixedPointDataType property of the filter System object™.

Full precision

Create a dsp.CICDecimator object. The default value of the NumSections property is 2. This value indicates that there are two integrator and comb sections. The WLs and FLs vectors returned by the getFixedPointInfo function contain five elements each. The first two elements represent the two integrator sections. The third and fourth elements represent the two comb sections. The last element represents the filter output.

cicD = dsp.CICDecimator
cicD =
dsp.CICDecimator with properties:

DecimationFactor: 2
DifferentialDelay: 1
NumSections: 2
FixedPointDataType: 'Full precision'

By default, the FixedPointDataType property of the object is set to 'Full precision'. Calling the getFixedPointInfo function on this object with the input numeric type, nt, yields the following word length and fraction length vectors.

nt = numerictype(1,16,15)
nt =

DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 15
[WLs,FLs] = getFixedPointInfo(cicD,nt) %#ok
WLs = 1×5

18    18    18    18    18

FLs = 1×5

15    15    15    15    15

For details on how the word lengths and fraction lengths are computed, see the description for Output Arguments.

If you lock the cicD object by passing an input to its algorithm, you do not need to pass the nt argument to the getFixedPointInfo function.

input = int64(randn(8,1))
input = 8x1 int64 column vector

1
2
-2
1
0
-1
0
0

output = cicD(input)
output =
0
1
3
0

DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 66
FractionLength: 0
[WLs,FLs] = getFixedPointInfo(cicD) %#ok
WLs = 1×5

66    66    66    66    66

FLs = 1×5

0     0     0     0     0

The output and section word lengths are the sum of input word length, 64 in this case, and the number of sections, 2. The output and section fraction lengths are 0 since the input is a built-in integer.

Minimum section word lengths

Release the object and change the FixedPointDataType property to 'Minimum section word lengths'. Determine the section and output fixed-point information when the input is fixed-point data, fi(randn(8,2),1,24,15).

release(cicD);
cicD.FixedPointDataType = 'Minimum section word lengths'
cicD =
dsp.CICDecimator with properties:

DecimationFactor: 2
DifferentialDelay: 1
NumSections: 2
FixedPointDataType: 'Minimum section word lengths'
OutputWordLength: 32

inputF = fi(randn(8,2),1,24,15)
inputF =
3.5784   -0.1241
2.7694    1.4897
-1.3499    1.4090
3.0349    1.4172
0.7254    0.6715
-0.0630   -1.2075
0.7148    0.7172
-0.2050    1.6302

DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 24
FractionLength: 15
[WLs, FLs] = getFixedPointInfo(cicD,numerictype(inputF)) %#ok
WLs = 1×5

26    26    26    26    32

FLs = 1×5

15    15    15    15    21

Specify word and fraction lengths

Change the FixedPointDataType property to 'Specify word and fraction lengths'. Determine the fixed-point information using the getFixedPointInfo function.

cicD.FixedPointDataType = 'Specify word and fraction lengths'
cicD =
dsp.CICDecimator with properties:

DecimationFactor: 2
DifferentialDelay: 1
NumSections: 2
FixedPointDataType: 'Specify word and fraction lengths'
SectionWordLengths: [16 16 16 16]
SectionFractionLengths: 0
OutputWordLength: 32
OutputFractionLength: 0

[WLs, FLs] = getFixedPointInfo(cicD,numerictype(inputF)) %#ok
WLs = 1×5

16    16    16    16    32

FLs = 1×5

0     0     0     0     0

The section and output word lengths and fraction lengths are assigned as per the respective fixed-point properties of the cicD object. These values are not determined by the input numeric type. To confirm, call the getFixedPointInfo function without passing the numerictype input argument.

[WLs, FLs] = getFixedPointInfo(cicD) %#ok
WLs = 1×5

16    16    16    16    32

FLs = 1×5

0     0     0     0     0

Specify word lengths

To specify the word lengths of the filter section and output, set the FixedPointDataType property to 'Specify word lengths'.

cicD.FixedPointDataType = 'Specify word lengths'
cicD =
dsp.CICDecimator with properties:

DecimationFactor: 2
DifferentialDelay: 1
NumSections: 2
FixedPointDataType: 'Specify word lengths'
SectionWordLengths: [16 16 16 16]
OutputWordLength: 32

The getFixedPointInfo function requires the input numeric type because that information is used to compute the section and word fraction lengths.

[WLs, FLs] = getFixedPointInfo(cicD,numerictype(inputF))
WLs = 1×5

16    16    16    16    32

FLs = 1×5

5     5     5     5    21

For more details on how the function computes the word and fraction lengths, see the description for Output Arguments.

## Input Arguments

collapse all

CIC filter System object, specified as either a dsp.CICDecimator or dsp.CICInterpolator System object.

Input data numeric type, specified as a numerictype (Fixed-Point Designer) object. Specify this input when the System object is unlocked and the FixedPointDataType property of the CIC filter is set to 'Full precision', 'Minimum section word lengths', or 'Specify word lengths'. If the FixedPointDataType property is set to 'Specify word and fraction lengths', the word and fraction lengths of the filter sections and the output are specified through the object parameters. In this case, the nt input is optional. Alternatively, if the object is locked, the fixed-point data input to the object specifies the input word length and fraction length. The nt argument in this case is also optional.

Example: numerictype(1,16,15)

Example: input = fi(randn(16,1),1,32,30); numerictype(input)

## Output Arguments

collapse all

Section and output word lengths, returned as a row vector. The first 2 × NumSections elements in the row vector correspond to the word lengths of the integrator and comb sections of the CIC filter. The value of the NumSections property specifies the number of sections in either the integrator part or the comb part of the filter. The last element in the vector corresponds to the word length of the object output.

The word length of the CIC filter sections and the object output depend on the FixedPointDataType property of the CIC filter object.

Full precision

When the FixedPointDataType property of the CIC filter object is set to 'Full precision', the section and output word lengths are computed using the following equation:

$\begin{array}{l}W{L}_{\text{section}}=W{L}_{\text{input}}+NumSect\\ W{L}_{\text{output}}=W{L}_{\text{input}}+NumSect\end{array}$

where,

• WLsection –– Word length of the CIC filter section.

• WLoutput –– Word length of the output data.

• WLinput –– Word length of the input data.

• NumSect –– Number of CIC filter sections specified through the NumSections property.

For locked objects, WLinput is inherited from the data input you pass to the object algorithm. For unlocked objects, the WLinput is inherited from the nt argument.

Minimum section word lengths

When the FixedPointDataType property is set to 'Minimum section word lengths', the section word length is given by the following equation:

$W{L}_{\text{section}}=W{L}_{\text{input}}+NumSect$

The output word length is the value you specify in OutputWordLength property of the CIC filter object.

Specify word and fraction lengths

When the FixedPointDataType property is set to 'Specify word and fraction lengths', the section word lengths and output word length are the values you specify in the SectionWordLengths and OutputWordLength properties of the CIC filter object.

Specify word lengths

When the FixedPointDataType property is set to 'Specify word lengths', the section word lengths and the output word length are the values you specify in the SectionWordLengths and OutputWordLength properties of the CIC filter object.

Example: [20 20 20 20 20]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Section and output fraction lengths, returned as a row vector. The first 2 × NumSections elements in the row vector correspond to the fraction lengths of the integrator and comb sections of the CIC filter. The value of NumSections property specifies the number of sections in either the integrator part or the comb part of the filter. The last element in the vector corresponds to the fraction length of the object output.

The fraction length of the CIC filter sections and the object output depend on the FixedPointDataType property of the CIC filter object.

Full precision

When the FixedPointDataType property of the CIC filter object is set to 'Full precision', the section and output fraction lengths are computed using the following equation:

$\begin{array}{l}F{L}_{\text{section}}=W{L}_{\text{section}}-\left(W{L}_{\text{input}}-F{L}_{\text{input}}+NumSect\right)\\ F{L}_{\text{output}}=W{L}_{\text{output}}-\left(W{L}_{\text{input}}-F{L}_{\text{input}}+NumSect\right)\end{array}$

For inputs of built-in integer data types, the section and output fraction lengths are 0.

Minimum section word lengths

When the FixedPointDataType property of the CIC filter object is set to 'Minimum section word lengths', the section and output fraction lengths, FLsection and FLoutput are given by the following equation:

$\begin{array}{l}F{L}_{\text{section}}=W{L}_{\text{section}}-\left(W{L}_{\text{input}}-F{L}_{\text{input}}+NumSect\right)\\ F{L}_{\text{output}}=W{L}_{\text{output}}-\left(W{L}_{\text{input}}-F{L}_{\text{input}}+NumSect\right)\end{array}$

For inputs of built-in integer data types, the section and output fraction lengths are 0.

Specify word and fraction lengths

When the FixedPointDataType property of the CIC filter object is set to 'Specify word and fraction lengths', the section and output fraction lengths are the values you specify in the SectionFractionLengths and OutputFractionLength properties.

Specify word lengths

When the FixedPointDataType property of the CIC filter object is set to 'Specify word lengths', the section and output fraction lengths, FLsection and FLoutput are given by the following equation:

$\begin{array}{l}F{L}_{\text{section}}=W{L}_{\text{section}}-\left(W{L}_{\text{input}}-F{L}_{\text{input}}+NumSect\right)\\ F{L}_{\text{output}}=W{L}_{\text{output}}-\left(W{L}_{\text{input}}-F{L}_{\text{input}}+NumSect\right)\end{array}$

Example: [12 12 12 12 12]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

## References

[1] Hogenauer, E.B. "An Economical Class of Digital Filters for Decimation and Interpolation." IEEE Transactions on Acoustics, Speech and Signal Processing. Volume 29, Number 2, 1981, 155–162.

[2] Meyer-Baese, U. Digital Signal Processing with Field Programmable Gate Arrays. New York: Springer, 2001.

[3] Harris, Fredric J. Multirate Signal Processing for Communication Systems. Indianapolis, IN: Prentice Hall PTR, 2004.

## Version History

Introduced in R2018a