%% Cause
%
% This error message generally occurs when you have Simulink(TM) blocks  
% performing floating-point operations inside a feedback loop. These blocks
% have a latency. HDL Coder(TM) is unable to allocate delays to compensate for
% the latency, because the code generator needs to add delays and balance them
% to maintain numerical accuracy.
%%
% If you open this example model |RunningSum.slx|, you see a Simulink(TM) model that uses  
% single data types.
open_system('RunningSum')
set_param('RunningSum','SimulationCommand','Update')
%% 
% To generate HDL code for the |CumSum_Sl| Subsystem, right-click the 
% subsystem and select *HDL Code* > *Generate HDL for Subsystem*. 
% During code generation, HDL Coder(TM) generates an error:
%%
msg_org = message('hdlcommon:nativefloatingpoint:TargetCodeGenFailure2','11','Add').getString();
msg_after = extractAfter(msg_org, " block. ");
msg = erase(msg_org, msg_after);
matlab.internal.display.printWrapped(msg);
%%
% By using the path to the block mentioned in the error message, navigate 
% to the Add block in the model. This block is inside a 
% feedback loop. 
open_system('RunningSum/CumSum_sl/Subsystem')
%%
% The Add block has a latency of 11. When generating code, 
% HDL Coder(TM) cannot allocate 11 delays for the block, because it cannot
% add matching delays to other paths.
%%
% This model serves as an example to illustrate the various strategies to
% solve this problem.

%% 
% Copyright 2012 The MathWorks, Inc.