Constants.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. #include "Constants.h"
  2. #include <string.h>
  3. /*! \file Implementation of the state machine 'Constants'
  4. */
  5. Constants::Constants()
  6. {
  7. stateConfVectorPosition = 0;
  8. }
  9. Constants::~Constants()
  10. {
  11. }
  12. const sc_integer Constants::DefaultSCI::x = 10;
  13. const sc_integer Constants::DefaultSCI::y = Constants::DefaultSCI::x * 2;
  14. const sc_string Constants::SCI_Named::y = "Hello World";
  15. const sc_integer Constants::SCI_Named::two = 2;
  16. const sc_integer Constants::InternalSCI::internalConstant = 5;
  17. void Constants::init()
  18. {
  19. for (int i = 0; i < maxOrthogonalStates; ++i)
  20. stateConfVector[i] = Constants_last_state;
  21. stateConfVectorPosition = 0;
  22. clearInEvents();
  23. clearOutEvents();
  24. /* Default init sequence for statechart Constants */
  25. iface.result = 0;
  26. }
  27. void Constants::enter()
  28. {
  29. /* Default enter sequence for statechart Constants */
  30. enseq_main_region_default();
  31. }
  32. void Constants::exit()
  33. {
  34. /* Default exit sequence for statechart Constants */
  35. exseq_main_region();
  36. }
  37. sc_boolean Constants::isActive() const
  38. {
  39. return stateConfVector[0] != Constants_last_state;
  40. }
  41. /*
  42. * Always returns 'false' since this state machine can never become final.
  43. */
  44. sc_boolean Constants::isFinal() const
  45. {
  46. return false;}
  47. void Constants::runCycle()
  48. {
  49. clearOutEvents();
  50. for (stateConfVectorPosition = 0;
  51. stateConfVectorPosition < maxOrthogonalStates;
  52. stateConfVectorPosition++)
  53. {
  54. switch (stateConfVector[stateConfVectorPosition])
  55. {
  56. case main_region_A :
  57. {
  58. react_main_region_A();
  59. break;
  60. }
  61. case main_region_B :
  62. {
  63. react_main_region_B();
  64. break;
  65. }
  66. case main_region_C :
  67. {
  68. react_main_region_C();
  69. break;
  70. }
  71. default:
  72. break;
  73. }
  74. }
  75. clearInEvents();
  76. }
  77. void Constants::clearInEvents()
  78. {
  79. iface.e_raised = false;
  80. iface.e2_raised = false;
  81. }
  82. void Constants::clearOutEvents()
  83. {
  84. }
  85. sc_boolean Constants::isStateActive(ConstantsStates state) const
  86. {
  87. switch (state)
  88. {
  89. case main_region_A :
  90. return (sc_boolean) (stateConfVector[0] == main_region_A
  91. );
  92. case main_region_B :
  93. return (sc_boolean) (stateConfVector[0] == main_region_B
  94. );
  95. case main_region_C :
  96. return (sc_boolean) (stateConfVector[0] == main_region_C
  97. );
  98. default: return false;
  99. }
  100. }
  101. Constants::DefaultSCI* Constants::getDefaultSCI()
  102. {
  103. return &iface;
  104. }
  105. void Constants::DefaultSCI::raise_e()
  106. {
  107. e_raised = true;
  108. }
  109. void Constants::raise_e()
  110. {
  111. iface.raise_e();
  112. }
  113. void Constants::DefaultSCI::raise_e2(sc_integer value)
  114. {
  115. e2_value = value;
  116. e2_raised = true;
  117. }
  118. void Constants::raise_e2(sc_integer value)
  119. {
  120. iface.raise_e2(value);
  121. }
  122. const sc_integer Constants::DefaultSCI::get_x() const
  123. {
  124. return x;
  125. }
  126. const sc_integer Constants::get_x() const
  127. {
  128. return Constants::DefaultSCI::x;
  129. }
  130. const sc_integer Constants::DefaultSCI::get_y() const
  131. {
  132. return y;
  133. }
  134. const sc_integer Constants::get_y() const
  135. {
  136. return Constants::DefaultSCI::y;
  137. }
  138. sc_integer Constants::DefaultSCI::get_result() const
  139. {
  140. return result;
  141. }
  142. sc_integer Constants::get_result() const
  143. {
  144. return iface.result;
  145. }
  146. void Constants::DefaultSCI::set_result(sc_integer value)
  147. {
  148. result = value;
  149. }
  150. void Constants::set_result(sc_integer value)
  151. {
  152. iface.result = value;
  153. }
  154. Constants::SCI_Named* Constants::getSCI_Named()
  155. {
  156. return &ifaceNamed;
  157. }
  158. const sc_string Constants::SCI_Named::get_y() const
  159. {
  160. return y;
  161. }
  162. const sc_integer Constants::SCI_Named::get_two() const
  163. {
  164. return two;
  165. }
  166. const sc_integer Constants::InternalSCI::get_internalConstant() const
  167. {
  168. return internalConstant;
  169. }
  170. // implementations of all internal functions
  171. sc_boolean Constants::check_main_region_A_tr0_tr0()
  172. {
  173. return iface.e_raised;
  174. }
  175. sc_boolean Constants::check_main_region_B_tr0_tr0()
  176. {
  177. return iface.e_raised;
  178. }
  179. sc_boolean Constants::check_main_region_C_tr0_tr0()
  180. {
  181. return iface.e2_raised;
  182. }
  183. void Constants::effect_main_region_A_tr0()
  184. {
  185. exseq_main_region_A();
  186. enseq_main_region_B_default();
  187. }
  188. void Constants::effect_main_region_B_tr0()
  189. {
  190. exseq_main_region_B();
  191. enseq_main_region_C_default();
  192. }
  193. void Constants::effect_main_region_C_tr0()
  194. {
  195. exseq_main_region_C();
  196. iface.result = iface.e2_value * Constants::DefaultSCI::x * Constants::SCI_Named::two * Constants::InternalSCI::internalConstant;
  197. enseq_main_region_A_default();
  198. }
  199. /* Entry action for state 'B'. */
  200. void Constants::enact_main_region_B()
  201. {
  202. /* Entry action for state 'B'. */
  203. iface.result = Constants::SCI_Named::two * Constants::DefaultSCI::x;
  204. }
  205. /* Entry action for state 'C'. */
  206. void Constants::enact_main_region_C()
  207. {
  208. /* Entry action for state 'C'. */
  209. iface.result = iface.result * Constants::InternalSCI::internalConstant;
  210. }
  211. /* 'default' enter sequence for state A */
  212. void Constants::enseq_main_region_A_default()
  213. {
  214. /* 'default' enter sequence for state A */
  215. stateConfVector[0] = main_region_A;
  216. stateConfVectorPosition = 0;
  217. }
  218. /* 'default' enter sequence for state B */
  219. void Constants::enseq_main_region_B_default()
  220. {
  221. /* 'default' enter sequence for state B */
  222. enact_main_region_B();
  223. stateConfVector[0] = main_region_B;
  224. stateConfVectorPosition = 0;
  225. }
  226. /* 'default' enter sequence for state C */
  227. void Constants::enseq_main_region_C_default()
  228. {
  229. /* 'default' enter sequence for state C */
  230. enact_main_region_C();
  231. stateConfVector[0] = main_region_C;
  232. stateConfVectorPosition = 0;
  233. }
  234. /* 'default' enter sequence for region main region */
  235. void Constants::enseq_main_region_default()
  236. {
  237. /* 'default' enter sequence for region main region */
  238. react_main_region__entry_Default();
  239. }
  240. /* Default exit sequence for state A */
  241. void Constants::exseq_main_region_A()
  242. {
  243. /* Default exit sequence for state A */
  244. stateConfVector[0] = Constants_last_state;
  245. stateConfVectorPosition = 0;
  246. }
  247. /* Default exit sequence for state B */
  248. void Constants::exseq_main_region_B()
  249. {
  250. /* Default exit sequence for state B */
  251. stateConfVector[0] = Constants_last_state;
  252. stateConfVectorPosition = 0;
  253. }
  254. /* Default exit sequence for state C */
  255. void Constants::exseq_main_region_C()
  256. {
  257. /* Default exit sequence for state C */
  258. stateConfVector[0] = Constants_last_state;
  259. stateConfVectorPosition = 0;
  260. }
  261. /* Default exit sequence for region main region */
  262. void Constants::exseq_main_region()
  263. {
  264. /* Default exit sequence for region main region */
  265. /* Handle exit of all possible states (of Constants.main_region) at position 0... */
  266. switch(stateConfVector[ 0 ])
  267. {
  268. case main_region_A :
  269. {
  270. exseq_main_region_A();
  271. break;
  272. }
  273. case main_region_B :
  274. {
  275. exseq_main_region_B();
  276. break;
  277. }
  278. case main_region_C :
  279. {
  280. exseq_main_region_C();
  281. break;
  282. }
  283. default: break;
  284. }
  285. }
  286. /* The reactions of state A. */
  287. void Constants::react_main_region_A()
  288. {
  289. /* The reactions of state A. */
  290. if (check_main_region_A_tr0_tr0())
  291. {
  292. effect_main_region_A_tr0();
  293. }
  294. }
  295. /* The reactions of state B. */
  296. void Constants::react_main_region_B()
  297. {
  298. /* The reactions of state B. */
  299. if (check_main_region_B_tr0_tr0())
  300. {
  301. effect_main_region_B_tr0();
  302. }
  303. }
  304. /* The reactions of state C. */
  305. void Constants::react_main_region_C()
  306. {
  307. /* The reactions of state C. */
  308. if (check_main_region_C_tr0_tr0())
  309. {
  310. effect_main_region_C_tr0();
  311. }
  312. }
  313. /* Default react sequence for initial entry */
  314. void Constants::react_main_region__entry_Default()
  315. {
  316. /* Default react sequence for initial entry */
  317. enseq_main_region_A_default();
  318. }