SyncFork.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef SYNCFORK_H_
  2. #define SYNCFORK_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'SyncFork'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. SyncFork_last_state,
  13. SyncFork_main_region_A,
  14. SyncFork_main_region_B,
  15. SyncFork_main_region_B_r1_C1,
  16. SyncFork_main_region_B_r1_C2,
  17. SyncFork_main_region_B_r2_D1,
  18. SyncFork_main_region_B_r2_D2
  19. } SyncForkStates;
  20. /*! Type definition of the data structure for the SyncForkIface interface scope. */
  21. typedef struct
  22. {
  23. sc_boolean e_raised;
  24. sc_boolean f_raised;
  25. } SyncForkIface;
  26. /*! Define dimension of the state configuration vector for orthogonal states. */
  27. #define SYNCFORK_MAX_ORTHOGONAL_STATES 2
  28. /*! Define indices of states in the StateConfVector */
  29. #define SCVI_SYNCFORK_MAIN_REGION_A 0
  30. #define SCVI_SYNCFORK_MAIN_REGION_B 0
  31. #define SCVI_SYNCFORK_MAIN_REGION_B_R1_C1 0
  32. #define SCVI_SYNCFORK_MAIN_REGION_B_R1_C2 0
  33. #define SCVI_SYNCFORK_MAIN_REGION_B_R2_D1 1
  34. #define SCVI_SYNCFORK_MAIN_REGION_B_R2_D2 1
  35. /*!
  36. * Type definition of the data structure for the SyncFork state machine.
  37. * This data structure has to be allocated by the client code.
  38. */
  39. typedef struct
  40. {
  41. SyncForkStates stateConfVector[SYNCFORK_MAX_ORTHOGONAL_STATES];
  42. sc_ushort stateConfVectorPosition;
  43. SyncForkIface iface;
  44. } SyncFork;
  45. /*! Initializes the SyncFork state machine data structures. Must be called before first usage.*/
  46. extern void syncFork_init(SyncFork* handle);
  47. /*! Activates the state machine */
  48. extern void syncFork_enter(SyncFork* handle);
  49. /*! Deactivates the state machine */
  50. extern void syncFork_exit(SyncFork* handle);
  51. /*! Performs a 'run to completion' step. */
  52. extern void syncFork_runCycle(SyncFork* handle);
  53. /*! Raises the in event 'e' that is defined in the default interface scope. */
  54. extern void syncForkIface_raise_e(SyncFork* handle);
  55. /*! Raises the in event 'f' that is defined in the default interface scope. */
  56. extern void syncForkIface_raise_f(SyncFork* handle);
  57. /*!
  58. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  59. * A state machine is active if it was entered. It is inactive if it has not been entered at all or if it has been exited.
  60. */
  61. extern sc_boolean syncFork_isActive(const SyncFork* handle);
  62. /*!
  63. * Checks if all active states are final.
  64. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  65. */
  66. extern sc_boolean syncFork_isFinal(const SyncFork* handle);
  67. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  68. extern sc_boolean syncFork_isStateActive(const SyncFork* handle, SyncForkStates state);
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72. #endif /* SYNCFORK_H_ */