CastExpressions.cpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. #include "CastExpressions.h"
  2. #include <string.h>
  3. /*! \file Implementation of the state machine 'CastExpressions'
  4. */
  5. CastExpressions::CastExpressions()
  6. {
  7. stateConfVectorPosition = 0;
  8. }
  9. CastExpressions::~CastExpressions()
  10. {
  11. }
  12. void CastExpressions::init()
  13. {
  14. for (int i = 0; i < maxOrthogonalStates; ++i)
  15. stateConfVector[i] = CastExpressions_last_state;
  16. stateConfVectorPosition = 0;
  17. clearInEvents();
  18. clearOutEvents();
  19. /* Default init sequence for statechart CastExpressions */
  20. iface.realValue = (((sc_real) 5));
  21. iface.intValue = (((sc_integer) 5.5));
  22. }
  23. void CastExpressions::enter()
  24. {
  25. /* Default enter sequence for statechart CastExpressions */
  26. enseq_main_region_default();
  27. }
  28. void CastExpressions::exit()
  29. {
  30. /* Default exit sequence for statechart CastExpressions */
  31. exseq_main_region();
  32. }
  33. sc_boolean CastExpressions::isActive() const
  34. {
  35. return stateConfVector[0] != CastExpressions_last_state;
  36. }
  37. /*
  38. * Always returns 'false' since this state machine can never become final.
  39. */
  40. sc_boolean CastExpressions::isFinal() const
  41. {
  42. return false;}
  43. void CastExpressions::runCycle()
  44. {
  45. clearOutEvents();
  46. for (stateConfVectorPosition = 0;
  47. stateConfVectorPosition < maxOrthogonalStates;
  48. stateConfVectorPosition++)
  49. {
  50. switch (stateConfVector[stateConfVectorPosition])
  51. {
  52. case main_region_A :
  53. {
  54. react_main_region_A();
  55. break;
  56. }
  57. case main_region_B :
  58. {
  59. react_main_region_B();
  60. break;
  61. }
  62. case main_region_C :
  63. {
  64. react_main_region_C();
  65. break;
  66. }
  67. default:
  68. break;
  69. }
  70. }
  71. clearInEvents();
  72. }
  73. void CastExpressions::clearInEvents()
  74. {
  75. }
  76. void CastExpressions::clearOutEvents()
  77. {
  78. }
  79. sc_boolean CastExpressions::isStateActive(CastExpressionsStates state) const
  80. {
  81. switch (state)
  82. {
  83. case main_region_A :
  84. return (sc_boolean) (stateConfVector[0] == main_region_A
  85. );
  86. case main_region_B :
  87. return (sc_boolean) (stateConfVector[0] == main_region_B
  88. );
  89. case main_region_C :
  90. return (sc_boolean) (stateConfVector[0] == main_region_C
  91. );
  92. default: return false;
  93. }
  94. }
  95. CastExpressions::DefaultSCI* CastExpressions::getDefaultSCI()
  96. {
  97. return &iface;
  98. }
  99. sc_real CastExpressions::DefaultSCI::get_realValue() const
  100. {
  101. return realValue;
  102. }
  103. sc_real CastExpressions::get_realValue() const
  104. {
  105. return iface.realValue;
  106. }
  107. void CastExpressions::DefaultSCI::set_realValue(sc_real value)
  108. {
  109. realValue = value;
  110. }
  111. void CastExpressions::set_realValue(sc_real value)
  112. {
  113. iface.realValue = value;
  114. }
  115. sc_integer CastExpressions::DefaultSCI::get_intValue() const
  116. {
  117. return intValue;
  118. }
  119. sc_integer CastExpressions::get_intValue() const
  120. {
  121. return iface.intValue;
  122. }
  123. void CastExpressions::DefaultSCI::set_intValue(sc_integer value)
  124. {
  125. intValue = value;
  126. }
  127. void CastExpressions::set_intValue(sc_integer value)
  128. {
  129. iface.intValue = value;
  130. }
  131. // implementations of all internal functions
  132. sc_boolean CastExpressions::check_main_region_A_tr0_tr0()
  133. {
  134. return true;
  135. }
  136. sc_boolean CastExpressions::check_main_region_B_tr0_tr0()
  137. {
  138. return (true) && (((sc_real) (iface.realValue * 0.1)) > ((sc_integer) 1.4) && ((sc_integer) (iface.realValue * iface.intValue)) < ((sc_real) 100));
  139. }
  140. void CastExpressions::effect_main_region_A_tr0()
  141. {
  142. exseq_main_region_A();
  143. enseq_main_region_B_default();
  144. }
  145. void CastExpressions::effect_main_region_B_tr0()
  146. {
  147. exseq_main_region_B();
  148. enseq_main_region_C_default();
  149. }
  150. /* Entry action for state 'B'. */
  151. void CastExpressions::enact_main_region_B()
  152. {
  153. /* Entry action for state 'B'. */
  154. iface.realValue = 3 * ((sc_integer) 5.5);
  155. }
  156. /* Entry action for state 'C'. */
  157. void CastExpressions::enact_main_region_C()
  158. {
  159. /* Entry action for state 'C'. */
  160. iface.realValue = ((sc_integer) (iface.realValue * iface.intValue * 10.1));
  161. }
  162. /* 'default' enter sequence for state A */
  163. void CastExpressions::enseq_main_region_A_default()
  164. {
  165. /* 'default' enter sequence for state A */
  166. stateConfVector[0] = main_region_A;
  167. stateConfVectorPosition = 0;
  168. }
  169. /* 'default' enter sequence for state B */
  170. void CastExpressions::enseq_main_region_B_default()
  171. {
  172. /* 'default' enter sequence for state B */
  173. enact_main_region_B();
  174. stateConfVector[0] = main_region_B;
  175. stateConfVectorPosition = 0;
  176. }
  177. /* 'default' enter sequence for state C */
  178. void CastExpressions::enseq_main_region_C_default()
  179. {
  180. /* 'default' enter sequence for state C */
  181. enact_main_region_C();
  182. stateConfVector[0] = main_region_C;
  183. stateConfVectorPosition = 0;
  184. }
  185. /* 'default' enter sequence for region main region */
  186. void CastExpressions::enseq_main_region_default()
  187. {
  188. /* 'default' enter sequence for region main region */
  189. react_main_region__entry_Default();
  190. }
  191. /* Default exit sequence for state A */
  192. void CastExpressions::exseq_main_region_A()
  193. {
  194. /* Default exit sequence for state A */
  195. stateConfVector[0] = CastExpressions_last_state;
  196. stateConfVectorPosition = 0;
  197. }
  198. /* Default exit sequence for state B */
  199. void CastExpressions::exseq_main_region_B()
  200. {
  201. /* Default exit sequence for state B */
  202. stateConfVector[0] = CastExpressions_last_state;
  203. stateConfVectorPosition = 0;
  204. }
  205. /* Default exit sequence for state C */
  206. void CastExpressions::exseq_main_region_C()
  207. {
  208. /* Default exit sequence for state C */
  209. stateConfVector[0] = CastExpressions_last_state;
  210. stateConfVectorPosition = 0;
  211. }
  212. /* Default exit sequence for region main region */
  213. void CastExpressions::exseq_main_region()
  214. {
  215. /* Default exit sequence for region main region */
  216. /* Handle exit of all possible states (of CastExpressions.main_region) at position 0... */
  217. switch(stateConfVector[ 0 ])
  218. {
  219. case main_region_A :
  220. {
  221. exseq_main_region_A();
  222. break;
  223. }
  224. case main_region_B :
  225. {
  226. exseq_main_region_B();
  227. break;
  228. }
  229. case main_region_C :
  230. {
  231. exseq_main_region_C();
  232. break;
  233. }
  234. default: break;
  235. }
  236. }
  237. /* The reactions of state A. */
  238. void CastExpressions::react_main_region_A()
  239. {
  240. /* The reactions of state A. */
  241. effect_main_region_A_tr0();
  242. }
  243. /* The reactions of state B. */
  244. void CastExpressions::react_main_region_B()
  245. {
  246. /* The reactions of state B. */
  247. if (check_main_region_B_tr0_tr0())
  248. {
  249. effect_main_region_B_tr0();
  250. }
  251. }
  252. /* The reactions of state C. */
  253. void CastExpressions::react_main_region_C()
  254. {
  255. /* The reactions of state C. */
  256. }
  257. /* Default react sequence for initial entry */
  258. void CastExpressions::react_main_region__entry_Default()
  259. {
  260. /* Default react sequence for initial entry */
  261. enseq_main_region_A_default();
  262. }