Documentation

Imported IP-XACT With Memory Map

This example shows how to use an imported IP-XACT specification with 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 with memory map for the Simulink model inputs, one tlm socket with memory map for the Simulink model outputs, and one tlm socket with memory map for the tunable parameters. Each Simulink model input is bound to its corresponding write register in the first socket. Each output is bound to its corresponding read register in the second tlm socket. Each tunable parameter is bound to its corresponding read/write register in the third 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 it could be attached to a communication channel.

For this example, we use a Simulink model of a FIR filter as the basis for SystemC/TLM generation.

Requirements to run this example:

  • MATLAB

  • Simulink

  • Simulink Coder

  • HDL Verifier

  • 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.

1. Open Preconfigured Model

Open the FIR Filter model with imported IPXact (with memory map). Alternatively, execute the following command in the MATLAB command window:

  >> openTlmgDemoModel('ipxactmem');

The following model opens in Simulink.

2. Open IP-XACT File

Open the IP-XACT file used by this example in the MATLAB Editor. Alternatively, execute the following command in the MATLAB command window:

  >> openTlmgDemoIPXact('ipxactmem');

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 (MWMap). These lines indicate that the bus interface Input is to be map on a TLM socket and its memory map contains input, output or parameter mapping information.

The following lines of code (MWMapInput) represent the FIR Filter input_1 mapping on individual register INPUT_REG_1.

Similarly, the following lines of code (MWMapOutput) represent the FIR Filter output_1 mapping on individual register OUTPUT_REG_1.

Similarly, the following lines of code (MWMapParam) represent the FIR Filter parameter coef_11 mapping on individual register COEF_REG_1.

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.

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 TLM component generation. Alternatively you can execute the following command in the MATLAB command window:

  >> buildTlmgDemoModel('ipxactmem');

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

7. Open Generated Files

Open the following file in the MATLAB Editor:

DualFilter_VP/DualFilter_ipxactmem_tlm/include/DualFilter_ipxactmem_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.

To provide a set of input to the generated TLM component, a TLM initiator should send two write TLM transactions at the Input socket:

  • one with a payload containing a data of type INPUT_REG_1_T at the address INPUT_REG_1_ADDR.

  • one with a payload containing a data of type INPUT_REG_2_T at the address INPUT_REG_2_ADDR.

To obtain a set of output from the generated TLM component, an TLM initiator should send three read TLM transactions at the Output socket::

  • one with a payload containing a data of type OUTPUT_REG_1_T at the address OUTPUT_REG_1_ADDR.

  • one with a payload containing a data of type OUTPUT_REG_2_T at the address OUTPUT_REG_2_ADDR.

To modify the generated TLM component tunable parameter coef_11, 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 COEF_REG_1_T at the address COEF_REG_1_ADDR.

Was this topic helpful?