| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Real-Time Workshop Embedded Coder |
| Contents | Index |
| Learn more about Real-Time Workshop Embedded Coder |
| On this page… |
|---|
Create Your Own Parameter and Signal Classes |
Certain data layouts (for example, nested structures) cannot be generated using the standard Unstructured and FlatStructure custom storage class types. You can create a new custom storage class from scratch if you want to generate other types of data. Note that this requires knowledge of TLC programming and use of a special advanced mode of the Custom Storage Class Designer.
The GetSet CSC (see Creating Packages that Support CSC Definitions) is an example of an advanced CSC that is provided with the Real-Time Workshop Embedded Coder software.
The following sections explain how to define advanced CSC types.
The first step is to use the Simulink Data Class Designer to create your own package containing classes derived from Simulink.Parameter or Simulink.Signal. This procedure is described in Creating Packages that Support CSC Definitions.
Add your own object properties and class initialization if desired. For each of your classes, select the Create your own custom storage classes for this class option.
If you have instance-specific properties that are relevant only to your CSC, you should use the Simulink Data Class Designer to create a custom attributes class for the package. A custom attributes class is a subclass of Simulink.CustomStorageClassAttributes. The name, type, and default value properties you set for the custom attributes class define the user view of instance-specific properties.
For example, the ExportToFile custom storage class requires that you set the RTWInfo.CustomAttributes.HeaderFile property to specify a .h file used for exporting each piece of data. See Simulink Package Custom Storage Classes for further information on instance-specific properties.
The next step is to write TLC code that implements code generation for data of your new custom storage class. A template TLC file is provided for this purpose. To create your TLC code, follow these steps:
Create a tlc directory inside your package's @directory (if it does not already exist). The naming convention to follow is
@PackageName/tlc
Copy TEMPLATE_v1.tlc (or another CSC template) from matlabroot/toolbox/rtw/targets/ecoder/csc_templates into your tlc directory to use as a starting point for defining your custom storage class.
Write your TLC code, following the comments in the CSC template file. Comments describe how to specify code generation for data of your custom storage class (for example, how data structures are to be declared, defined, and whether they are accessed by value or by reference).
Alternatively, you can copy a custom storage class TLC file from another existing package as a starting point for defining your custom storage class.
After you have created a package for your new custom storage class and written its associated TLC code, you must register your class definitions with the Custom Storage Class Designer, using its advanced mode.
The advanced mode supports selection of an additional storage class Type, designated Other. The Other type is designed to support special CSC types that cannot be accommodated by the standard Unstructured and FlatStructure custom storage class types. The Other type cannot be assigned to a CSC except when the Custom Storage Class Designer is in advanced mode.
To register your class definitions:
Launch the Custom Storage Class Designer in advanced mode by typing the following command at the MATLAB prompt:
cscdesigner -advanced
Set the Type of the custom storage class to Other. Note that when you do this, the Other Attributes pane is displayed. This pane is visible only for CSCs whose Type is set to Other.

If you specify a customized package, additional options, as defined by the package, also appear on the Other Attributes pane.
Set the properties shown on the Other Attributes pane. The properties are:
Is grouped: Select this option if you intend to combine multiple data objects of this CSC into a single variable in the generated code. (for example, a struct).
TLC file name: Enter the name of the TLC file corresponding to this custom storage class. The location of the file is assumed to be in the /tlc subdirectory for the package, so you should not enter the path to the file.
CSC attributes class name: (optional) If you created a custom attributes class corresponding to this custom storage class, enter the full name of the custom attributes class. (see Create a Custom Attributes Class for Your CSC (Optional)).
Set the remaining properties on the General and Comments panes based on the layout of the data that you wish to generate (as defined in your TLC file).
![]() | Generating Code with Custom Storage Classes | GetSet Custom Storage Class for Data Store Memory | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |