Main Content


Latency of FIR decimation filter



Y = getLatency(hdlfird,inputType,isInputComplex,inputVecSize) returns the latency, Y, between the first valid input sample and the first valid output sample, assuming contiguous input samples. The latency depends on filter structure and filter coefficients. The final two arguments may be optional, depending on the object configuration.

  • Use inputType when you set CoefficientsDataType property to 'Same word length as input'. Otherwise, set it to [].

  • Set isInputComplex to true when your input data is complex. The latency changes when you have complex data and complex coefficients, because of the extra adder pipeline.

Y = getLatency(hdlfird) returns the latency, Y. Use this syntax when the CoefficientsDataType is set to a numeric type, you are using scalar input, and the input data is not complex.


collapse all

The latency of the dsp.HDLFIRDecimation System object™ varies with filter architecture and input vector size. Use the getLatency function to find the latency of a particular configuration. The latency is the number of cycles between the first valid input and the first valid output.

Create a dsp.HDLFIRDecimation System object™ and request the latency. The default filter is a direct-form systolic architecture. The default data type for the coefficients is 'Same word length as input'. Therefore, when you call the getLatency object function, you must specify an input data type. The default filter has 36 coefficients. This example assumes the data input to your filter is complex-valued. The default coefficients are real-valued. Complexity affects filter latency only when you have complex-valued data and complex-valued coefficients.

inputType = numerictype(1,16,15); % object uses only the word length for coefficient type cast
complexInput = true;
downBy4 = dsp.HDLFIRDecimation('DecimationFactor',4);
L_by4scalar = getLatency(downBy4,inputType,complexInput)
L_by4scalar = 44

Check the latency for the same filter with vector input.

vectorSize = 2;
L_by4Vec2 = getLatency(downBy4,inputType,complexInput,vectorSize)
L_by4Vec2 = 28

Check the latency of a transposed architecture.

downBy4.FilterStructure = 'Direct form transposed';
L_by4trans = getLatency(downBy4,inputType,complexInput)
L_by4trans = 11

Check the latency for the transposed filter with vector input.

vectorSize = 4;
L_by4transVec4 = getLatency(downBy4,inputType,complexInput,vectorSize)
L_by4transVec4 = 9

Input Arguments

collapse all

HDL-optimized FIR decimation filter System object that you created and configured. See dsp.HDLFIRDecimation.

Input data type, specified as a numerictype (Fixed-Point Designer) object. Call numerictype(s,w,f), where s is 1 for signed and 0 for unsigned, w is the word length in bits, and f is the number of fractional bits.

If you specify [] for this argument, the object uses double data type to calculate the latency. The result is equivalent to the fixed-point latency as long as the coefficient data type is large enough to represent the coefficient values exactly.


This argument applies when the CoefficientsDataType is 'Same word length as input'.

Set this argument to true if your input data is complex. You can omit this argument if your input data is real. When your filter has complex input data and complex coefficients there is an additional adder at the output of the filter that adds pipeline latency.

Data Types: logical

Vector size, specified as an integer from 1 to 64. When you do not specify this argument, the function assumes scalar input.

Output Arguments

collapse all

Cycles of latency that the filter object takes between the first valid input and the first valid output. Each call to the object simulates one cycle. This latency assumes valid input data on every cycle.

See Also


Introduced in R2020b