model_step

Step routine entry point in generated code for Simulink model

Syntax

void model_step(void)
void model_stepN(void)

Calling Interfaces

The model_step default function prototype varies depending on the setting of model configuration parameter Treat each discrete rate as a separate task (Simulink) (EnableMultiTasking) :

Parameter ValueFunction Prototype
Off
(single rate or multirate)
void model_step(void);
On
(multirate)
void model_stepN (void);
(N is a task identifier)

The calling interface generated for this function also differs depending on the value of the model configuration parameter Code interface packaging:

  • C++ class (default for C++ language) — Generated function is encapsulated into a C++ class method. Required model data is encapsulated into C++ class attributes.

  • Nonreusable function (default for C language) — Generated function passes (void). Model data structures are statically allocated, global, and accessed directly in the model code.

  • Reusable function — Generated function passes the real-time model data structure, by reference, as an input argument. The real-time model data structure is exported with the model.h header file.

    For an ERT-based model, you can use model configuration parameter Pass root-level I/O as to control how root-level input and output arguments are passed to the function. They can be included in the real-time model data structure, passed as individual arguments, or passed as references to an input structure and an output structure.

If you have an Embedded Coder® license:

Description

The generated model_step function contains the output and update code for the blocks in a Simulink® model. The model_step function computes the current value of the blocks. If logging is enabled, model_step updates logging variables. If the model's stop time is finite, model_step signals the end of execution when the current time equals the stop time.

Under the following conditions, model_step does not check the current time against the stop time:

  • The model's stop time is set to inf.

  • Logging is disabled.

  • Parameter Terminate function required is not selected.

If one or more of these conditions are true, the program runs indefinitely.

For a GRT- or ERT-based model, the software generates a model_step function when model configuration parameter Single output/update function is selected (the default).

model_step is designed to be called at interrupt level from rt_OneStep, which is assumed to be invoked as a timer ISR. rt_OneStep calls model_step to execute processing for one clock period of the model. For a description of how calls to model_step are generated and scheduled, see rt_OneStep and Scheduling Considerations (Embedded Coder).

If model configuration parameter Single output/update function is not selected, the software generates these model entry-point functions in place of model_step:

  • model_output: Contains the output code for the blocks in the model

  • model_update: Contains the update code for the blocks in the model

Introduced before R2006a