Comments (3)
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.
from fwprofile.
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.
I did a small test with the Example 3 (example procedure provided in the fwprofile-editor). I compiled for sparc processor with optimization enabled (GR712RC) for signed int and signed char:
text data bss dec hex
56240 3048 2124 61412 efe4 signed char
55536 3064 2204 60804 ed84 signed int
As expected: memory usage for data goes up when using 32-bit index variables, while instructions go down.
from fwprofile.
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
with 125 transitions it worked perfect
then i've to add a new part in the user menu
this gives 133 transitions .
/** Check that the SM is properly configured */
if (FwSmCheckRec(smDesc) != smSuccess) {
printf("The state machine FSMMAIN is NOT properly configured ... FAILURE\n");
in smDesc i found this error message
smUndefinedTransSrc
so i debugged this error message and came to this part
smDesc->errCode = smTooManyOutTrans;
and then i found this in FwSmConstands.h
typedef signed char FwSmCounterS1_t;
after changing it to signed int
typedef signed int FwSmCounterS1_t;
it works again - as expected perfect LOL
/** Type used for signed counters with a "short" range. */
//typedef signed char FwSmCounterS1_t;
/** If there are more then 127 transitions uncomment */
typedef signed int FwSmCounterS1_t;
I agree with
oppm commented on 15 Nov 2016
memory usage for data goes up when using 32-bit index variables, while instructions go down.
from fwprofile.
Related Issues (20)
- Tests and examples not built / run by Travis HOT 7
- Potential Memory Leak
- Wrong Format Specifier HOT 1
- Comment about Dead Code in CrFwAux HOT 3
- Guards of decision nodes correctly evaluated ? HOT 2
- fw profile repository is detected as the wrong language
- Probable Error in Release Script
- Add step-by-step procedure for creating a release HOT 2
- Running Valgrind on Tutorials
- SM Configuration When Too Many Out-Going Transitions HOT 1
- Keeping Track of Previous State in State Machines HOT 3
- Some problems with the online editor HOT 1
- Embedded State Machines and State Machine Extension
- Typos and Editorials HOT 4
- Error in Doxygen Comment of Function FwPrGetCurNode HOT 1
- Order of Operations in Transition Execution HOT 1
- Double Execution of Procedure Guard HOT 1
- Decrement of Notification Counter in Activation Thread HOT 1
- New Property on Notification Processing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fwprofile.