| 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… |
|---|
Specifying Parameters in Custom Objectives Specifying Checks in Custom Objectives |
The Code Generation Advisor reviews your model based on objectives that you specify. If the predefined efficiency, traceability, safety precaution, and debugging objectives do not meet your requirements, you can create custom objectives.
You can create custom objectives by:
Creating a new objective and adding parameters and checks to a new objective.
Creating a new objective based on an existing objective, then adding, modifying and removing the parameters and checks within the new objective.
When you create a custom objective, you specify the values of configuration parameters that the Code Generation Advisor reviews using the following methods:
addParam — Add parameters and specify the values that the Code Generation Advisor reviews in Check model configuration settings against code generation objectives. When you add parameters that have dependencies, the software includes the dependencies in the list of parameter values that the Code Generation Advisor reviews.
modifyInheritedParam — Modify inherited parameter values that the Code Generation Advisor reviews in Check model configuration settings against code generation objectives.
removeInheritedParam — Remove inherited parameters from a new objective that is based on an existing objective. When a user selects multiple objectives, if another selected objective includes this parameter, the Code Generation Advisor reviews the parameter value in Check model configuration settings against code generation objectives.
All objectives include the Check model configuration settings against code generation objectives check by default. When you create a custom objective, you specify the list of additional checks that are associated with the custom objective using the following methods:
addCheck — Add checks to the Code Generation Advisor. When a user selects the custom objective, the Code Generation Advisor displays the check, unless the user specifies an additional objective with a higher priority that excludes the check.
For example, you might add a check to the Code Generation Advisor to include a custom check in the automatic model checking process.
excludeCheck — Exclude checks from the Code Generation Advisor. When a user selects multiple objectives, if the user specifies an additional objective that includes this check as a higher priority objective, the Code Generation Advisor displays this check.
For example, you might exclude a check from the Code Generation Advisor when a check takes a long time to process.
removeInheritedCheck — Remove inherited checks from a new objective that is based on an existing objective. When a user selects multiple objectives, if another selected objective includes this check, the Code Generation Advisor displays the check.
For example, you might remove an inherited check, rather than exclude the check, when the check takes a long time to process, but the check is important for another objective.
When you base a new objective on an existing objective, you can determine what checks and parameters the existing objective contains. Select the existing objective and check the model. The Code Generation Advisor lists the checks and parameters associated with the existing objective.
The Code Generation Advisor contains the list of checks in each objective. For example, the Efficiency objective includes ten checks, which you can see in the Code Generation Advisor if you:
Open the rtwdemo_rtwecintro model.
Specify an ERT-based target.
Specify the Efficiency objective.
Check the model.
The Code Generation Advisor displays in the right pane the list of checks in the Efficiency objective.

Caution The following objectives exclude the listed checks. For more information about excluding checks, see excludeCheck.
|
The first check, Check model configuration settings against code generation objectives, lists all parameters and values specified by the objective. For example, the Code Generation Advisor displays the list of parameters and the recommended values in the Efficiency objective, if you:
Run Check model configuration settings against code generation objectives.
Click Modify Parameters.
Rerun the check.
The Code Generation Advisor displays in the check results the list of parameters and recommended values in the Efficiency objective.

To create a custom objective:
Create an sl_customization.m file.
Note
|
Create an sl_customization function that takes a single argument. When the software invokes the function, the value of this argument is the Simulink customization manager. In the function:
Create a handle to the code generation objective, using the ObjectiveCustomizer constructor.
Register a callback function for the custom objectives, using the ObjectiveCustomizer.addCallbackObjFcn method.
Add a call to execute the callback function, using the ObjectiveCustomizer.callbackFcn method.
For example
function sl_customization(cm)
%SL_CUSTOMIZATION objective customization callback
objCustomizer = cm.ObjectiveCustomizer;
index = objCustomizer.addCallbackObjFcn(@addObjectives);
objCustomizer.callbackFcn{index}();
endCreate a callback function which includes M-code to:
Create code generation objective objects using the rtw.codegenObjectives.Objective constructor.
Add, modify, and remove configuration parameters for each objective using the addParam, modifyInheritedParam, and removeInheritedParam methods.
Include and exclude checks for each objective using the addCheck, excludeCheck, and removeInheritedCheck methods.
Register objectives using the register method.
The following example shows you how to create an objective, Reduce RAM Example. Reduce RAM Example includes five parameters and three checks that the Code Generation Advisor reviews:
function addObjectives
% Create the custom objective
obj = rtw.codegenObjectives.Objective('ex_ram_1');
setObjectiveName(obj, 'Reduce RAM Example');
% Add parameters to the objective
addParam(obj, 'InlineParams', 'on');
addParam(obj, 'BooleanDataType', 'on');
addParam(obj, 'OptimizeBlockIOStorage', 'on');
addParam(obj, 'EnhancedBackFolding', 'on');
addParam(obj, 'BooleansAsBitfields', 'on');
% Add additional checks to the objective
% The Code Generation Advisor automatically includes 'Check model
% configuration settings against code generation objectives' in every
% objective.
addCheck(obj, 'Identify unconnected lines, input ports, and output ports');
addCheck(obj, 'Check model and local libraries for updates');
%Register the objective
register(obj);
endThe following example shows you how to create an objective, My Traceability Example, based on the existing Traceability objective. The custom objective modifies, removes, and adds parameters that the Code Generation Advisor reviews. It also adds and removes checks from the Code Generation Advisor:
function addObjectives
% Create the custom objective from an existing objective
obj = rtw.codegenObjectives.Objective('ex_my_trace_1', 'Traceability');
setObjectiveName(obj, 'My Traceability Example');
% Modify parameters in the objective
modifyInheritedParam(obj, 'GenerateTraceReportSf', 'Off');
removeInheritedParam(obj, 'ConditionallyExecuteInputs');
addParam(obj, 'MatFileLogging', 'On');
% Modify checks in the objective
addCheck(obj, 'Identify questionable software environment specifications');
removeInheritedCheck(obj, 'com.mathworks.MA.CheckDisableSignalLogging');
%Register the objective
register(obj);
endIf you previously opened the Code Generation Advisor, close the model from which you opened the Code Generation Advisor.
Refresh the customization manager. At the MATLAB command line, enter the sl_refresh_customizations command.
Open your model and review the new objectives.
![]() | Determining Whether the Model is Configured for Specified Objectives | Choosing and Configuring an Embedded Real-Time Target | ![]() |

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 |