Compare and Merge State Transition Tables and Truth Tables
You can use the Comparison Tool (Simulink) to compare and merge the contents of State Transition Table and Truth Table blocks. You can compare two versions of a block and identify the changes to conditions, actions, states, and rows between the blocks, and then can combine the content of the two blocks. For more information, see Review Changes in Simulink Models (Simulink).
For more information on using State Transition Table blocks in Stateflow®, see Model Finite State Machines Using State Transition Tables.
For more information on using Truth Table blocks in Stateflow, see Use Truth Tables to Model Combinatorial Logic.
Detect Changes
When you use the Comparison Tool on two models that includes a State Transition Table or a Truth Table block, you can detect these differences:
Conditions that trigger transitions between states.
Actions that are executed upon a transition.
States that serve as the origin or target of a transition.
Order of rows or columns.
Addition or deletion of rows or columns.
The tool highlights the differences between the State Transition Table or Truth Table block versions by using color-coded highlighting.
Blue: Highlights new content
Yellow: Highlights removed content
Purple: Highlights modified content
In this image, the Comparison Tool compares a modified version of a model,
sf_stt_boiler2.slx
, to the original version,
sf_stt_boiler.slx
. This Simulink® model includes a State Transition Table block.
In sf_stt_boiler2.slx
, a new substate was added. The transition
condition and actions in the Warmup
state are different.
Merge Changes
After comparing the changes between the State Transition Table or Truth Table blocks, you can merge the changes between the two blocks. To merge the changes:
Select the desired modifications to tailor the merge process, and fit the merge process to your requirements.
Address any conflicts that may arise during the merge process, ensuring a consistent and coherent final table.
Implement the selected modifications, then create a new version of the State Transition Table block or Truth Table block that integrates the desired changes. To save the new version, click Save Result.
In this image, the Target pane lists the differences between the two blocks. By selecting the version you want to keep for each change, you can create a new merged file.
In the merged model, the new substate, Alarm_1
remains, but the
transition condition and action in the Warmup
state revert to the
original version.
Note
Merging child decomposition to parallel (AND) is not supported for states that contain history junctions or default transition paths.
Best Practices and Considerations
Before initiating the merge process, make a backup copy of your Stateflow chart to preserve the original version in case any issues arise.
Thoroughly examine each change to fully understand its impact and ensure its appropriateness.
Use the Comparison Tool with a version control system to track changes and manage different versions of your Stateflow chart.
When merging states in different models, the tool matches states based on hierarchy index and row type rather than state names, which can lead to unexpected behavior when moving or merging states.
You can not insert default transition paths in the target model if the parent state has no child state rows.
If you change the decomposition from parallel to exclusive, the default transition in the merged model is on the first state, regardless of the configuration of the original model.
History junction rows from the models cannot be merged if:
The decomposition of the parent state is parallel (AND)
The state has no child state rows
When you merge State Transition Table blocks, manually check:
Transition paths that use several junctions or branching paths
State transition tables with many rows or layers of hierarchy
See Also
State Transition Table | Comparison Tool (Simulink)