-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type of index variables #20
Comments
The reason for the "signed char" choice was that, at least in some cases, I am using the value -1 to encode an invalid or not yet defined value. I am not really worried about users wanting to define state machines with more than 127 states or procedures with more than 127 as I think that this would be very unlikely (and probably indicative of poor design choices -- one should never have such large state machines or procedures). In any cases, all types are defined through typedef and users, if they really wanted to, could extend the type of their variables. The argument about speed and memory footprint is appreciated but I am not sure it is completely correct. I would imagine, for instance, that the state machine and procedure descriptors would become larger if we switch from "signed char" to "signed int" (I am assuming that the compiler would "pack" the data structures representing the descriptors). One final point: when there was a trade-off between memory footprint and speed, I generally gave priority to minimizing memory footprint. The rationale for this choice is as follows. In most realistic scenarios, most of the CPU would be used by the application code which implements the actions and guards of the state machine and procedures. Hence, CPU optimization of the state machine and procedure code would only have a marginal impact on the overall CPU efficiency. |
I agree on the memory footprint minimizing, as less code/data means much faster code because of caching. Ok, if users are expected/allowed to update the data types, then it probably doesn't matter at all and this issue is obsolete. Packing data does indeed save memory for the data, but not for the instructions accessing them. Say, you want to read one element in such a packed 8-bit array on a 32-bit processor. You would need, a) read the 32-bit value where the element is included, b) mask the other elements away, c) shift the value to the correct position. So, three instructions instead of only one when using 32-bit variables. |
Application: OLED Display , STM32L476 some switches, a rotary encoder and a big user menu with a lot of options. I was running in the same problem
in smDesc i found this error message so i debugged this error message and came to this part and then i found this in FwSmConstands.h after changing it to signed int
I agree with
|
I saw that all index variables (e.g. to access action array, nodes, etc) are of type "signed char", so are in the range 0..127. What is the reason for this limitation ? For a big procedure or state machine you would run into problems...
Also, I think it would be much better to use normal "unsigned int" for index variables as the generated code runs much faster (unless you have an 8-bit processor) and requires less code (no masking on variable access).
The text was updated successfully, but these errors were encountered: