| Real-Time Workshop® Embedded Coder™ | ![]() |
| On this page… |
|---|
Simulink.CustomParameter Class Instance-Specific Attributes for Older Storage Classes Assigning a Custom Storage Class to Data |
In releases prior to Real-Time Workshop Embedded Coder version 4.0 (MATLAB Release 14), custom storage classes were implemented with special Simulink.CustomSignal and Simulink.CustomParameter classes. This section describes these older classes.
Note Models that use the Simulink.CustomSignal and Simulink.CustomParameter classes continue to operate correctly. The current CSCs support a superset of the functions of the older classes. Therefore, you should consider using the Simulink.Signal and Simulink.Parameter classes instead (see Compatibility Issues for Older Custom Storage Classes). |
This class is a subclass of Simulink.Parameter. Objects of this class have expanded RTWInfo properties. The properties of Simulink.CustomParameter objects are:
RTWInfo.StorageClass. This property should always be set to the default value, Custom.
RTWInfo.CustomStorageClass. This property takes on one of the enumerated values described in the tables below. This property controls the generated storage declaration and code for the object.
RTWInfo.CustomAttributes. This property defines additional attributes that are exclusive to the class, as described in Instance-Specific Attributes for Older Storage Classes.
Value. This property is the numeric value of the object, used as an initial (or inlined) parameter value in generated code.
This class is a subclass of Simulink.Signal. Objects of this class have expanded RTWInfo properties. The properties of Simulink.CustomSignal objects are:
RTWInfo.StorageClass. This property should always be set to the default value, Custom.
RTWInfo.CustomStorageClass. This property takes on one of the enumerated values described in the tables below. This property controls the generated storage declaration and code for the object.
RTWInfo.CustomAttributes. This optional property defines additional attributes that are exclusive to the storage class, as described in Instance-Specific Attributes for Older Storage Classes.
The following tables summarize the predefined custom storage classes for Simulink.CustomSignal and Simulink.CustomParameter objects. The entry for each class indicates
Name and purpose of the class.
Whether the class is valid for parameter or signal objects. For example, you can assign the storage class Const to a parameter object. This storage class is not valid for signals, however, since signal data (except for the case of invariant signals) is not constant.
Whether the class is valid for complex data or nonscalar (wide) data.
Data types supported by the class.
The first three classes, shown in Const, ConstVolatile, and Volatile Storage Classes (Prior to Release 14), insert type qualifiers in the data declaration.
Const, ConstVolatile, and Volatile Storage Classes (Prior to Release 14)
| Class Name | Purpose | Parameters | Signals | Data Types | Complex | Wide |
|---|---|---|---|---|---|---|
Const | Use const | Y | N | any | Y | Y |
ConstVolatile | Use | Y | N | any | Y | Y |
Volatile | Use volatile | Y | Y | any | Y | Y |
The second set of three classes, shown in ExportToFile, ImportFromFile, and Internal Storage Classes (Prior to Release 14), handles issues of data scope and file partitioning.
ExportToFile, ImportFromFile, and Internal Storage Classes (Prior to Release 14)
| Class Name | Purpose | Parameters | Signals | Data Types | Complex | Wide |
|---|---|---|---|---|---|---|
ExportToFile | Generate and include | Y | Y | any | Y | Y |
ImportFromFile | Include predefined | Y | Y | any | Y | Y |
Internal | Declare and define global | Y | Y | any | Y | Y |
The final three classes, shown in BitField, Define, and Struct Storage Classes (Prior to Release 14), specify the data structure or construct used to represent the data.
BitField, Define, and Struct Storage Classes (Prior to Release 14)
| Class Name | Purpose | Parameters | Signals | Data types | Complex | Wide |
|---|---|---|---|---|---|---|
BitField | Embed Boolean data | Y | Y | Boolean | N | N |
Define | Represent parameters | Y | N | any | N | N |
Struct | Embed data in a named | Y | Y | any | N | Y |
Some custom storage classes have attributes that are exclusive to the class. These attributes are made visible as members of the RTWInfo.CustomAttributes field. For example, the BitField class has a BitFieldName attribute (RTWInfo.CustomAttributes.BitFieldName).
Additional Properties of Custom Storage Classes (Prior to Release 14) summarizes the storage classes with additional attributes, and the meaning of those attributes. Attributes marked optional have default values and may be left unassigned.
Additional Properties of Custom Storage Classes (Prior to Release 14)
| Storage Class Name | Additional Properties | Description | Optional (has default) |
|---|---|---|---|
ExportToFile | FileName | String. Defines the name of the generated header file within which the global variable declaration should reside. If unspecified, the declaration is placed in model_export.h by default. | Y |
ImportFromFile | FileName | String. Defines the name of the generated header file which to be used in #include directive. | N |
ImportFromFile | IncludeDelimeter | Enumerated. Defines delimiter used for filename in the #include directive. Delimiter is either double quotes (for example, #include "vars.h") or angle brackets (for example, #include <vars.h>). The default is quotes. | Y |
BitField | BitFieldName | String. Defines name of bit field in which data is embedded; if unassigned, the name defaults to rt_BitField. | Y |
Struct | StructName | String. Defines name of the struct in which data is embedded; if unassigned, the name defaults to rt_Struct. | Y |
You can create custom parameter or signal objects from the MATLAB command line. For example, the following commands create a custom parameter object p and a custom signal object s:
p = Simulink.CustomParameter s = Simulink.CustomSignal
After creating the object, set the RTWInfo.CustomStorageClass and RTWInfo.CustomAttributes fields. For example, the following commands sets these fields for the custom parameter object p:
p.RTWInfo.CustomStorageClass = 'ExportToFile' p.RTWInfo.CustomAttributes.FileName = 'testfile.h'
Finally, make sure that the RTWInfo.StorageClass property is set to Custom. If you inadvertently set this property to some other value, the custom storage properties are ignored.
The procedure for generating code with data objects that have a custom storage class is similar to the procedure for code generation using Simulink data objects that have built-in storage classes. If you are unfamiliar with this procedure, see the discussion of Simulink data objects in the Working with Data section of the Real-Time Workshop documentation.
To generate code with custom storage classes, you must
Create one or more data objects of class Simulink.CustomParameter or Simulink.CustomSignal.
Set the custom storage class property of the objects, as well as the class-specific attributes (if any) of the objects.
Reference these objects as block parameters, signals, block states, or Data Store memory.
When generating code from a model employing custom storage classes, make sure that the Ignore custom storage classes option is not selected. This is the default for the Real-Time Workshop Embedded Coder software.
When Ignore custom storage classes is selected:
Objects with custom storage classes are treated as if their storage class attribute is set to Auto.
The storage class of signals that have custom storage classes is not displayed on the signal line, even if the Storage class option of the Simulink model editor Format menu is selected.
Ignore custom storage classes lets you switch to a target that does not support CSCs, such as the generic real-time target (GRT), without having to reconfigure your parameter and signal objects.
When using the Real-Time Workshop Embedded Coder software, you can control the Ignore custom storage classes option with the check box in the Real-Time Workshop pane of the Configuration Parameters dialog box.
If you are using a target that does not have a check box for this option (such as a custom target) you can enter the option directly into the TLC options field in the Real-Time Workshop pane of the Configuration Parameters dialog box. The following example turns the option on:
-aIgnoreCustomStorageClasses=1
In Release 14, the full functionality of the Simulink.CustomSignal and Simulink.CustomParameter classes was added to the Simulink.Signal and Simulink.Parameter classes. You should consider replacing the use of Simulink.CustomSignal and Simulink.CustomParameter objects by using equivalent Simulink.Signal and Simulink.Parameter objects.
If you prefer, you can continue to use the Simulink.CustomSignal and Simulink.CustomParameter classes in the current release. Note that the following changes have been implemented in these classes:
The Internal storage class has been removed from the enumerated values of the RTWInfo.CustomStorageClass property. Internal storage class is no longer supported.
For the ExportToFile and ImportFromFile storage classes, the RTWInfo.CustomAttributes.FileName and RTWInfo.CustomAttributes.IncludeDelimeter properties have been obsoleted and combined into a single property, RTWInfo.CustomAttributes.HeaderFile. When specifying a header file, include both the filename and the required delimiter as you want them to appear in generated code, as in the following example:
myobj.RTWInfo.CustomAttributes.HeaderFile = '<myheader.h>';
Prior to Release 14, user-defined CSCs were created by designing custom packages that included the CSC definitions. This technique for creating CSCs is obsolete; see Creating Packages with CSC Definitions for a description of the current procedure, which is much simpler.
If you designed your own custom packages containing CSCs prior to Release 14 you should convert them to Release 14 CSCs. The conversion procedure is described in the next section, Converting Older Packages to Use CSC Registration Files.
A Simulink data class package can be associated with one or more CSC definitions. In Release 14, the linkage between a set of CSC definitions and a package is formed when a CSC registration file (csc_registration.m) is located in the package directory.
Prior to Release 14, user-defined CSCs were created by designing custom packages that included the CSC definitions as part of the package.
The Simulink Data Class Designer supports conversion of older packages to the use of CSC registration files. When such a package is selected in Data Class Designer, a special conversion button is displayed on the Custom Storage Classes pane. This button lets you invoke a conversion procedure; you can then write out all files and directories required to define the package, including a CSC registration file. To convert a package:
You should make a complete backup copy of the package directory before converting the package. After backing up the directory, remove the @ prefix from the backup directory name and make sure that the backup directory is not on the MATLAB path.
Open the Simulink Data Class Designer by typing the following command at the MATLAB command prompt:
sldataclassdesigner
The Data Class Designer loads all packages that exist on the MATLAB path. Select the package to be converted from the Package name menu. Then, click OK.
If you want to store the converted package in a different directory than the original package, enter the desired path in the Parent directory field. This step is optional.
The figure below shows the package my_converted_package. The package definition is stored in d:\work\testConversion.

