ShallowHistoryWithDeepEntry.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. #include "ShallowHistoryWithDeepEntry.h"
  2. #include <string.h>
  3. /*! \file Implementation of the state machine 'ShallowHistoryWithDeepEntry'
  4. */
  5. ShallowHistoryWithDeepEntry::ShallowHistoryWithDeepEntry()
  6. {
  7. for (int i = 0; i < maxHistoryStates; ++i)
  8. historyVector[i] = ShallowHistoryWithDeepEntry_last_state;
  9. stateConfVectorPosition = 0;
  10. }
  11. ShallowHistoryWithDeepEntry::~ShallowHistoryWithDeepEntry()
  12. {
  13. }
  14. void ShallowHistoryWithDeepEntry::init()
  15. {
  16. for (int i = 0; i < maxOrthogonalStates; ++i)
  17. stateConfVector[i] = ShallowHistoryWithDeepEntry_last_state;
  18. for (int i = 0; i < maxHistoryStates; ++i)
  19. historyVector[i] = ShallowHistoryWithDeepEntry_last_state;
  20. stateConfVectorPosition = 0;
  21. clearInEvents();
  22. clearOutEvents();
  23. }
  24. void ShallowHistoryWithDeepEntry::enter()
  25. {
  26. /* Default enter sequence for statechart ShallowHistoryWithDeepEntry */
  27. enseq_main_region_default();
  28. }
  29. void ShallowHistoryWithDeepEntry::exit()
  30. {
  31. /* Default exit sequence for statechart ShallowHistoryWithDeepEntry */
  32. exseq_main_region();
  33. }
  34. sc_boolean ShallowHistoryWithDeepEntry::isActive() const
  35. {
  36. return stateConfVector[0] != ShallowHistoryWithDeepEntry_last_state;
  37. }
  38. /*
  39. * Always returns 'false' since this state machine can never become final.
  40. */
  41. sc_boolean ShallowHistoryWithDeepEntry::isFinal() const
  42. {
  43. return false;}
  44. void ShallowHistoryWithDeepEntry::runCycle()
  45. {
  46. clearOutEvents();
  47. for (stateConfVectorPosition = 0;
  48. stateConfVectorPosition < maxOrthogonalStates;
  49. stateConfVectorPosition++)
  50. {
  51. switch (stateConfVector[stateConfVectorPosition])
  52. {
  53. case main_region_Y :
  54. {
  55. react_main_region_Y();
  56. break;
  57. }
  58. case main_region_Z__region0_A :
  59. {
  60. react_main_region_Z__region0_A();
  61. break;
  62. }
  63. case main_region_Z__region0_B__region0_C :
  64. {
  65. react_main_region_Z__region0_B__region0_C();
  66. break;
  67. }
  68. default:
  69. break;
  70. }
  71. }
  72. clearInEvents();
  73. }
  74. void ShallowHistoryWithDeepEntry::clearInEvents()
  75. {
  76. iface.toZ_raised = false;
  77. iface.toY_raised = false;
  78. iface.toC_raised = false;
  79. iface.toA_raised = false;
  80. }
  81. void ShallowHistoryWithDeepEntry::clearOutEvents()
  82. {
  83. }
  84. sc_boolean ShallowHistoryWithDeepEntry::isStateActive(ShallowHistoryWithDeepEntryStates state) const
  85. {
  86. switch (state)
  87. {
  88. case main_region_Y :
  89. return (sc_boolean) (stateConfVector[0] == main_region_Y
  90. );
  91. case main_region_Z :
  92. return (sc_boolean) (stateConfVector[0] >= main_region_Z
  93. && stateConfVector[0] <= main_region_Z__region0_B__region0_C);
  94. case main_region_Z__region0_A :
  95. return (sc_boolean) (stateConfVector[0] == main_region_Z__region0_A
  96. );
  97. case main_region_Z__region0_B :
  98. return (sc_boolean) (stateConfVector[0] >= main_region_Z__region0_B
  99. && stateConfVector[0] <= main_region_Z__region0_B__region0_C);
  100. case main_region_Z__region0_B__region0_C :
  101. return (sc_boolean) (stateConfVector[0] == main_region_Z__region0_B__region0_C
  102. );
  103. default: return false;
  104. }
  105. }
  106. ShallowHistoryWithDeepEntry::DefaultSCI* ShallowHistoryWithDeepEntry::getDefaultSCI()
  107. {
  108. return &iface;
  109. }
  110. void ShallowHistoryWithDeepEntry::DefaultSCI::raise_toZ()
  111. {
  112. toZ_raised = true;
  113. }
  114. void ShallowHistoryWithDeepEntry::raise_toZ()
  115. {
  116. iface.raise_toZ();
  117. }
  118. void ShallowHistoryWithDeepEntry::DefaultSCI::raise_toY()
  119. {
  120. toY_raised = true;
  121. }
  122. void ShallowHistoryWithDeepEntry::raise_toY()
  123. {
  124. iface.raise_toY();
  125. }
  126. void ShallowHistoryWithDeepEntry::DefaultSCI::raise_toC()
  127. {
  128. toC_raised = true;
  129. }
  130. void ShallowHistoryWithDeepEntry::raise_toC()
  131. {
  132. iface.raise_toC();
  133. }
  134. void ShallowHistoryWithDeepEntry::DefaultSCI::raise_toA()
  135. {
  136. toA_raised = true;
  137. }
  138. void ShallowHistoryWithDeepEntry::raise_toA()
  139. {
  140. iface.raise_toA();
  141. }
  142. // implementations of all internal functions
  143. sc_boolean ShallowHistoryWithDeepEntry::check_main_region_Y_tr0_tr0()
  144. {
  145. return iface.toZ_raised;
  146. }
  147. sc_boolean ShallowHistoryWithDeepEntry::check_main_region_Y_tr1_tr1()
  148. {
  149. return iface.toC_raised;
  150. }
  151. sc_boolean ShallowHistoryWithDeepEntry::check_main_region_Z_tr0_tr0()
  152. {
  153. return iface.toY_raised;
  154. }
  155. sc_boolean ShallowHistoryWithDeepEntry::check_main_region_Z__region0_A_tr0_tr0()
  156. {
  157. return iface.toC_raised;
  158. }
  159. sc_boolean ShallowHistoryWithDeepEntry::check_main_region_Z__region0_B__region0_C_tr0_tr0()
  160. {
  161. return iface.toA_raised;
  162. }
  163. void ShallowHistoryWithDeepEntry::effect_main_region_Y_tr0()
  164. {
  165. exseq_main_region_Y();
  166. enseq_main_region_Z_default();
  167. }
  168. void ShallowHistoryWithDeepEntry::effect_main_region_Y_tr1()
  169. {
  170. exseq_main_region_Y();
  171. enseq_main_region_Z__region0_B__region0_C_default();
  172. historyVector[0] = stateConfVector[0];
  173. }
  174. void ShallowHistoryWithDeepEntry::effect_main_region_Z_tr0()
  175. {
  176. exseq_main_region_Z();
  177. enseq_main_region_Y_default();
  178. }
  179. void ShallowHistoryWithDeepEntry::effect_main_region_Z__region0_A_tr0()
  180. {
  181. exseq_main_region_Z__region0_A();
  182. enseq_main_region_Z__region0_B__region0_C_default();
  183. historyVector[0] = stateConfVector[0];
  184. }
  185. void ShallowHistoryWithDeepEntry::effect_main_region_Z__region0_B__region0_C_tr0()
  186. {
  187. exseq_main_region_Z__region0_B();
  188. enseq_main_region_Z__region0_A_default();
  189. }
  190. /* 'default' enter sequence for state Y */
  191. void ShallowHistoryWithDeepEntry::enseq_main_region_Y_default()
  192. {
  193. /* 'default' enter sequence for state Y */
  194. stateConfVector[0] = main_region_Y;
  195. stateConfVectorPosition = 0;
  196. }
  197. /* 'default' enter sequence for state Z */
  198. void ShallowHistoryWithDeepEntry::enseq_main_region_Z_default()
  199. {
  200. /* 'default' enter sequence for state Z */
  201. enseq_main_region_Z__region0_default();
  202. }
  203. /* 'default' enter sequence for state A */
  204. void ShallowHistoryWithDeepEntry::enseq_main_region_Z__region0_A_default()
  205. {
  206. /* 'default' enter sequence for state A */
  207. stateConfVector[0] = main_region_Z__region0_A;
  208. stateConfVectorPosition = 0;
  209. historyVector[0] = stateConfVector[0];
  210. }
  211. /* 'default' enter sequence for state B */
  212. void ShallowHistoryWithDeepEntry::enseq_main_region_Z__region0_B_default()
  213. {
  214. /* 'default' enter sequence for state B */
  215. enseq_main_region_Z__region0_B__region0_default();
  216. historyVector[0] = stateConfVector[0];
  217. }
  218. /* 'default' enter sequence for state C */
  219. void ShallowHistoryWithDeepEntry::enseq_main_region_Z__region0_B__region0_C_default()
  220. {
  221. /* 'default' enter sequence for state C */
  222. stateConfVector[0] = main_region_Z__region0_B__region0_C;
  223. stateConfVectorPosition = 0;
  224. }
  225. /* 'default' enter sequence for region main region */
  226. void ShallowHistoryWithDeepEntry::enseq_main_region_default()
  227. {
  228. /* 'default' enter sequence for region main region */
  229. react_main_region__entry_Default();
  230. }
  231. /* 'default' enter sequence for region null */
  232. void ShallowHistoryWithDeepEntry::enseq_main_region_Z__region0_default()
  233. {
  234. /* 'default' enter sequence for region null */
  235. react_main_region_Z__region0__entry_Default();
  236. }
  237. /* shallow enterSequence with history in child null */
  238. void ShallowHistoryWithDeepEntry::shenseq_main_region_Z__region0()
  239. {
  240. /* shallow enterSequence with history in child null */
  241. /* Handle shallow history entry of null */
  242. switch(historyVector[ 0 ])
  243. {
  244. case main_region_Z__region0_A :
  245. {
  246. enseq_main_region_Z__region0_A_default();
  247. break;
  248. }
  249. case main_region_Z__region0_B__region0_C :
  250. {
  251. enseq_main_region_Z__region0_B_default();
  252. break;
  253. }
  254. default: break;
  255. }
  256. }
  257. /* 'default' enter sequence for region null */
  258. void ShallowHistoryWithDeepEntry::enseq_main_region_Z__region0_B__region0_default()
  259. {
  260. /* 'default' enter sequence for region null */
  261. react_main_region_Z__region0_B__region0__entry_Default();
  262. }
  263. /* Default exit sequence for state Y */
  264. void ShallowHistoryWithDeepEntry::exseq_main_region_Y()
  265. {
  266. /* Default exit sequence for state Y */
  267. stateConfVector[0] = ShallowHistoryWithDeepEntry_last_state;
  268. stateConfVectorPosition = 0;
  269. }
  270. /* Default exit sequence for state Z */
  271. void ShallowHistoryWithDeepEntry::exseq_main_region_Z()
  272. {
  273. /* Default exit sequence for state Z */
  274. exseq_main_region_Z__region0();
  275. }
  276. /* Default exit sequence for state A */
  277. void ShallowHistoryWithDeepEntry::exseq_main_region_Z__region0_A()
  278. {
  279. /* Default exit sequence for state A */
  280. stateConfVector[0] = ShallowHistoryWithDeepEntry_last_state;
  281. stateConfVectorPosition = 0;
  282. }
  283. /* Default exit sequence for state B */
  284. void ShallowHistoryWithDeepEntry::exseq_main_region_Z__region0_B()
  285. {
  286. /* Default exit sequence for state B */
  287. exseq_main_region_Z__region0_B__region0();
  288. }
  289. /* Default exit sequence for state C */
  290. void ShallowHistoryWithDeepEntry::exseq_main_region_Z__region0_B__region0_C()
  291. {
  292. /* Default exit sequence for state C */
  293. stateConfVector[0] = ShallowHistoryWithDeepEntry_last_state;
  294. stateConfVectorPosition = 0;
  295. }
  296. /* Default exit sequence for region main region */
  297. void ShallowHistoryWithDeepEntry::exseq_main_region()
  298. {
  299. /* Default exit sequence for region main region */
  300. /* Handle exit of all possible states (of ShallowHistoryWithDeepEntry.main_region) at position 0... */
  301. switch(stateConfVector[ 0 ])
  302. {
  303. case main_region_Y :
  304. {
  305. exseq_main_region_Y();
  306. break;
  307. }
  308. case main_region_Z__region0_A :
  309. {
  310. exseq_main_region_Z__region0_A();
  311. break;
  312. }
  313. case main_region_Z__region0_B__region0_C :
  314. {
  315. exseq_main_region_Z__region0_B__region0_C();
  316. break;
  317. }
  318. default: break;
  319. }
  320. }
  321. /* Default exit sequence for region null */
  322. void ShallowHistoryWithDeepEntry::exseq_main_region_Z__region0()
  323. {
  324. /* Default exit sequence for region null */
  325. /* Handle exit of all possible states (of ShallowHistoryWithDeepEntry.main_region.Z._region0) at position 0... */
  326. switch(stateConfVector[ 0 ])
  327. {
  328. case main_region_Z__region0_A :
  329. {
  330. exseq_main_region_Z__region0_A();
  331. break;
  332. }
  333. case main_region_Z__region0_B__region0_C :
  334. {
  335. exseq_main_region_Z__region0_B__region0_C();
  336. break;
  337. }
  338. default: break;
  339. }
  340. }
  341. /* Default exit sequence for region null */
  342. void ShallowHistoryWithDeepEntry::exseq_main_region_Z__region0_B__region0()
  343. {
  344. /* Default exit sequence for region null */
  345. /* Handle exit of all possible states (of ShallowHistoryWithDeepEntry.main_region.Z._region0.B._region0) at position 0... */
  346. switch(stateConfVector[ 0 ])
  347. {
  348. case main_region_Z__region0_B__region0_C :
  349. {
  350. exseq_main_region_Z__region0_B__region0_C();
  351. break;
  352. }
  353. default: break;
  354. }
  355. }
  356. /* The reactions of state Y. */
  357. void ShallowHistoryWithDeepEntry::react_main_region_Y()
  358. {
  359. /* The reactions of state Y. */
  360. if (check_main_region_Y_tr0_tr0())
  361. {
  362. effect_main_region_Y_tr0();
  363. } else
  364. {
  365. if (check_main_region_Y_tr1_tr1())
  366. {
  367. effect_main_region_Y_tr1();
  368. }
  369. }
  370. }
  371. /* The reactions of state A. */
  372. void ShallowHistoryWithDeepEntry::react_main_region_Z__region0_A()
  373. {
  374. /* The reactions of state A. */
  375. if (check_main_region_Z_tr0_tr0())
  376. {
  377. effect_main_region_Z_tr0();
  378. } else
  379. {
  380. if (check_main_region_Z__region0_A_tr0_tr0())
  381. {
  382. effect_main_region_Z__region0_A_tr0();
  383. }
  384. }
  385. }
  386. /* The reactions of state C. */
  387. void ShallowHistoryWithDeepEntry::react_main_region_Z__region0_B__region0_C()
  388. {
  389. /* The reactions of state C. */
  390. if (check_main_region_Z_tr0_tr0())
  391. {
  392. effect_main_region_Z_tr0();
  393. } else
  394. {
  395. if (check_main_region_Z__region0_B__region0_C_tr0_tr0())
  396. {
  397. effect_main_region_Z__region0_B__region0_C_tr0();
  398. }
  399. }
  400. }
  401. /* Default react sequence for initial entry */
  402. void ShallowHistoryWithDeepEntry::react_main_region__entry_Default()
  403. {
  404. /* Default react sequence for initial entry */
  405. enseq_main_region_Y_default();
  406. }
  407. /* Default react sequence for shallow history entry */
  408. void ShallowHistoryWithDeepEntry::react_main_region_Z__region0__entry_Default()
  409. {
  410. /* Default react sequence for shallow history entry */
  411. /* Enter the region with shallow history */
  412. if (historyVector[0] != ShallowHistoryWithDeepEntry_last_state)
  413. {
  414. shenseq_main_region_Z__region0();
  415. } else
  416. {
  417. enseq_main_region_Z__region0_A_default();
  418. }
  419. }
  420. /* Default react sequence for initial entry */
  421. void ShallowHistoryWithDeepEntry::react_main_region_Z__region0_B__region0__entry_Default()
  422. {
  423. /* Default react sequence for initial entry */
  424. enseq_main_region_Z__region0_B__region0_C_default();
  425. }