getLatency

Latency of FIR filter

Description

example

Y = getLatency(hdlfir,inputType,[],isInputComplex) 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. Use this syntax when you are not using programmable coefficients. The final three arguments may be optional, depending on the object configuration.

  • Use inputType when you set CoefficientsDataType property to 'Same word length as input'. The latency can change with input data type because the object casts the coefficients to the input data type, which can affect multiplier sharing for equal-absolute-value coefficients.

  • Use isInputComplex when your input data is complex and you are using a partly-serial systolic architecture. The latency can change with complexity because of the extra multipliers. When you specify isInputComplex, you must also give a placeholder argument, [] for the unused third argument.

example

Y = getLatency(hdlfir,coeffType,coeffPrototype,isInputComplex) 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. Use this syntax when you are using programmable coefficients. coeffType is the data type of the input coefficients. The final two arguments may be optional, depending on the object configuration.

  • Use coeffPrototype to optimize the programmable filter for symmetric or antisymmetric coefficients. The prototype specifies a pattern that all input coefficients must follow. Based on the prototype, the object implements an optimized filter that shares the multipliers for symmetric coefficients. If your input coefficients do not all conform to the same pattern, or to opt out of multiplier optimization, you can omit this argument or specify the prototype as an empty vector, [].

  • Use isInputComplex when your input data is complex. When you specify isInputComplex, you must also specify the coeffPrototype or a placeholder argument, [].

example

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

Examples

collapse all

The latency of the dsp.HDLFIRFilter System object™ varies with filter structure, serialization options, and whether the coefficient values provide optimization opportunities. 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.HDLFIRFilter System object™ and request the latency. The default architecture is fully parallel systolic. 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 object casts the coefficient values to the input data type, and then checks for symmetric coefficients. This Numerator has 31 symmetric coefficients, so the object optimizes for the shared coefficients, and implements 16 multipliers.

Numerator = firpm(30,[0 0.1 0.2 0.5]*2,[1 1 0 0]);
Input_type = numerictype(1,16,15); % object uses only the word length for coefficient type cast
hdlfir = dsp.HDLFIRFilter('Numerator',Numerator);
L_sysp = getLatency(hdlfir,Input_type)
L_sysp = 23

Check the latency for a partly serial systolic implementation of the same filter. By default, the SerializationOption property is 'Minimum number of cycles between valid input samples', and so you must specify the serialization rule using the NumberOfCycles property. To share each multiplier between 8 coefficients, set the NumberOfCycles to 8. The object then optimizes based on the coefficient symmetry, so there are 16 unique coefficients shared 8 times each over 2 multipliers. This serial filter implementation requires input samples that are valid every 8 cycles.

hdlfir = dsp.HDLFIRFilter('Numerator',Numerator,'FilterStructure','Partly serial systolic','NumberOfCycles',8);
L_syss = getLatency(hdlfir,Input_type)
L_syss = 19

Check the latency of a nonsymmetric fully parallel systolic filter. The Numerator has 31 coefficients.

Numerator = sinc(0.4*[-30:0]);
hdlfir = dsp.HDLFIRFilter('Numerator',Numerator);
L_sysp = getLatency(hdlfir,Input_type)
L_sysp = 37

Check the latency of the same nonsymmetric filter implemented as a partly serial systolic filter. In this case, specify the SerializationOption by the number of multipliers. The object implements a filter that has 2 multipliers and requires 8 cycles between input samples.

hdlfir = dsp.HDLFIRFilter('Numerator',Numerator,'FilterStructure','Partly serial systolic',...
                          'SerializationOption','Maximum number of multipliers','NumberOfMultipliers',2);
L_syss = getLatency(hdlfir,Input_type)
L_syss = 25

Check the latency of a fully parallel transposed architecture. The latency for this filter structure is always 6 cycles.

hdlfir = dsp.HDLFIRFilter('Numerator',Numerator,'FilterStructure','Direct form transposed');
L_trans = getLatency(hdlfir,Input_type)
L_trans = 6

Input Arguments

collapse all

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

Input data type, specified as a numerictype 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.

Dependencies

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

Input coefficients data type, specified as a numerictype object. This argument applies when tyou use programmable coefficients. 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.

Dependencies

This argument applies when you set NumeratorSource to 'Input port (Parallel interface)'.

Prototype filter coefficients, specified as a vector of numeric real values. The prototype specifies a pattern that all input coefficients must follow. Based on the prototype, the object implements an optimized filter that shares the multipliers for symmetric coefficients. If your input coefficients do not all conform to the same pattern, or to opt out of multiplier optimization, specify the prototype as an empty vector, [].

Coefficient optimizations affect the latency of the filter object.

Dependencies

This argument applies when you set NumeratorSource to 'Input port (Parallel interface)'. When you have complex input data, but are not using programmable coefficients, set this argument to [].

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

Set this argument to true if your input data is complex. You can omit this argument if your input data is real. Complex input data requires twice as many multipliers, so the input data complexity affects multiplier optimizations and filter latency.

Data Types: logical

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

System Objects

Introduced in R2018b