Click on the Custom Storage Classes pane. The pane displays a message indicating that the package contains obsolete CSC definitions, as shown in this figure.

Below the message text, the pane also contains a button captioned Convert Package to Use CSC Registration File. This button invokes a script that converts the package to use a CSC registration file.
Note that this button does not actually create the CSC registration file. That happens when the package files are written out, as described below.
Click Convert Package to Use CSC Registration File. After conversion, the appearance of the pane changes, as shown below.

Click Confirm Changes. In the Confirm Changes pane, select the package you converted. Add the parent directory to the MATLAB path if necessary. Then, click Write Selected.
You can now view and edit the CSCs belonging to your package in the Custom Storage Class Designer. To do so, type the following command at the MATLAB prompt:
cscdesigner
Note You must launch the CSC Designer with the -advanced motion to edit the attributes of old CSCs because they are defined with user-defined TLC files. |
The Custom Storage Class Designer loads all packages that have a CSC registration file.
Select your converted package from the Select package menu.
The figure below shows the Custom Storage Class Designer displaying the CSCs defined in the package my_converted_package. See Designing Custom Storage Classes and Memory Sections for a description of the operation of the Custom Storage Class Designer.

Note All user-defined CSCs created prior to Release 14 are defined with their own TLC code. As a result, after conversion, the Type is set to Other (as opposed to Unstructured or FlatStructure). See Defining Advanced Custom Storage Class Types for more information. |
Restart your MATLAB session to ensure that your converted package is accessible.
![]() | Custom Storage Class Limitations | Memory Sections | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |