StreamFMAKernel.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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, 10, 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: 8 (NodeInputMappedReg)
  15. registerMappedRegister("io_output_force_disabled", Data(1));
  16. }
  17. { // Node ID: 0 (NodeInputMappedReg)
  18. registerMappedRegister("io_a_force_disabled", Data(1));
  19. }
  20. { // Node ID: 2 (NodeInput)
  21. m_a = registerInput("a",0,5);
  22. }
  23. { // Node ID: 3 (NodeInputMappedReg)
  24. registerMappedRegister("io_b_force_disabled", Data(1));
  25. }
  26. { // Node ID: 5 (NodeInput)
  27. m_b = registerInput("b",1,5);
  28. }
  29. { // Node ID: 11 (NodeOutput)
  30. m_output = registerOutput("output",0 );
  31. }
  32. { // Node ID: 16 (NodeConstantRawBits)
  33. id16out_value = (c_hw_fix_1_0_uns_bits_1);
  34. }
  35. { // Node ID: 26 (NodeConstantRawBits)
  36. id26out_value = (c_hw_fix_1_0_uns_bits_1);
  37. }
  38. { // Node ID: 13 (NodeConstantRawBits)
  39. id13out_value = (c_hw_fix_49_0_uns_bits);
  40. }
  41. { // Node ID: 17 (NodeOutputMappedReg)
  42. registerMappedRegister("current_run_cycle_count", Data(48), true);
  43. }
  44. { // Node ID: 25 (NodeConstantRawBits)
  45. id25out_value = (c_hw_fix_1_0_uns_bits_1);
  46. }
  47. { // Node ID: 19 (NodeConstantRawBits)
  48. id19out_value = (c_hw_fix_49_0_uns_bits);
  49. }
  50. { // Node ID: 22 (NodeInputMappedReg)
  51. registerMappedRegister("run_cycle_count", Data(48));
  52. }
  53. }
  54. void StreamFMAKernel::resetComputation() {
  55. resetComputationAfterFlush();
  56. }
  57. void StreamFMAKernel::resetComputationAfterFlush() {
  58. { // Node ID: 8 (NodeInputMappedReg)
  59. id8out_io_output_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_output_force_disabled");
  60. }
  61. { // Node ID: 0 (NodeInputMappedReg)
  62. id0out_io_a_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_a_force_disabled");
  63. }
  64. { // Node ID: 2 (NodeInput)
  65. (id2st_read_next_cycle) = (c_hw_fix_1_0_uns_bits);
  66. (id2st_last_read_value) = (c_hw_fix_32_0_sgn_undef);
  67. }
  68. { // Node ID: 3 (NodeInputMappedReg)
  69. id3out_io_b_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_b_force_disabled");
  70. }
  71. { // Node ID: 5 (NodeInput)
  72. (id5st_read_next_cycle) = (c_hw_fix_1_0_uns_bits);
  73. (id5st_last_read_value) = (c_hw_fix_32_0_sgn_undef);
  74. }
  75. { // Node ID: 14 (NodeCounter)
  76. (id14st_count) = (c_hw_fix_49_0_uns_bits_1);
  77. }
  78. { // Node ID: 20 (NodeCounter)
  79. (id20st_count) = (c_hw_fix_49_0_uns_bits_1);
  80. }
  81. { // Node ID: 22 (NodeInputMappedReg)
  82. id22out_run_cycle_count = getMappedRegValue<HWOffsetFix<48,0,UNSIGNED> >("run_cycle_count");
  83. }
  84. }
  85. void StreamFMAKernel::updateState() {
  86. { // Node ID: 8 (NodeInputMappedReg)
  87. id8out_io_output_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_output_force_disabled");
  88. }
  89. { // Node ID: 0 (NodeInputMappedReg)
  90. id0out_io_a_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_a_force_disabled");
  91. }
  92. { // Node ID: 3 (NodeInputMappedReg)
  93. id3out_io_b_force_disabled = getMappedRegValue<HWOffsetFix<1,0,UNSIGNED> >("io_b_force_disabled");
  94. }
  95. { // Node ID: 22 (NodeInputMappedReg)
  96. id22out_run_cycle_count = getMappedRegValue<HWOffsetFix<48,0,UNSIGNED> >("run_cycle_count");
  97. }
  98. }
  99. void StreamFMAKernel::preExecute() {
  100. { // Node ID: 2 (NodeInput)
  101. if(((needsToReadInput(m_a))&(((getFlushLevel())<((4l)+(5)))|(!(isFlushingActive()))))) {
  102. (id2st_last_read_value) = (readInput<HWOffsetFix<32,0,TWOSCOMPLEMENT> >(m_a));
  103. }
  104. id2out_data = (id2st_last_read_value);
  105. }
  106. { // Node ID: 5 (NodeInput)
  107. if(((needsToReadInput(m_b))&(((getFlushLevel())<((4l)+(5)))|(!(isFlushingActive()))))) {
  108. (id5st_last_read_value) = (readInput<HWOffsetFix<32,0,TWOSCOMPLEMENT> >(m_b));
  109. }
  110. id5out_data = (id5st_last_read_value);
  111. }
  112. }
  113. void StreamFMAKernel::runComputationCycle() {
  114. if (m_mappedElementsChanged) {
  115. m_mappedElementsChanged = false;
  116. updateState();
  117. std::cout << "StreamFMAKernel: Mapped Elements Changed: Reloaded" << std::endl;
  118. }
  119. preExecute();
  120. execute0();
  121. }
  122. int StreamFMAKernel::getFlushLevelStart() {
  123. return ((1l)+(3l));
  124. }
  125. }