core_state.c | |
Description | Simple state machines like this one are used in many embedded products. |
Functions | |
core_bench_state | Benchmark function |
core_init_state | Initialize the input data for the state machine. |
core_state_transition | Actual state machine. |
Simple state machines like this one are used in many embedded products.
For more complex state machines, sometimes a state transition table implementation is used instead, trading speed of direct coding for ease of maintenance.
Since the main goal of using a state machine in CoreMark is to excercise the switch/if behaviour, we are using a small moore machine.
In particular, this machine tests type of string input, trying to determine whether the input is a number or something else. (see core_state).
void core_init_state( ee_u32 size, ee_s16 seed, ee_u8 * p )
Initialize the input data for the state machine.
Populate the input with several predetermined strings, interspersed. Actual patterns chosen depend on the seed parameter.
The seed parameter MUST be supplied from a source that cannot be determined at compile time
enum CORE_STATE core_state_transition( ee_u8 **instr , ee_u32 * transition_count )
Actual state machine.
1 | an invalid input is detcted. |
2 | a valid number has been detected. |
The input pointer is updated to point to the end of the token, and the end state is returned (either specific format determined or invalid).
Benchmark function
ee_u16 core_bench_state( ee_u32 blksize, ee_u8 * memblock, ee_s16 seed1, ee_s16 seed2, ee_s16 step, ee_u16 crc )
Initialize the input data for the state machine.
void core_init_state( ee_u32 size, ee_s16 seed, ee_u8 * p )
Actual state machine.
enum CORE_STATE core_state_transition( ee_u8 **instr , ee_u32 * transition_count )