codeArray.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. Generated with CMSIS-DSP Compute Graph Scripts.
  3. The generated code is not covered by CMSIS-DSP license.
  4. The support classes and code is covered by CMSIS-DSP license.
  5. */
  6. {% if config.dumpFIFO %}
  7. #define DEBUGSCHED 1
  8. {% endif %}
  9. #include "arm_math.h"
  10. #include "{{config.customCName}}"
  11. #include "GenericNodes.h"
  12. #include "{{config.appNodesCName}}"
  13. #include "{{config.schedulerCFileName}}.h"
  14. {% macro optionalargs() -%}
  15. {% if config.cOptionalArgs %},{{config.cOptionalArgs}}{% endif %}
  16. {% endmacro -%}
  17. /* List of nodes */
  18. static NodeBase *nodeArray[{{nbNodes}}]={0};
  19. /*
  20. Description of the scheduling. It is a list of nodes to call.
  21. The values are indexes in the previous array.
  22. */
  23. static unsigned int schedule[{{schedLen}}]=
  24. {
  25. {{schedDescription}}
  26. };
  27. /***********
  28. FIFO buffers
  29. ************/
  30. {% for fifo in fifos %}
  31. #define FIFOSIZE{{fifo.fifoID}} {{fifo.length}}
  32. {% endfor %}
  33. {% for buf in sched._graph._allBuffers %}
  34. #define BUFFERSIZE{{buf._bufferID}} {{buf._length}}
  35. {{buf._theType.ctype}} {{config.prefix}}buf{{buf._bufferID}}[BUFFERSIZE{{buf._bufferID}}]={0};
  36. {% endfor %}
  37. /**************
  38. Classes created for pure function calls (like some CMSIS-DSP functions)
  39. ***************/
  40. {% for p in pureNodes %}
  41. {% set node = pureNodes[p] %}
  42. template<{{node.templateParameters}}> class Func{{node.pureClassID}};
  43. template<{{node.specializedTemplateParameters}}>
  44. class Func{{node.pureClassID}}<{{node.templateArguments}}>: public {{node.nodeKind}}<{{node.templateParametersForGeneric}}>
  45. {
  46. public:
  47. Func{{node.pureClassID}}({{node.datatypeForConstructor}}):
  48. {{node.nodeKind}}<{{node.templateParametersForGeneric}}>({{node.genericConstructorArgs}}){};
  49. int run(){
  50. {{node.codeArrayRun()}}
  51. };
  52. };
  53. {% endfor %}
  54. uint32_t {{config.schedName}}(int *error{{optionalargs()}})
  55. {
  56. int cgStaticError=0;
  57. uint32_t nbSchedule=0;
  58. {% if config.debug %}
  59. int32_t debugCounter={{config.debugLimit}};
  60. {% endif %}
  61. /*
  62. Create FIFOs objects
  63. */
  64. {% for id in range(nbFifos) %}
  65. {% if fifos[id].hasDelay %}
  66. FIFO<{{fifos[id].theType.ctype}},FIFOSIZE{{id}},{{fifos[id].isArrayAsInt}}> fifo{{id}}({{config.prefix}}buf{{fifos[id].buffer._bufferID}},{{fifos[id].delay}});
  67. {% else %}
  68. FIFO<{{fifos[id].theType.ctype}},FIFOSIZE{{id}},{{fifos[id].isArrayAsInt}}> fifo{{id}}({{config.prefix}}buf{{fifos[id].buffer._bufferID}});
  69. {% endif %}
  70. {% endfor %}
  71. CG_BEFORE_NODE_INIT;
  72. /*
  73. Create node objects
  74. */
  75. {% for node in nodes %}
  76. {% if node.hasState %}
  77. {{node.typeName}}<{{node.ioTemplate()}}> {{node.nodeName}}({{node.args}});
  78. nodeArray[{{node.codeID}}]=(NodeBase*)&{{node.nodeName}};
  79. {% else %}
  80. Func{{node.pureClassID}}<{{node.constructorTypes}}> func{{node.pureNodeID}}({{node.constructorArguments}});
  81. nodeArray[{{node.codeID}}]=(NodeBase*)&func{{node.pureNodeID}};
  82. {% endif %}
  83. {% endfor %}
  84. CG_BEFORE_SCHEDULE;
  85. /* Run several schedule iterations */
  86. {% if config.debug %}
  87. while((cgStaticError==0) && (debugCounter > 0))
  88. {% else %}
  89. while(cgStaticError==0)
  90. {% endif %}
  91. {
  92. /* Run a schedule iteration */
  93. {% if config.eventRecorder -%}
  94. EventRecord2 (Evt_Scheduler, nbSchedule, 0);
  95. {% endif -%}
  96. CG_BEFORE_ITERATION;
  97. for(unsigned long id=0 ; id < {{schedLen}}; id++)
  98. {
  99. unsigned int nodeId = schedule[id];
  100. {% if config.eventRecorder -%}
  101. EventRecord2 (Evt_Node, nodeId, 0);
  102. {% endif -%}
  103. cgStaticError = nodeArray[nodeId]->run();
  104. {% if config.eventRecorder -%}
  105. if (cgStaticError<0)
  106. {
  107. EventRecord2 (Evt_Error, cgStaticError, 0);
  108. }
  109. {% endif -%}
  110. CHECKERROR;
  111. }
  112. {% if config.debug %}
  113. debugCounter--;
  114. {% endif %}
  115. CG_AFTER_ITERATION;
  116. nbSchedule++;
  117. }
  118. errorHandling:
  119. *error=cgStaticError;
  120. return(nbSchedule);
  121. }