Applying Memory Sections

Assigning Memory Sections to Custom Storage Classes

To assign a memory section to a custom storage class,

  1. Choose View > Model Explorer in the model window.

    The Model Explorer appears.

  2. Choose Tools > Custom Storage Class Designer in the Model Explorer window.

    A notification box appears that states Please Wait ... Finding Packages. After a brief pause, the notification box closes and the Custom Storage Class Designer appears.

  3. Select the Custom Storage Class tab. The Custom Storage Class pane looks like this:

  4. Select the desired custom storage class in the Custom storage class definitions pane.

  5. Select the desired memory section from the Memory section pull-down.

  6. Click Apply to apply changes to the open copy of the model; Save to apply changes and save them to disk; or OK to apply changes, save changes, and close the Custom Storage Class Designer.

Generated code for all data definitions in the specified custom storage class will be enclosed in the pragmas of the specified memory section. The pragmas can surround contiguous blocks of definitions or each definition separately, as described in Surrounding Individual Definitions with Pragmas. For more information, see Creating Packages with CSC Definitions.

Applying Memory Sections to Model-Level Functions and Internal Data

When using the Real-Time Workshop Embedded Coder software, you can apply memory sections to the following categories of model-level functions:

Function CategoryFunction Subcategory
Initialize/Terminate functionsInitialize/Start
Terminate
Execution functionsStep functions
Run-time initialization
Derivative
Enable
Disable

When using the Real-Time Workshop Embedded Coder software, you can apply memory sections to the following categories of internal data:

Data CategoryData DefinitionData Purpose
Constantsmodel_cPConstant parameters
model_cBConstant block I/O
model_ZZero representation
Input/Outputmodel_URoot inputs
model_YRoot outputs
Internal datamodel_BBlock I/O
model_DD-work vectors
model_MRun-time model
model_ZeroZero-crossings
Parametersmodel_PParameters

Memory section specifications for model-level functions and internal data apply to the top level of the model and to all subsystems except atomic subsystems that contain overriding memory section specifications, as described in Applying Memory Sections to Atomic Subsystems.

To specify memory sections for model-level functions or internal data,

  1. Open the Model Explorer and select Configuration (Active) > Real-Time Workshop > General. (Alternatively, choose Simulation > Configuration Parameters in the model window.)

  2. Ensure that the System target file is an ERT target, such as ert.tlc .

  3. Select the Memory Sections tab. The Memory Sections pane looks like this:

  4. Initially, the Package field specifies ---None--- and the pull-down lists only built-in packages. If you have defined any packages of your own, click Refresh package list. This action adds all user-defined packages on your search path to the package list.

  5. In the Package pull-down, select the package that contains the memory sections that you want to apply.

  6. In the pull-down for each category of internal data and model-level function, specify the memory section (if any) that you want to apply to that category. Accepting or specifying Default omits specifying any memory section for that category.

  7. Click Apply to save any changes to the package and memory section selections.

Applying Memory Sections to Atomic Subsystems

For any atomic subsystem whose generated code format is Function or Reusable Function, you can specify memory sections for functions and internal data that exist in that code format. Such specifications override any model-level memory section specifications. Such overrides apply only to the atomic subsystem itself, not to any subsystems within it. Subsystems of an atomic subsystem inherit memory section specifications from the top-level model, not from the containing atomic subsystem.

To specify memory sections for an atomic subsystem,

  1. Right-click the subsystem in the model window.

  2. Choose Subsystem Parameters from the context menu. The Function Block Parameters: Subsystem dialog box appears.

  3. Ensure that Treat as atomic unit is checked. Otherwise, you cannot specify memory sections for the subsystem.

    For an atomic system, you can use the Real-Time Workshop system code field to control the format of the generated code.

  4. Ensure that Real-Time Workshop system code is Function or Reusable function. Otherwise, you cannot specify memory sections for the subsystem.

  5. If the code format is Function and you want separate data, check Function with separate data.

    The Real-Time Workshop pane now shows all applicable memory section options. The available options depend on the values of Real-Time Workshop system code and the Function with separate data check box. When the former is Function and the latter is checked, the pane looks like this:

  6. In the pull-down for each available definition category, specify the memory section (if any) that you want to apply to that category.

  7. Click Apply to save changes, or OK to save changes and close the dialog box.

It is not possible to specify the memory section for a subsystem in a library. However, you can specify the memory section for the subsystem after you have copied it into a Simulink model. This is because in the library it is unknown what code generation target will be used. You can copy a library block into many different models with different code generation targets and different memory sections available.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS