2.5.1. Special-purpose behaviors

The following behaviors names have a specific meaning in components and are called implicitly and automatically in certain simulation phases:

behavior init

This behavior is called implicitly once when the simulation is started. The code in this behavior is only executed once. It is intended to allocate memory and other resources used during simulation.

behavior reset(int level)

This behavior is called whenever the simulation is reset by the user. Reset might be called multiple times. There are two reset levels:

  • MX_RESETLEVEL_SOFT indicates that all state variables must be reset to their reset value but memory contents must not be cleared.

  • MX_RESETLEVEL_HARD indicates that all state variables must be reset to their reset values and memories must also be cleared.

Memory must not be allocated in this behavior since it might be invoked several times.

Caution

All registers are normally reset to the values specified in their reset_value parameters immediately before behavior reset is run.

You can use reset_value(UNINITIALIZED) to prevent the register values being overwritten. See Table 2.1.

behavior loadApplicationFile(const string& filename)

This behavior is invoked whenever a user loads an application file into a component using a debugger. The implementation of this behavior must load the application file.

behavior terminate

This behavior is the counterpart to behavior init. It is called when the simulation terminates. It is intended to free any allocated memory and resources that have been allocated in behavior init.

behavior setupGlobalSystemAttributes()

This behavior is used to define a parameter export list. For details see Parameter Export List

Note

See also Controlling simulation from behaviors.

Copyright © 2007-2010 ARM Limited. All rights reserved.ARM DUI 0372I
Non-Confidential