Hi Christophe,
The error you're encountering, 'Stateflow:Runtime:DataOverflowErrorMSLD', indicates a data overflow problem in your Stateflow model within MATLAB's Simulink Test Manager. This error often arises when a variable exceeds its maximum value that can be represented by its data type, leading to a wrap-around effect.
In the context of your code, the issue seems related to the bitwise operations you're performing. Specifically, this line:
B_stream_10ms_busA.FRAME_EXTSYS_STATE.BAT_STARTUP = ((A_data64_bigend[0] << 5)>>63);
and similar lines are shifting bits and potentially causing an overflow.
Here are a few steps to troubleshoot and resolve the issue:
- Check Data Types: Ensure that the data types of the variables involved in the bitwise operations are large enough to handle the values after shifting. If 'A_data64_bigend' is not of a sufficiently large data type, the shift operation could cause an overflow.
- Review Shift Operations: Bitwise shift operations can easily result in values that exceed the data type's limits. Ensure that your shift logic is correct and does not cause values to exceed these limits.
- Explicit Type Casting: If necessary, you can explicitly cast your variables to larger data types before performing the shift operations. This can prevent unintended overflows.
- Debugging Stateflow: Use Stateflow debugging tools to step through the state machine execution. This can help you pinpoint the exact location and cause of the data overflow.
- Model Configuration: Since the error does not appear when updating (compiling) the model, there might be a difference in the way variables are initialized or handled between the compilation and the test run. Ensure that your model's configuration parameters are consistent between these stages.
Here's an example of how you might modify the code to include explicit type casting to a larger data type (if applicable):
tempVar = uint64(A_data64_bigend[0]);
B_stream_10ms_busA.FRAME_EXTSYS_STATE.BAT_STARTUP = bitshift(bitshift(tempVar, 5), -63);
Remember, the key is to ensure that the intermediate values produced during the shift operations do not exceed the range of the data type. If 'uint64' is not sufficient, you may need to consider an even larger data type or revise your approach to avoid such large intermediate values.
Hope this helps!