class FunctionalBlock : public AbstractBlock {\r
public:\r
\r
- FunctionalBlock(GroupBlock* _parent, ReferenceBlock* _reference) throw(Exception);\r
-\r
+ FunctionalBlock(Graph* _graph, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception);\r
+ ~FunctionalBlock();\r
// getters\r
inline ReferenceBlock* getReference() { return reference; }\r
-\r
+ inline QList<int> getProductionCounter() { return productionCounter; }\r
+ inline QMap<AbstractInterface*, QList<char>* > getConsumptionPattern() { return consumptionPattern; }\r
+ inline QMap<AbstractInterface*, QList<char>* > getProductionPattern() { return productionPattern; }\r
+ inline QMap<AbstractInterface*, QList<int>* > getAdmittanceDelays() { return admittanceDelays; }\r
+ inline int getConsumptionPatternLength() { return lengthCP; }\r
+ inline int getProductionPatternLength() { return lengthPP; }\r
+ inline int getDelta() { return delta; }\r
+ \r
// setters\r
inline void setImplementation(BlockImplementation* impl) { implementation = impl; }\r
+ inline void setProductionCounter(QList<int> pattern) { productionCounter = pattern; }\r
+ inline void setDelta(int _delta) { delta = _delta; }\r
+ \r
\r
// testers\r
bool isFunctionalBlock();\r
- bool isSourceBlock(); //! a source block has no parent and has no data inputs\r
+ bool isStimuliBlock(); //! a stimuli block has no parent and is out of the top group\r
\r
// others\r
\r
void populate(); // create parameters and interface from reference block\r
+\r
+ QList<QString> getExternalResources();\r
+ void generateVHDL(const QString& path) throw(Exception); // main entry to generate the VHDL code \r
+ QString getIfaceUserName(AbstractInterface* refIface); // get iface name from reference interface\r
+\r
void parametersValidation(QList<AbstractBlock *> *checkedBlocks, QList<AbstractBlock*>* blocksToConfigure);\r
\r
QString getReferenceXmlFile();\r
QString getReferenceHashMd5();\r
\r
// patterns\r
- bool createPatterns();\r
- bool createDelta();\r
- bool createConsumptionPattern(); // initialize a QList<char> for each interface from patterns defined in implementation\r
- bool createProductionPattern(); // initialize a QList<char> for each interface from patterns defined in implementation\r
- bool createProductionCounter(); // initialize a QList<int> from counter defined in implementation\r
- void initConsumptionPattern(); // initialize a char** from patterns defined for each interface\r
- void initProductionPattern(); // initialize a char** from patterns defined for each interface\r
+ void createPatterns() throw(Exception); // called in Graph, before checking compatibility and computing output pattern\r
+ virtual void checkInputPatternCompatibility() throw(Exception);\r
+ virtual void computeOutputPattern(int nbExec = -1) throw(Exception);\r
+ void computeAdmittanceDelays() throw(Exception); // compute differences between IP and admittance\r
+\r
+protected:\r
+ // patterns\r
+ void createDelta() throw(Exception);\r
+ void createConsumptionPattern() throw(Exception); // initialize a QList<char> for each interface from patterns defined in implementation\r
+ void createProductionPattern() throw(Exception); // initialize a QList<char> for each interface from patterns defined in implementation\r
+ void createProductionCounter() throw(Exception); // initialize a QList<int> from counter defined in implementation\r
+ void createAdmittance(int nbExec) throw(Exception); // initialize a QList<char> from consumption pattern and delta\r
+ void createInputPattern() throw(Exception);\r
+\r
void clearConsumptionPattern();\r
- void clearProductionPattern();\r
+ void clearProductionPattern(); \r
+ void clearInputPattern();\r
+ void clearOutputPattern();\r
+ void clearAdmittanceDelays();\r
+ int createTriggers(); // compute the clock cycle at which the block is triggered\r
\r
-private: \r
- // patterns\r
- bool computeOutputPattern(int nbExec = -1);\r
- bool isValidDataGroup(char** pattern, int nbPorts, int clock);\r
+ double evaluateExpression(const QString& expression) throw(Exception);\r
+ QList<char>* expandPattern(const QString& patternIn) throw(Exception);\r
+ QList<char> expandPatternRecur(const QString& patternIn, int* offset) throw(Exception);\r
+ QString replaceExpressions(const QString& patternIn) throw(Exception);\r
+ /*!\r
+ * \brief samePatterns\r
+ * \param patternSrc the pattern that must be tested with patternDest (is patternDest == patternDest) \r
+ * \param srcCol the column index within patternSrc\r
+ * \param patternDest the pattern that must be tested with patternSrc\r
+ * \param destCol the column index within patternDest \r
+ * BEWARE: this method returns as soons as there is an acces problem (i.e. out of list range, impossible combine, ...)\r
+ leaving the dest pattern in an inconsistent state. Thus, it is a good idea to call canCombine before.\r
+ */\r
+ bool samePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, const QMap<AbstractInterface*, QList<char>* >& patternDest, int destCol);\r
+ bool samePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, const QList<int>& srcCols, const QMap<AbstractInterface*, QList<char>* >& patternDest, int destCol);\r
+ /*!\r
+ * \brief canCombinePatterns\r
+ * \param patternSrc the pattern that must be combined with patternDest (patternDest = patternDest OR patternSrc) \r
+ * \param srcCol the column index within patternSrc\r
+ * \param patternDest the pattern that is modified by the combination (patternDest = patternDest OR patternSrc)\r
+ * \param destCol the column index within patternDest \r
+ * \return true if the combination is possible, and false else (e.g. when X1 must be combined with 11)\r
+ * NB: if src/destCol are outside the range of the list, false is returned. \r
+ */\r
+ bool canCombinePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, QMap<AbstractInterface*, QList<char>* > patternDest, int destCol);\r
/*!\r
* \brief combinePatterns\r
* \param patternSrc the pattern that must be combined with patternDest (patternDest = patternDest OR patternSrc) \r
* \param srcCol the column index within patternSrc\r
* \param patternDest the pattern that is modified by the combination (patternDest = patternDest OR patternSrc)\r
- * \param destClock the column index within patternDest\r
- * \param nbCols the numer of columns to combine\r
- * \param nbPorts the number of rows in both patterns\r
- * BEWARE: no check is done if nbCols is consistent with the real length of both patterns, thus an access outside\r
- * the patterns is possible.\r
+ * \param destCol the column index within patternDest \r
+ * BEWARE: this method returns as soons as there is an acces problem (i.e. out of list range, impossible combine, ...)\r
+ leaving the dest pattern in an inconsistent state. Thus, it is a good idea to call canCombine before.\r
*/\r
- void combinePatterns(char** patternSrc, int srcCol, char** patternDest, int destCol, int nbCols, int nbPorts );\r
-\r
- char** consumptionPattern;\r
- int nbConsumingPorts;\r
- int lengthCP;\r
- char** productionPattern;\r
- int nbProducingPorts;\r
- int lengthPP;\r
+ void combinePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, QMap<AbstractInterface*, QList<char>* > patternDest, int destCol);\r
+ /*!\r
+ * \brief appendToPattern\r
+ * \param patternSrc the pattern that must be appended to patternDest\r
+ * \param srcCol the column index within patternSrc\r
+ * \param patternDest the pattern that is modified by the append \r
+ * \param nbCols the numer of columns to append \r
+ * BEWARE: if nbCols is not consistent with the real length of src pattern, there may be less that nbCols\r
+ * that will be appended\r
+ */\r
+ void appendToPattern(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, QMap<AbstractInterface*, QList<char>* > patternDest, int nbCols);\r
+ /*!\r
+ * \brief removeDataGroup\r
+ * \param pattern the pattern for which a column is removed\r
+ * \param offset the index of the column to remove \r
+ */\r
+ void removeDataGroup(QMap<AbstractInterface*, QList<char>* >& pattern, int offset);\r
+ /*!\r
+ * \brief isValidGroup\r
+ * \param pattern the pattern to test\r
+ * \param offset the column to test\r
+ * isValidGroup checks if there is at least one 1 in the column offset of pattern.\r
+ */\r
+ bool isValidDataGroup(const QMap<AbstractInterface*, QList<char>* >& pattern, int offset);\r
+ bool isValidDataGroup(const QMap<AbstractInterface*, QList<char>* >& pattern, const QList<int> offsets);\r
+ /*!\r
+ * \brief isOnlyXGroup\r
+ * \param pattern the pattern to test\r
+ * \param offset the column to test\r
+ * isOnlyXGroup checks if there is only X in the column offset of pattern.\r
+ */\r
+ bool isOnlyXDataGroup(const QMap<AbstractInterface*, QList<char>* >& pattern, int offset);\r
+ /*!\r
+ * \brief shifRightPattern\r
+ * \param pattern the pattern to shift\r
+ * \param offset the column where to shift\r
+ * shiftRightPattern insert a null colmun in pattern, which leads to shift right the pattern at offset.\r
+ * this method is used during admittance generation\r
+ */\r
+ void shiftRightPattern(const QMap<AbstractInterface*, QList<char>* >& pattern, int offset);\r
+\r
+ void generateComments(QTextStream& out, QDomElement &elt, QString coreFile) throw(Exception); // generates comments from <comments> element\r
+ void generateLibraries(QTextStream& out, QDomElement &elt) throw(Exception); // generates libraries from <libraries> element\r
+ void generateArchitecture(QTextStream& out, QDomElement &elt ) throw(Exception); // generate the architecture using <architecture> element\r
+ void generateController(QTextStream& out) throw(Exception); // generate the wishbone controller of the block\r
+ void generateEntityOrComponentBody(QTextStream& out, int indentLevel, bool hasController=false) throw(Exception); // generate the entity/compo body using reference\r
+\r
+ QMap<AbstractInterface*, QList<char>* > consumptionPattern;\r
+ QMap<AbstractInterface*, QString > admittanceCyclic; // the admittance expressed as prologue-cyclic part-epilogue, deduced from admittance\r
+ QMap<AbstractInterface*, QList<char>* > admittance; // the admittance taking into account nb exec.\r
+ QMap<AbstractInterface*, QList<int>* > admittanceDelays; // the delay between what should be consumed and IP\r
+ QMap<AbstractInterface*, QList<char>* > productionPattern;\r
+ QMap<AbstractInterface*,QList<char>* > inputPattern;\r
+ QMap<AbstractInterface*, QList<char>* > outputPattern; // CAUTION: the QList<char>* must also be stored in the outputPattern attributes of AbstractInterface\r
+ QList<int> productionCounter; // only usefull for control output interfaces\r
+ QList<int> triggers; // the clock cycles at which the block is triggered, taking into account IP\r
+ int lengthIP; // for convenience, set in createInputPattern()\r
+ int lengthCP; // for convenience, set in createConsumptionPattern()\r
+ int lengthAP; // for convenience, set in createAdmittance()\r
+ int lengthPP; // for convenience, set in createProductionPattern()\r
+ int lengthOP; // for convenience, set in computeOutputPattern()\r
+ int delta;\r
+ \r
ArithmeticEvaluator* evaluator;\r
\r
ReferenceBlock* reference;\r