core_state.c

Summary
core_state.c
DescriptionSimple state machines like this one are used in many embedded products.
Functions
core_bench_stateBenchmark function
core_init_stateInitialize the input data for the state machine.
core_state_transitionActual state machine.

Description

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).

core_state

Functions

core_bench_state

ee_u16 core_bench_state(ee_u32 blksize,
ee_u8 *memblock,
ee_s16 seed1,
ee_s16 seed2,
ee_s16 step,
ee_u16 crc)

Benchmark function

Go over the input twice, once direct, and once after introducing some corruption.

core_init_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.

Note

The seed parameter MUST be supplied from a source that cannot be determined at compile time

core_state_transition

enum CORE_STATE core_state_transition(ee_u8 **instr ,
ee_u32 *transition_count)

Actual state machine.

The state machine will continue scanning until either

1an invalid input is detcted.
2a 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).

ee_u16 core_bench_state(ee_u32 blksize,
ee_u8 *memblock,
ee_s16 seed1,
ee_s16 seed2,
ee_s16 step,
ee_u16 crc)
Benchmark function
void core_init_state(ee_u32 size,
ee_s16 seed,
ee_u8 *p)
Initialize the input data for the state machine.
enum CORE_STATE core_state_transition(ee_u8 **instr ,
ee_u32 *transition_count)
Actual state machine.
Close