| 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… |
|---|
The GetSet custom storage class is designed to generate specialized function calls to read from (get) and write to (set) the memory associated with a Data Store Memory block, when there is a need to read/write a signal many times in a single model. See Working with Data Stores for information about data stores and the Data Store Memory block.
The GetSet storage class is an advanced CSC: it cannot be represented by the standard Unstructured or FlatStructure custom storage class types. To access the CSC definition for GetSet, you must launch Custom Storage Class designer in advanced mode:
cscdesigner -advanced
GetSet CSC is capable of handling signals other than data stores. GetSet is supported for the outputs of most built-in blocks provided by The MathWorks. However, it is not supported for user-written S-functions. A workaround is to drop a Signal Conversion block at the outport of an S-Function (or unsupported built-in) block and assign the GetSet storage class to the output of the Signal Conversion block.
The next table summarizes the instance-specific properties of the GetSet storage class:
For example, if the GetFunction of signal X is specified as 'get_X' then the generated code calls get_X() wherever the value of X is used. Similarly, if the SetFunction of signal X is specified as 'set_X' then the generated code calls set_X(value) wherever the value of X is assigned.
For wide signals, an additional index argument is passed, so the calls to the get and set functions are get_X(idx) and set_X(idx, value) respectively.
The following restrictions apply to the GetSet custom storage class:
The GetSet custom storage class supports only signals of noncomplex data types.
The GetSet custom storage class is designed for use with the state of the Data Store Memory block
For more details about the definition of the GetSet storage class, look at its associated TLC code in the file
matlabroot\toolbox\simulink\simulink\@Simulink\tlc\GetSet.tlc
The model below contains a Data Store Memory block that resolves to Simulink signal object X. X is configured to use the GetSet custom storage class as follows:
X = Simulink.Signal; X.RTWInfo.StorageClass = `Custom'; X.RTWInfo.CustomStorageClass = `GetSet'; X.RTWInfo.CustomAttributes.GetFunction = `get_X'; X.RTWInfo.CustomAttributes.SetFunction = `set_X'; X.RTWInfo.CustomAttributes.HeaderFile = `user_file.h';

The following code is generated for this model:
/* Includes for objects with custom storage classes. */
#include "user_file.h"
void getset_csc_step(void)
{
/* local block i/o variables */
real_T rtb_DSRead_o;
/* DataStoreWrite: '<Root>/DSWrite' incorporates:
* Inport: '<Root>/In1'
*/
set_X(getset_csc_U.In1);
/* DataStoreRead: '<Root>/DSRead' */
rtb_DSRead_o = get_X();
/* Outport: '<Root>/Out1' */
getset_csc_Y.Out1 = rtb_DSRead_o;
}Note The Data Store Memory block creates a local variable to ensure that its value does not change in the middle of a simulation step. This also avoids multiple calls to the data's GetFunction. |
![]() | Defining Advanced Custom Storage Class Types | Custom Storage Class Implementation | ![]() |

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 |