Main Content

Guidelines for Using Atomic Subcharts

An atomic subchart is a graphical object that helps you to create independent subcomponents in a Stateflow® chart. Atomic subcharts are not supported in standalone Stateflow charts in MATLAB®. For more information, see Create Reusable Subcomponents by Using Atomic Subcharts.

Chart Properties and Atomic Subcharts

Do Not Use Moore Charts as Atomic Subcharts

Moore charts do not have the same simulation behavior as Classic Stateflow charts with the same constructs.

Do Not Use Atomic Subcharts in Continuous-Time Charts

Continuous-time charts do not support atomic subcharts.

Avoid Using Atomic Subcharts in Charts That Execute at Initialization

You get a warning when the following conditions are true:

  • The chart property Execute (enter) Chart At Initialization is enabled.

  • The default transition path of the chart reaches an atomic subchart.

If an entry action inside the atomic subchart requires access to a chart input or data store memory, you can get inaccurate results. To avoid this warning, you can disable Execute (enter) Chart At Initialization or redirect the default transition path away from the atomic subchart.

For more information about execute-at-initialization behavior, see Execution of a Chart at Initialization.

Use Consistent Settings for Super Step Semantics

When you use linked atomic subcharts, verify that your settings for super step semantics match the settings in the main chart. For more information, see Super Step Semantics.

Data in Atomic Subcharts

Define Data in an Atomic Subchart Explicitly

Be sure to define data that appears in an atomic subchart explicitly in the main chart. Atomic subcharts can only access main chart data whose size, type, and complexity are fully specified. For more information, see Set Data Properties.

Map Variables of Linked Atomic Subcharts

When you use linked atomic subcharts, map the variables so that data in the subchart corresponds to the correct data in the main chart. Map subchart variables manually if, when you add the subchart, the variables do not have the same names as the corresponding symbols in the main chart. For more information, see Map Variables for Atomic Subcharts and Boxes.

Match Size, Type, and Complexity of Variables in Linked Atomic Subcharts

Verify that the size, type, and complexity of variables in a subchart match the settings of the corresponding variables in the main chart. For more information, see Map Variables for Atomic Subcharts and Boxes.

Do Not Use Variable-Size Data in Atomic Subcharts

Atomic subcharts do not support variable-sized input or output arrays.

Do Not Change the First Index of Local Data to a Nonzero Value

When a data store memory in an atomic subchart maps to chart-level local data, the First index property of the local data must remain zero.

Do Not Log Signals from Atomic Subcharts That Map Variables with Different Scopes

If an atomic subchart maps variables to variables at the main chart level with a different scope, you cannot log signals for the chart.

Avoid Using the Names of Subsystem Parameters in Atomic Subcharts

If a parameter in an atomic subchart matches the name of a Simulink® built-in subsystem parameter, the only mapping allowed for that parameter is Inherited. Specifying any other parameter mapping in the Mappings tab of the properties dialog box causes an error. You can, however, change the parameter value at the MATLAB prompt so that all instances of that parameter have the same value.

To get a list of Simulink subsystem parameters, enter:

param_list = sort(fieldnames(get_param("built-in/subsystem", ...
    "ObjectParameters")));

Events in Atomic Subcharts

Do Not Mix Edge-Triggered and Function-Call Input Events in The Same Atomic Subchart

Input events in an atomic subchart must all use edge-triggered type, or they must all use function-call type. This restriction is consistent with the behavior for the container chart. For more information, see Best Practices for Using Events in Stateflow Charts.

Do Not Use Outgoing Transitions When an Atomic Subchart Uses Top-level Local Events

You cannot use outgoing transitions from an atomic subchart that uses local events at the top level of the subchart. Using this configuration causes a simulation error.

Match the Trigger Type When Mapping Input Events

Each input event in an atomic subchart must map to an input event of the same trigger type in the container chart.

Do Not Map Multiple Input Events in an Atomic Subchart to the Same Input Event in the Container Chart

Each input event in an atomic subchart must map to a unique input event in the container chart. You can verify unique mappings of input events by opening the properties dialog box for the atomic subchart and checking the Input Event Mapping section of the Mappings tab.

Functions and Atomic Subcharts

Export Chart-Level Functions If Called from an Atomic Subchart

If your atomic subchart contains a function call to a chart-level function, export that function by selecting Export Chart Level Functions. Do not export graphical functions from an atomic subchart that maps variables to variables at the main chart level with a different scope. For more information, see Export Stateflow Functions for Reuse.

Restrictions for Converting to Atomic Subcharts

Data, Graphical Functions, and Events

To convert a state or subchart to an atomic subchart, access to objects not parented by the state or subchart must be one of the following:

  • Chart-level data

  • Chart-level graphical functions

  • Input events

If the state or subchart accesses a chart-level graphical function, the chart must export that function. For more information, see Export Stateflow Functions for Reuse.

Do not export graphical functions from an atomic subchart that maps variables to variables at the main chart level with a different scope.

Local Data with a Nonzero First Index

The state or subchart that you want to convert to an atomic subchart cannot access local data where the First index property is nonzero. For the conversion process to work, the First index property of the local data must be zero, which is the default value.

Event Broadcasts

The state or subchart that you want to convert to an atomic subchart cannot refer to:

  • Local events that are outside the scope of that state or subchart

  • Output events

The state or subchart you want to convert can refer to input events.

Messages

If a state or subchart contains messages, you cannot convert it to an atomic subchart.

Masked Library Chart

You cannot use a masked library chart containing mask parameters as an atomic subchart.

Related Topics