Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop Embedded Coder   

Configuring Model Function Prototypes

Launching the Model Interface Dialog Boxes

Clicking the Configure Model Functions button on the Interface pane of the Configuration Parameters dialog box launches the Model Interface dialog box. This dialog box is the starting point for configuring the model function prototypes that are generated during code generation for ERT-based Simulink models. Based on the Function specification value you select for your model function (supported values include Default model initialize and step functions and Model specific C prototypes), you can preview and modify the function prototype. Once you validate and apply your changes, you can generate code based on your function prototype modifications.

To configure function prototypes for a right-click build of a nonvirtual subsystem, invoke the RTW.configSubsystemBuild function, which launches the Model Interface for subsystem dialog box. For more information, see Configuring Function Prototypes for Nonvirtual Subsystems

Default Model Initialize and Step Functions View

The figure below shows the Model Interface dialog box in the Default model initialize and step functions view.

The Default model initialize and step functions view allows you to validate and preview the predicted default model step and initialization function prototypes. To validate the default function prototype configuration against your model, click the Validate button. If the validation succeeds, the predicted step function prototype appears in the Step function preview subpane.

Model Specific C Prototypes View

Selecting Model specific C prototypes for the Function specification parameter displays the Model specific C prototypes view of your model function prototypes. This view provides controls that you can use to customize the function names, the order of arguments, and argument attributes including name, passing mechanism, and type qualifier for each of the model's root-level I/O ports.

To begin configuring your function control prototype configuration, click the Get Default Configuration button. This activates and initializes the function names and properties in the Configure model initialize and step functions subpane, as shown below. If you click Get Default Configuration again later, only the properties of the step function arguments are reset to default values.

In the Configure model initialize and step functions subpane:

ParameterDescription
Step function nameName of the model_step function.
Initialize function nameName of the model_init function.
OrderOrder of the argument. A return argument is listed as Return.
Port NameName of the port.
Port TypeType of the port.
CategorySpecifies how an argument is passed in or out from the customized step function, either by copying a value (Value) or by a pointer to a memory space (Pointer).
Argument NameName of the argument.
Qualifier (optional)

Specifies a const type qualifier for a function argument. The available values are dependent on the Category specified. When you change the Category, if the specified type is no longer available, the Qualifier changes to none. The possible values are:

  • none

  • const (value)

  • const* (value referenced by the pointer)

  • const*const (value referenced by the pointer and the pointer itself)

    Tip   When a model includes a referenced model, the const type qualifier for the root input argument of the referenced model's specified step function interface is set to none, and the qualifier for the source signal in the referenced model's parent is set to a value other than none, Real-Time Workshop honors the referenced model's interface specification by generating a type cast that discards the const type qualifier from the source signal. To override this behavior, add a const type qualifier to the referenced model.

The Step function preview subpane provides a preview of how your step function prototype is interpreted in generated code. The preview is updated dynamically as you make modifications.

An argument foo whose Category is Pointer is previewed as * foo. If its Category is Value, it is previewed as foo. Notice that argument types and qualifiers are not represented in the Step function preview subpane.

Configuring Function Prototypes for Nonvirtual Subsystems

You can control step and initialization function prototypes for nonvirtual subsystems in ERT-based Simulink models, if you generate subsystem code using right-click build. Function prototype control is supported for the following types of nonvirtual subsystems:

To launch the Model Interface for Subsystem dialog box, open the model containing the subsystem and invoke the RTW.configSubsystemBuild function.

The Model Interface dialog box for modifying the model-specific C prototypes for the rtwdemo_counter/Amplifier subsystem appears as follows:

Right-click building the subsystem generates the step and initialization functions according to the customizations you make.

  


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