Model Code Interfaces
To produce code that can interact between model elements , the code generator must be aware of interface requirements. The first step for doing that is to represent required interfaces in your top model by including specific model elements. For example, you can model an interface for reading data from a model elementby using a root-level In Bus Element or Inport block.
This table lists typical code interfaces and ways to represent them in a top model.
|Type of Code Interface||Model Element or Pattern|
|Callable rate-based entry point||Block in a rate-based model that is configured for single-tasking or multitasking execution or that is set up as a partition in the Simulink Schedule Editor|
|Callable initialize function entry point||Initialize Function block|
|Callable terminate function entry point||Terminate Function block|
|Call to target platform receiver service||In Bus Element or Inport block|
|Call to target platform sender service||Out Bus Element or Outport block|
|Access target platform nonvolatile memory||Initialize Function and Terminate Function blocks or Simulink Function and Function Caller blocks|
|Reuse memory between a state variable and root-level output variable||Function loopback pattern that models state variable as a signal or Delay block that models state variable|
|Message communication||Send block directly connected to a root-level Outport block and Receive block directly connected to a root-level Inport block|
|Client-server communication||Simulink Function and Function Caller blocks|
|Tunable parameters and parameter arguments||Parameter objects stored in the model workspace|
|Data for measurement||Signals (output port of a block), states (states on a block), and Datastore Memory blocks|
|Custom service interface||Custom blocks|
These topics provide more information for the different types of interfaces:
Modeling guidelines can be helpful depending on your deployment objective and how you configure code interfaces for the code generator. In some cases, you might need to create custom representations that involve creating custom blocks.
For information on modeling guidelines, see Modeling Guidelines and Block Usage.
For information on creating custom blocks, see Code Generation for Custom Blocks.