Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Code Regeneration in Accelerated Models

Structural Changes That Cause Rebuilds

Changing the structure of your model causes the Rapid Accelerator mode to regenerate the standalone executable, and for the Accelerator mode to regenerate the target code and update (overwrite) the existing MEX-file.

Examples of model structure changes that result in a rebuild include:

Determining If the Simulation Will Rebuild

The Accelerator and Rapid Accelerator modes use a checksum to determine if the model has changed, indicating that the code should be regenerated. The checksum is an array of four integers computed using an MD5 checksum algorithm based on attributes of the model and the blocks it contains.

Use the Simulink.BlockDiagram.getChecksum command to obtain the checksum for your model. For example:

cs1 = Simulink.BlockDiagram.getChecksum('myModel');

Obtain a second checksum after you have altered your model. The code regenerates if the new checksum does not match the previous checksum. You can use the information in the checksum to determine why the simulation target rebuilt. For a detailed explanation of this procedure, see the demo model slAccelDemoWhyRebuild.

Parameter Handling in Rapid Accelerator Mode

In terms of model rebuilds, Block Diagram and Run-time parameters are handled differently than other parameters in rapid accelerator mode.

Some Block Diagram parameters can be changed during simulation without causing a rebuild. These Block Diagram parameters include the following:

BLOCK DIAGRAM PARAMETERS THAT DO NOT REQUIRE RAPID ACCELERATOR REBUILD
Solver ParametersLoading and Logging Parameters
  
AbsTolDecimation
ConsecutiveZCsStepRelTolFinalStateName
ExtrapolationOrderInitialState
InitialStepLimitDataPoints
MaxConsecutiveMinStepLoadExternalInput
MaxConsecutiveZCsLoadInitialState
MaxNumMinStepsMaxDataPoints
MaxOrderOutputOption
MaxStepOutputSaveName
MinStepSaveFinalState
NumberNwtonIterationsSaveFormat
OutputTimesSaveOutput
RefineSaveState
RelTolSaveTime
SolverNameSignalLogging
StartTimeSignalLoggingName
StopTimeStateSaveName
ZCDetectionTolTimeSaveName

Run-time parameters are collected within an rtp structure either by user specification via a simset option or through automatic collection during the compile phase. Changes to the Run-time parameters are supported if they are passed directly to sim. However, if they are passed graphically via the block diagram or programmatically via the set_param command, then a rebuild may be necessary. All other parameter changes may necessitate a rebuild.

Parameter Changes:Passed Directly to sim commandPassed Graphically via Block Diagram or via set_param command
   
Run-timeRebuild Not RequiredRebuild May Be Required
Block Diagram (Solver and Logging Parameters)Rebuild Not RequiredRebuild Not Required
OtherRebuild May Be RequiredRebuild May Be Required

  


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