StreamFMAKernel.cpp 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. #include "stdsimheader.h"
  2. #include "StreamFMAKernel.h"
  3. namespace maxcompilersim {
  4. StreamFMAKernel::StreamFMAKernel(const std::string &instance_name) :
  5. ManagerBlockSync(instance_name),
  6. KernelManagerBlockSync(instance_name, 15, 2, 0, 0, "",1)
  7. , c_hw_fix_1_0_uns_bits((HWOffsetFix<1,0,UNSIGNED>(varint_u<1>(0x0l))))
  8. , c_hw_fix_32_0_sgn_undef((HWOffsetFix<32,0,TWOSCOMPLEMENT>()))
  9. , c_hw_fix_1_0_uns_bits_1((HWOffsetFix<1,0,UNSIGNED>(varint_u<1>(0x1l))))
  10. , c_hw_fix_49_0_uns_bits((HWOffsetFix<49,0,UNSIGNED>(varint_u<49>(0x1000000000000l))))
  11. , c_hw_fix_49_0_uns_bits_1((HWOffsetFix<49,0,UNSIGNED>(varint_u<49>(0x0000000000000l))))
  12. , c_hw_fix_49_0_uns_bits_2((HWOffsetFix<49,0,UNSIGNED>(varint_u<49>(0x0000000000001l))))
  13. {
  14. { // Node ID: 22 (NodeInputMappedReg)
  15. registerMappedRegister("io_oDataT1_force_disabled", Data(1));
  16. }
  17. { // Node ID: 0 (NodeInputMappedReg)
  18. registerMappedRegister("io_inAT1_force_disabled", Data(1));
  19. }
  20. { // Node ID: 2 (NodeInput)
  21. m_inAT1 = registerInput("inAT1",0,5);
  22. }
  23. { // Node ID: 3 (NodeInputMappedReg)
  24. registerMappedRegister("io_inBT1_force_disabled", Data(1));
  25. }
  26. { // Node ID: 5 (NodeInput)
  27. m_inBT1 = registerInput("inBT1",1,5);
  28. }
  29. { // Node ID: 25 (NodeOutput)
  30. m_oDataT1 = registerOutput("oDataT1",0 );
  31. }
  32. { // Node ID: 27 (NodeInputMappedReg)
  33. registerMappedRegister("io_oDataT2_force_disabled", Data(1));
  34. }
  35. { // Node ID: 6 (NodeInputMappedReg)
  36. registerMappedRegister("io_inAT2_force_disabled", Data(1));
  37. }
  38. { // Node ID: 8 (NodeInput)
  39. m_inAT2 = registerInput("inAT2",2,5);
  40. }
  41. { // Node ID: 9 (NodeInputMappedReg)
  42. registerMappedRegister("io_inBT2_force_disabled", Data(1));
  43. }
  44. { // Node ID: 11 (NodeInput)
  45. m_inBT2 = registerInput("inBT2",3,5);
  46. }
  47. { // Node ID: 30 (NodeOutput)
  48. m_oDataT2 = registerOutput("oDataT2",1 );
  49. }
  50. { // Node ID: 32 (NodeInputMappedReg)
  51. registerMappedRegister("io_oDataT3_force_disabled", Data(1));
  52. }
  53. { // Node ID: 12 (NodeInputMappedReg)
  54. registerMappedRegister("io_inAT3_force_disabled", Data(1));
  55. }
  56. { // Node ID: 14 (NodeInput)
  57. m_inAT3 = registerInput("inAT3",4,5);
  58. }
  59. { // Node ID: 15 (NodeInputMappedReg)
  60. registerMappedRegister("io_inBT3_force_disabled", Data(1));
  61. }
  62. { // Node ID: 17 (NodeInput)
  63. m_inBT3 = registerInput("inBT3",5,5);
  64. }
  65. { // Node ID: 35 (NodeOutput)
  66. m_oDataT3 = registerOutput("oDataT3",2 );
  67. }
  68. { // Node ID: 40 (NodeConstantRawBits)
  69. id40out_value = (c_hw_fix_1_0_uns_bits_1);
  70. }
  71. { // Node ID: 50 (NodeConstantRawBits)
  72. id50out_value = (c_hw_fix_1_0_uns_bits_1);
  73. }
  74. { // Node ID: 37 (NodeConstantRawBits)
  75. id37out_value = (c_hw_fix_49_0_uns_bits);
  76. }
  77. { // Node ID: 41 (NodeOutputMappedReg)
  78. registerMappedRegister("current_run_cycle_count", Data(48), true);
  79. }
  80. { // Node ID: 49 (NodeConstantRawBits)
  81. id49out_value = (c_hw_fix_1_0_uns_bits_1);
  82. }
  83. { // Node ID: 43 (NodeConstantRawBits)
  84. id43out_value = (c_hw_fix_49_0_uns_bits);
  85. }
  86. { // Node ID: 46 (NodeInputMappedReg)
  87. registerMappedRegister("run_cycle_count", Data(48));
  88. }
  89. }
  90. void StreamFMAKernel::resetComputation() {
  91. resetComputationAfterFlush();
  92. }
  93. void StreamFMAKernel::resetComputationAfterFlush() {
  94. { // Node ID: 22 (NodeInputMappedReg)
  95. id22out_io_oDataT1_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_oDataT1_force_disabled");
  96. }
  97. { // Node ID: 0 (NodeInputMappedReg)
  98. id0out_io_inAT1_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inAT1_force_disabled");
  99. }
  100. { // Node ID: 2 (NodeInput)
  101. (id2st_read_next_cycle) = (c_hw_fix_1_0_uns_bits);
  102. (id2st_last_read_value) = (c_hw_fix_32_0_sgn_undef);
  103. }
  104. { // Node ID: 3 (NodeInputMappedReg)
  105. id3out_io_inBT1_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inBT1_force_disabled");
  106. }
  107. { // Node ID: 5 (NodeInput)
  108. (id5st_read_next_cycle) = (c_hw_fix_1_0_uns_bits);
  109. (id5st_last_read_value) = (c_hw_fix_32_0_sgn_undef);
  110. }
  111. { // Node ID: 27 (NodeInputMappedReg)
  112. id27out_io_oDataT2_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_oDataT2_force_disabled");
  113. }
  114. { // Node ID: 6 (NodeInputMappedReg)
  115. id6out_io_inAT2_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inAT2_force_disabled");
  116. }
  117. { // Node ID: 8 (NodeInput)
  118. (id8st_read_next_cycle) = (c_hw_fix_1_0_uns_bits);
  119. (id8st_last_read_value) = (c_hw_fix_32_0_sgn_undef);
  120. }
  121. { // Node ID: 9 (NodeInputMappedReg)
  122. id9out_io_inBT2_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inBT2_force_disabled");
  123. }
  124. { // Node ID: 11 (NodeInput)
  125. (id11st_read_next_cycle) = (c_hw_fix_1_0_uns_bits);
  126. (id11st_last_read_value) = (c_hw_fix_32_0_sgn_undef);
  127. }
  128. { // Node ID: 32 (NodeInputMappedReg)
  129. id32out_io_oDataT3_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_oDataT3_force_disabled");
  130. }
  131. { // Node ID: 12 (NodeInputMappedReg)
  132. id12out_io_inAT3_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inAT3_force_disabled");
  133. }
  134. { // Node ID: 14 (NodeInput)
  135. (id14st_read_next_cycle) = (c_hw_fix_1_0_uns_bits);
  136. (id14st_last_read_value) = (c_hw_fix_32_0_sgn_undef);
  137. }
  138. { // Node ID: 15 (NodeInputMappedReg)
  139. id15out_io_inBT3_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inBT3_force_disabled");
  140. }
  141. { // Node ID: 17 (NodeInput)
  142. (id17st_read_next_cycle) = (c_hw_fix_1_0_uns_bits);
  143. (id17st_last_read_value) = (c_hw_fix_32_0_sgn_undef);
  144. }
  145. { // Node ID: 38 (NodeCounter)
  146. (id38st_count) = (c_hw_fix_49_0_uns_bits_1);
  147. }
  148. { // Node ID: 44 (NodeCounter)
  149. (id44st_count) = (c_hw_fix_49_0_uns_bits_1);
  150. }
  151. { // Node ID: 46 (NodeInputMappedReg)
  152. id46out_run_cycle_count = getMappedRegValue<HWOffsetFix<48,0,UNSIGNED> >("run_cycle_count");
  153. }
  154. }
  155. void StreamFMAKernel::updateState() {
  156. { // Node ID: 22 (NodeInputMappedReg)
  157. id22out_io_oDataT1_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_oDataT1_force_disabled");
  158. }
  159. { // Node ID: 0 (NodeInputMappedReg)
  160. id0out_io_inAT1_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inAT1_force_disabled");
  161. }
  162. { // Node ID: 3 (NodeInputMappedReg)
  163. id3out_io_inBT1_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inBT1_force_disabled");
  164. }
  165. { // Node ID: 27 (NodeInputMappedReg)
  166. id27out_io_oDataT2_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_oDataT2_force_disabled");
  167. }
  168. { // Node ID: 6 (NodeInputMappedReg)
  169. id6out_io_inAT2_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inAT2_force_disabled");
  170. }
  171. { // Node ID: 9 (NodeInputMappedReg)
  172. id9out_io_inBT2_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inBT2_force_disabled");
  173. }
  174. { // Node ID: 32 (NodeInputMappedReg)
  175. id32out_io_oDataT3_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_oDataT3_force_disabled");
  176. }
  177. { // Node ID: 12 (NodeInputMappedReg)
  178. id12out_io_inAT3_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inAT3_force_disabled");
  179. }
  180. { // Node ID: 15 (NodeInputMappedReg)
  181. id15out_io_inBT3_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_inBT3_force_disabled");
  182. }
  183. { // Node ID: 46 (NodeInputMappedReg)
  184. id46out_run_cycle_count = getMappedRegValue<HWOffsetFix<48,0,UNSIGNED> >("run_cycle_count");
  185. }
  186. }
  187. void StreamFMAKernel::preExecute() {
  188. { // Node ID: 2 (NodeInput)
  189. if(((needsToReadInput(m_inAT1))&(((getFlushLevel())<((4l)+(5)))|(!(isFlushingActive()))))) {
  190. (id2st_last_read_value) = (readInput<HWOffsetFix<32,0,TWOSCOMPLEMENT> >(m_inAT1));
  191. }
  192. id2out_data = (id2st_last_read_value);
  193. }
  194. { // Node ID: 5 (NodeInput)
  195. if(((needsToReadInput(m_inBT1))&(((getFlushLevel())<((4l)+(5)))|(!(isFlushingActive()))))) {
  196. (id5st_last_read_value) = (readInput<HWOffsetFix<32,0,TWOSCOMPLEMENT> >(m_inBT1));
  197. }
  198. id5out_data = (id5st_last_read_value);
  199. }
  200. { // Node ID: 8 (NodeInput)
  201. if(((needsToReadInput(m_inAT2))&(((getFlushLevel())<((4l)+(5)))|(!(isFlushingActive()))))) {
  202. (id8st_last_read_value) = (readInput<HWOffsetFix<32,0,TWOSCOMPLEMENT> >(m_inAT2));
  203. }
  204. id8out_data = (id8st_last_read_value);
  205. }
  206. { // Node ID: 11 (NodeInput)
  207. if(((needsToReadInput(m_inBT2))&(((getFlushLevel())<((4l)+(5)))|(!(isFlushingActive()))))) {
  208. (id11st_last_read_value) = (readInput<HWOffsetFix<32,0,TWOSCOMPLEMENT> >(m_inBT2));
  209. }
  210. id11out_data = (id11st_last_read_value);
  211. }
  212. { // Node ID: 14 (NodeInput)
  213. if(((needsToReadInput(m_inAT3))&(((getFlushLevel())<((4l)+(5)))|(!(isFlushingActive()))))) {
  214. (id14st_last_read_value) = (readInput<HWOffsetFix<32,0,TWOSCOMPLEMENT> >(m_inAT3));
  215. }
  216. id14out_data = (id14st_last_read_value);
  217. }
  218. { // Node ID: 17 (NodeInput)
  219. if(((needsToReadInput(m_inBT3))&(((getFlushLevel())<((4l)+(5)))|(!(isFlushingActive()))))) {
  220. (id17st_last_read_value) = (readInput<HWOffsetFix<32,0,TWOSCOMPLEMENT> >(m_inBT3));
  221. }
  222. id17out_data = (id17st_last_read_value);
  223. }
  224. }
  225. void StreamFMAKernel::runComputationCycle() {
  226. if (m_mappedElementsChanged) {
  227. m_mappedElementsChanged = false;
  228. updateState();
  229. std::cout << "StreamFMAKernel: Mapped Elements Changed: Reloaded" << std::endl;
  230. }
  231. preExecute();
  232. execute0();
  233. }
  234. int StreamFMAKernel::getFlushLevelStart() {
  235. return ((1l)+(3l));
  236. }
  237. }