Real-Time Workshop Embedded Coder    

Customizing an ASAP2 File

The Real-Time Workshop Embedded Coder provides a number of TLC files to enable you to customize the ASAP2 file generated from a Simulink model. The following figure illustrates the hierarchy of ASAP2 related directories and files within the MATLAB directory.

ASAP2 File Structure on the MATLAB Path

The ASAP2 related files are located within the directories shown above. The files are organized as follows:

Customizing the Contents of the ASAP2 File

The ASAP2 related TLC files enable you to customize the appearance of the ASAP2 file generated from a Simulink model. Most customization is done by modifying or adding to the files contained in the matlabroot/toolbox/rtw/targets/asap2/asap2/user directory.This section refers to this directory as the asap2/user directory.

The user-customizable files provided are divided into two groups:

The procedure for customizing the ASAP2 file is as follows:

  1. Make a copy of the asap2/user directory before making any modifications.
  2. Remove the old asap2/user directory from the MATLAB path, or add the new asap2/user directory to the MATLAB path above the old directory. This will ensure that MATLAB uses the new ASAP2 setup file, asap2setup.tlc.
  1. asap2setup.tlc specifies which directories and files to include in the TLC path during the ASAP2 file generation process. Modify asap2setup.tlc to control the directories and folders included in the TLC path.

  1. Modify the static parts of the ASAP2 file. These include

ASAP2 Templates

The appearance of CHARACTERISTICS in the ASAP2 file is controlled using a different template for each type of CHARACTERISTIC. The asap2/user directory contains template definition files for scalars, 1-D Lookup Table blocks and 2-D Lookup Table blocks. You can modify these template definition files, or you can create additional templates as required.

The procedure for creating a new ASAP2 template is as follows:

  1. Define a parameter group. See Defining Parameter Groups.
  2. Create a template definition file. See Creating Template Definition Files.
  3. Include the template definition file in the TLC path. The path is specified in the ASAP2 setup file, asap2setup.tlc.

Defining Parameter Groups.   In some cases you must group multiple parameters together in the ASAP2 file (for example, the x and y data in a 1-D Lookup Table block). Parameter groups enable Simulink blocks to define an associative relationship between some or all of their parameters. The following example shows the Lookup1D parameter group and describes how to create and use parameter groups in conjunction with the ASAP2 file generation process.

The BlockInstanceSetup function, within a block's TLC file, creates parameter groups. There are two built-in TLC functions that facilitate this process: SLibCreateParameterGroup and SLibAddMember. The following code fragment creates the Lookup1D parameter group in look_up.tlc. Similar syntax is used to create parameter groups for the Look-Up Table (2D) block, the Fixed-Point Blockset Look-Up Table block, and the Look-Up Table (2-D) block:

ParameterGroup records are not written to the model.rtw file, but are included as part of the relevant Block records in the CompiledModel. The following code fragment shows the Lookup1D parameter group. The Lookup1D parameter group has two Member records. The Reference fields of these records refer to the relevant x and y data records in the GlobalMemoryMap:

The Lookup1D parameter group is used by the function ASAP2UserFcnWriteCharacteristic_Lookup1D, which is defined in the template definition file, asap2lookup1d.tlc. This function uses the parameter group to obtain the references to the associated x and y data records in the GlobalMemoryMap, as shown in the following code fragment.

Creating Template Definition Files.   This section describes the components that make up an ASAP2 template definition file. This description is in the form of code examples from asap2lookup1d.tlc, the template definition file for the Lookup1D template. This template corresponds to the Lookup1D parameter group.

The following sections describe the components of an ASAP2 template definition file.

Template Registration Function.   The input argument is the name of the parameter group associated with this template:

RECORD_LAYOUT Name Definition Function.   Record layout names (aliases) can be arbitrarily specified for each data type. This function is used by the other components of this file.

Function to Write RECORD_LAYOUT Definitions.   This function writes out RECORD_LAYOUT definitions associated with this template. The function is called by the built-in functions involved in the ASAP2 file generation process. The function name must be defined as shown, with the appropriate template name after the underscore:

Function to Write the CHARACTERISTIC.   This function writes out the CHARACTERISTIC associated with this template. The function is called by the built-in functions involved in the ASAP2 file generation process. The function name must be defined as shown, with the appropriate template name after the underscore.

The input argument to this function is a pointer to a parameter group record. The example shown is for a Lookup1D parameter group that has two members. The references to the associated x and y data records are obtained from the parameter group record as shown.

This function calls a number of built-in functions to obtain the required information. For example, LibASAP2GetSymbol returns the symbol (name) for the specified data record.


  Generating an ASAP2 File Structure of the ASAP2 File