%% Automatic Delay Matching for the Latency of FFT HDL Optimized Block
% This example shows how to programmatically obtain the latency of an FFT
% HDL Optimized block in a model. You can use the latency value for delay
% matching of parallel data paths. 
% 
% Be cautious with delay matching for large signals or long latencies, since it 
% adds memory to your hardware implementation. Alternatively, if the signal
% does not change within a frame, use the valid or frame control signals to
% align the signal with the output of the FFT block. 
%%
% Open a model that contains an FFT HDL Optimized or an IFFT HDL Optimized
% block, such as the model from the <docid:dsp_ug.example-FFTHDLOptimizedExample Generate HDL Code for FFT HDL Optimized Block> example. 
modelname = 'FFTHDLOptimizedExample_Streaming';
load_system(modelname);
set_param(modelname,'SimulationCommand','Update');
open_system([modelname '/FFT HDL Optimized Streaming']);
%%
% This example includes a |ffthdlLatency| function that calculates the 
% latency of the block for its current parameters. Call the function with 
% the block pointer and input vector size. You can use the Simulink path 
% to the block, or select the block in the model to obtain a pointer, |gcb|. 
% In this model, the input signal is a vector of 8 samples. 
latency = ffthdlLatency([modelname '/FFT HDL Optimized Streaming/FFT HDL Optimized'],8)

%% 
% The function copies the parameters from the block pointer and creates a 
% System object(TM) with the same settings as the block. Then it calls the 
% |getLatency| function on the object. See
% <docid:dsp_ref.mw_8c4f0be6-598d-4d95-9ec4-8caf16d7160c getLatency>.
% 
% <include>ffthdlLatency.m</include>


%% 
% Copyright 2012 The MathWorks, Inc.
