Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop Embedded Coder   

Specifying the Persistence Level for Signals and Parameters


With this procedure, you can control the persistence level of signal and parameter objects associated with a model. Persistence level allows you to make intermediate variables or parameters global during initial development. At the later stages of development, you can use this procedure to remove these signals and parameters for efficiency. Notice the Persistence Level field on the Model Explorer, as illustrated in the figure below. For descriptions of the properties on the Model Explorer, see Parameter and Signal Property Values.

Notice also the Signal display level and Parameter tune level fields on the Data Placement pane of the Configuration Parameters dialog box, as illustrated in the next figure.

The Signal display level field allows you to specify whether or not the code generator defines a signal data object as global data in the generated code. The number you specify in this field is relative to the number you specify in the Persistence level field. The Signal display level number is for all mpt (module packaging tool) signal data objects in the model. The Persistence level number is for a particular mpt signal data object. If the data object's Persistence level is equal to or less than the Signal display level, the signal appears in the generated code as global data with all of the properties (custom attributes) specified in Creating mpt Data Objects with Data Object Wizard. For example, this would occur if Persistence level is 2 and Signal display level is 5.

Otherwise, the code generator automatically determines how the particular signal data object appears in the generated code. Depending on the settings on the Optimization pane of the Configuration Parameters dialog box, the signal data object could appear in the code as local data and thus have none of the custom attributes you specified for that data object. Or, based on expression folding, the code generator could remove the data object so that it does not appear in the code. (See Tips for Optimizing the Generated Code in the Real-Time Workshop Embedded Coder documentation and Optimizing Generated Code in the Real-Time Workshop documentation for details on optimization.)

The Parameter tune level field allows you to specify whether or not the code generator declares a parameter data object as tunable global data in the generated code.

The number you specify in this field is relative to the number you specify in the Persistence level field. The Parameter tune level number is for all mpt parameter data objects in the model. The Persistence level number is for a particular mpt parameter data object. If the data object's Persistence level is equal to or less than the Parameter tune level, the parameter appears in the generated code with all of the properties (custom attributes) specified in Creating mpt Data Objects with Data Object Wizard, and thus is tunable. For example, this would occur if Persistence level is 2 and Parameter tune level is 5.

Otherwise, the parameter is inlined in the generated code, and Real-Time Workshop settings determine its exact form.

Note that, in the initial stages of development, you may be more concerned about debugging than code size. Or, you may want to ensure that one or more particular data objects appear in the code so that you can analyze intermediate calculations of an equation. In this case, you may want to specify the Parameter tune level (Signal display level for signals) to be higher than Persistence level for some or all mpt parameter (or signal) data objects. This results in larger code size, because the code generator defines the parameter (or signal) data objects as global data, which have all the custom properties you specified. As you approach production code generation, however, you may have more concern about reducing the size of the code and less need for debugging or intermediate analyses. In this stage of the tradeoff, you could make the Parameter tune level (Signal display level for signals) greater than Persistence level for one or more data objects, generate code and observe the results. Repeat until satisfied.

  1. With the model open, in the Configuration Parameters dialog box, click Data Placement under Real-Time Workshop.

  2. Type the desired number in the Signal display level or Parameter tune level field, and click Apply.

  3. In the Model Explorer, type the desired number in the Persistence field for the selected signal or parameter, and click Apply.

  4. Save the model and generate code.

  


Related Products & Applications

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