Main Content

getLatency

Latency of FIR filter

Description

Y = getLatency(hdlfir) returns the latency, Y, between the first valid input sample and the first valid output sample, assuming contiguous input samples. 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 or a vector.

example

Y = getLatency(hdlfir,inputType,[],isInputComplex,V) returns the latency, Y. The latency depends on filter structure, filter coefficients, and input vector size. Use this syntax when you are not using programmable coefficients. These 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 changes when you have complex data and complex coefficients because of the extra adder pipeline. When you specify isInputComplex, you must also give a placeholder argument, [] for the unused third argument.

  • Use V to specify the input vector size when your input is not scalar.

example

Y = getLatency(hdlfir,coeffType,coeffPrototype,isInputComplex,V) returns the latency, Y. 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 you are not using the memory coefficient interface, and 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, []. The coeffPrototype is required if you use the memory coefficient interface.

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

  • Use V to specify the input vector size when your input is not scalar.

example

Examples

collapse all

The latency of the dsphdl.FIRFilter System object™ varies with filter structure, serialization options, input vector size, 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 dsphdl.FIRFilter 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 = dsphdl.FIRFilter(Numerator);
L_sysp = getLatency(hdlfir,Input_type)
L_sysp = 
23

For the same fully parallel filter with vector input, the latency is lower. Call getLatency with an input vector size of four to check the latency for that case. The empty arguments are placeholders for when you use programmable coefficients or complex input data.

L_syspv = getLatency(hdlfir,Input_type,[],[],4)
L_syspv = 
17

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 NumCycles property. To share each multiplier between 8 coefficients, set the NumCycles 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 = dsphdl.FIRFilter(Numerator,FilterStructure='Partly serial systolic', ...
                          NumCycles=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 = dsphdl.FIRFilter(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 = dsphdl.FIRFilter(Numerator,FilterStructure='Partly serial systolic', ...
                          SerializationOption='Maximum number of multipliers', ...
                          NumberOfMultipliers=2);
L_syss = getLatency(hdlfir,Input_type)
L_syss = 
37

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

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

The latency of the transposed filter increases with input vector size.

L_transv4 = getLatency(hdlfir,Input_type,[],[],4)
L_transv4 = 
9
L_transv8 = getLatency(hdlfir,Input_type,[],[],16)
L_transv8 = 
11

Input Arguments

collapse all

HDL-optimized filter System object that you created and configured.

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.

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.

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 you 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)' or 'Input port (Memory 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)' or 'Input port (Memory 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. 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 a power of 2 from 1 to 64. Use this argument to request the latency of a similar object, but with V-sample vector input. 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.

Version History

Introduced in R2017a

See Also

Objects