%% Imported IP-XACT Without Memory Map
%
% This example shows how to use an imported IP-XACT specification
% without memory map  when you generate a SystemC(TM)/TLM component from a
% Simulink(R) model with the tlmgenerator target. You can use the
% tlmgenerator target for either Simulink Coder or Embedded Coder(TM).
%
% In Simulink, each block input or output is bound
% point-to-point to another block. In SystemC/TLM, each component
% communicates through a TLM socket. This socket handles all the incoming
% and outgoing communication formatted inside TLM transactions. Because
% each system handles communication differently, you must define a
% communication interface for the SystemC/TLM component when it is
% generated from a Simulink model. Depending on the intended use of this
% SystemC/TLM component, this communication interface could require
% building a memory map (or address) for each input/output in the
% component. This memory map may be simple, detailed, or imported from an
% IP-XACT specification file.
%
% The import IP-XACT option generates a TLM component according to an IP-XACT
% specification file. In this particular example, the IP-XACT file specified
% one tlm socket without memory map for the Simulink model inputs/output
% and one socket without memory map for the tunable parameters. The
% Simulink model inputs are bound to a unique write register, and the
% outputs are bound to a unique read register in the first tlm socket. The
% tunable parameters are bound to a unique read/write register in the second
% tlm socket. When created with this option, the generated TLM component
% can be used in a virtual platform (VP) as a standalone component in a
% test bench, or as a direct bound co-processing unit, or it could be attached
% to a communication channel using an adapter.
%  
% For this example, we use a Simulink model of a FIR filter as the
% basis for SystemC/TLM generation.
%
% Requirements to run this example:
%
% * SystemC 2.3.1 (includes the TLM library)
% 
%
% Note: The example includes a code generation build procedure.
% Simulink does not permit you to build programs in the MATLAB(R) installation
% area. If necessary, change to a working directory that is not in the
% MATLAB installation area prior to starting any build.

% Copyright 2005-2014 The MathWorks, Inc.

%% 1. Open Preconfigured Model
% To open the *FIR Filter model with imported IPXact (without memory map)*,
% click the *Open Model* button.
%
% The following model opens in Simulink.

%%
open_system('tlmgdemo_ipxactnomem');

%% 2. Open IP-XACT File
% Open the <matlab:open('tlmgdemo_ipxactnomem.xml') IP-XACT file> used by
% this example in the MATLAB Editor. Alternatively, execute the following
% command in the MATLAB command window: 
%
%    >> open('tlmgdemo_ipxactnomem.xml');
%
% The IP-XACT file opens in the MATLAB editor.

%% 3. Examine the IP-XACT File
% With the MATLAB Editor, find the following lines of code (MWMapInput, MWMapOutput). These lines represent the FIR Filter
% input and output mapping on the Inout TLM socket (represented by a bus
% interface in IPXact).
%
% <<../MemoryMap_ipxactnomem_inoutmap.png>>
%
% Similarly, the following lines of code (MWMapParam) represent the FIR Filter parameter
% mapping on the Config TLM socket. 
%
% <<../MemoryMap_ipxactnomem_parammap.png>>
%

%% 4. Set Option to Defined by Imported IP-XACT File
%
% *a.* In the *Configuration Parameters* dialog box, select the *TLM
% Generator* view in the left-hand pane.
%
% *b.* In the *TLM Mapping* tab, under *Socket Mapping*, select *Defined by imported IP-XACT file*.
%
% *c.* Under *Import IP-XACT File*, browse to the location of the IP-XACT file, as
% shown in the following image.  
%
% <<../MemoryMap_ipxactnomem_conf.png>>
%

%% 5. Set Other Options
% Set the remaining TLM Generation options according to your preferences
% (or leave the default values as they are) and click *OK* to apply these
% settings and exit the *Configuration Parameters* dialog box.


%% 6. Build the Model
% In the model window, right-click on the DualFilter block and select
% *C/C++ Code > Generate Code for this Subsystem*. This option starts the
% <matlab:rtwbuild('tlmgdemo_ipxactnomem/DualFilter') TLM component generation>. Alternatively you can
% execute the following command in the MATLAB command window:
%
%    >> rtwbuild('tlmgdemo_ipxactnomem/DualFilter');
%
% TLM generation is completed when the following message appears in the
% MATLAB command window:

%%
rtwbuild('tlmgdemo_ipxactnomem/DualFilter');

%% 7. Open Generated Files
% Open the following file in the MATLAB Editor:
%
% <matlab:open(fullfile('DualFilter_VP','DualFilter_ipxactnomem_tlm','include','DualFilter_ipxactnomem_tlm_def.h')) DualFilter_VP/DualFilter_ipxactnomem_tlm/include/DualFilter_ipxactnomem_tlm_def.h>

%% 8. Examine Generated Code
% Using MATLAB Editor, find the following lines of code. These lines represent the input and
% output definitions of the FIR Filter when generated as a TLM component with
% no memory map.
%
% <<../MemoryMap_ipxactnomem_inputdef.png>>
%
% To provide a set of inputs to the generated TLM component, a TLM initiator should
% send a write TLM transaction with no address at the InOut socket and with a payload
% containing a datum of type *InOut_IN_BANK_T*.
%
% <<../MemoryMap_ipxactnomem_outputdef.png>>
%
% To obtain a set of outputs from the generated TLM component, a TLM initiator should
% send a read TLM transaction with no address at the InOut socket and with a payload
% containing a datum of type *InOut_OUT_BANK_T*.
%
% <<../MemoryMap_ipxactnomem_paramdef.png>>
%
% To modify the generated TLM component tunable parameter, a TLM initiator should
% send a write TLM transaction with no address at the Config socket and with a payload
% containing a datum of type *DualFilter_Config_PARAM_BANK_T*.
%%
