%% Distributed Pipelining Example for Vector Sum of Elements

% Copyright 2018 The MathWorks, Inc.

%%
% This example shows how you can distribute pipeline registers at the output
% of a Sum of Elements block that accepts vector inputs.
%%
open_system('hdlcoder_distributed_pipelining_soe')
set_param('hdlcoder_distributed_pipelining_soe','SimulationCommand','Update')
%%
% If you navigate the model, you see three pipeline stages for the Sum of Elements block.
open_system('hdlcoder_distributed_pipelining_soe/DUT/Add')
%%
% You see a Delay block of three added at the output of the Sum of Elements
% block. You can use distributed pipelining to distribute the
% delays.
%
% 1. Set *Architecture* to |Tree| for the Sum of Elements block.
hdlset_param('hdlcoder_distributed_pipelining_soe/DUT/Add/Add', ...
'Architecture','Tree')
%%
% 2. Enable *DistributedPipelining* on the Add Subsystem
hdlset_param('hdlcoder_distributed_pipelining_soe/DUT/Add', ...
'DistributedPipelining','On')
%%
% 3. Generate HDL code for the DUT Subsystem.
%
% makehdl('hdlcoder_distributed_pipelining_soe/DUT')
%%
% 4. Open the Code Generation Report to see the effect of the distributed pipelining
% optimization.
%
% <<../distributed_pipelining_report_soe_vectors.png>>
%%
% 5. To see the effect of the transformation and how the pipeline registers
% are distributed, open the generated model and navigate to the Add Subsystem.
load_system('gm_hdlcoder_distributed_pipelining_soe')
set_param('gm_hdlcoder_distributed_pipelining_soe','SimulationCommand','Update')
open_system('gm_hdlcoder_distributed_pipelining_soe/DUT/Add')