This example shows how to use an imported IP-XACT specification without memory map when you generate a SystemC™/TLM component from a Simulink® model with the tlmgenerator target. You can use the tlmgenerator target for either Simulink Coder or Embedded Coder™.
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® installation area. If necessary, change to a working directory that is not in the MATLAB installation area prior to starting any build.
To open the FIR Filter model with imported IPXact (without memory map), click the Open Model button.
The following model opens in Simulink.
Open the IP-XACT file used by this example in the MATLAB Editor. Alternatively, execute the following command in the MATLAB command window:
The IP-XACT file opens in the MATLAB editor.
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).
Similarly, the following lines of code (MWMapParam) represent the FIR Filter parameter mapping on the Config TLM socket.
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.
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.
In the model window, right-click on the DualFilter block and select C/C++ Code > Generate Code for this Subsystem. This option starts the TLM component generation. Alternatively you can execute the following command in the MATLAB command window:
TLM generation is completed when the following message appears in the MATLAB command window:
### Starting Simulink Coder build procedure for model: DualFilter ### Successful completion of Simulink Coder build procedure for model: DualFilter
Open the following file in the MATLAB Editor:
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.
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.
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.
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.