X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/48f48e6a26a54751ecd0ab90b10ab972cc5e89cd..fc9f5b8b77edda9e49a35d8ef75c4d71caf1c832:/FunctionalBlock.h diff --git a/FunctionalBlock.h b/FunctionalBlock.h index b6ac65f..440c154 100644 --- a/FunctionalBlock.h +++ b/FunctionalBlock.h @@ -27,10 +27,14 @@ class FunctionalBlock : public AbstractBlock { public: FunctionalBlock(GroupBlock* _parent, ReferenceBlock* _reference) throw(Exception); - + ~FunctionalBlock(); // getters inline ReferenceBlock* getReference() { return reference; } inline QList getProductionCounter() { return productionCounter; } + inline QMap* > getConsumptionPattern() { return consumptionPattern; } + inline QMap* > getProductionPattern() { return productionPattern; } + inline int getConsumptionPatternLength() { return lengthCP; } + inline int getProductionPatternLength() { return lengthPP; } inline int getDelta() { return delta; } // setters @@ -52,45 +56,110 @@ public: QString getReferenceHashMd5(); // patterns - bool createPatterns(); - bool createDelta(); - bool createConsumptionPattern(); // initialize a QList for each interface from patterns defined in implementation - bool createProductionPattern(); // initialize a QList for each interface from patterns defined in implementation - bool createProductionCounter(); // initialize a QList from counter defined in implementation - void initConsumptionPattern(); // initialize a char** from patterns defined for each interface - void initProductionPattern(); // initialize a char** from patterns defined for each interface + void createPatterns() throw(Exception); // called in Graph, before checking compatibility and computing output pattern + void checkInputPatternCompatibility() throw(Exception); + void computeOutputPattern(int nbExec = -1) throw(Exception); + +private: + // patterns + void createDelta() throw(Exception); + void createConsumptionPattern() throw(Exception); // initialize a QList for each interface from patterns defined in implementation + void createProductionPattern() throw(Exception); // initialize a QList for each interface from patterns defined in implementation + void createProductionCounter() throw(Exception); // initialize a QList from counter defined in implementation + void createAdmittance(int nbExec) throw(Exception); // initialize a QList from consumption pattern and delta void clearConsumptionPattern(); void clearProductionPattern(); - bool computeOutputPattern(int nbExec = -1); + void createInputPattern() throw(Exception); + void clearInputPattern(); + int createTriggers(); // compute the clock cycle at which the block is triggered -private: - // patterns - bool isValidDataGroup(char** pattern, int nbPorts, int clock); - double evaluateExpression(const QString& expression, bool* ok); - QList expandPattern(const QString& pattern, bool* ok); - QList expandPatternRecur(const QString& pattern, int* offset, bool* ok); + double evaluateExpression(const QString& expression) throw(Exception); + QList* expandPattern(const QString& patternIn) throw(Exception); + void expandPatternRecur(const QString& patternIn, int* offset, QList *patternOut) throw(Exception); + /*! + * \brief samePatterns + * \param patternSrc the pattern that must be tested with patternDest (is patternDest == patternDest) + * \param srcCol the column index within patternSrc + * \param patternDest the pattern that must be tested with patternSrc + * \param destCol the column index within patternDest + * BEWARE: this method returns as soons as there is an acces problem (i.e. out of list range, impossible combine, ...) + leaving the dest pattern in an inconsistent state. Thus, it is a good idea to call canCombine before. + */ + bool samePatterns(const QMap* >& patternSrc, int srcCol, const QMap* >& patternDest, int destCol); + /*! + * \brief canCombinePatterns + * \param patternSrc the pattern that must be combined with patternDest (patternDest = patternDest OR patternSrc) + * \param srcCol the column index within patternSrc + * \param patternDest the pattern that is modified by the combination (patternDest = patternDest OR patternSrc) + * \param destCol the column index within patternDest + * \return true if the combination is possible, and false else (e.g. when X1 must be combined with 11) + * NB: if src/destCol are outside the range of the list, false is returned. + */ + bool canCombinePatterns(const QMap* >& patternSrc, int srcCol, QMap* > patternDest, int destCol); /*! * \brief combinePatterns * \param patternSrc the pattern that must be combined with patternDest (patternDest = patternDest OR patternSrc) * \param srcCol the column index within patternSrc * \param patternDest the pattern that is modified by the combination (patternDest = patternDest OR patternSrc) - * \param destClock the column index within patternDest - * \param nbCols the numer of columns to combine - * \param nbPorts the number of rows in both patterns - * BEWARE: no check is done if nbCols is consistent with the real length of both patterns, thus an access outside - * the patterns is possible. + * \param destCol the column index within patternDest + * BEWARE: this method returns as soons as there is an acces problem (i.e. out of list range, impossible combine, ...) + leaving the dest pattern in an inconsistent state. Thus, it is a good idea to call canCombine before. */ - void combinePatterns(char** patternSrc, int srcCol, char** patternDest, int destCol, int nbCols, int nbPorts ); - - QList productionCounter; //! only usefull for output interfaces + void combinePatterns(const QMap* >& patternSrc, int srcCol, QMap* > patternDest, int destCol); + /*! + * \brief appendToPattern + * \param patternSrc the pattern that must be appended to patternDest + * \param srcCol the column index within patternSrc + * \param patternDest the pattern that is modified by the append + * \param nbCols the numer of columns to append + * BEWARE: if nbCols is not consistent with the real length of src pattern, there may be less that nbCols + * that will be appended + */ + void appendToPattern(const QMap* >& patternSrc, int srcCol, QMap* > patternDest, int nbCols); + /*! + * \brief removeDataGroup + * \param pattern the pattern for which a column is removed + * \param offset the index of the column to remove + */ + void removeDataGroup(QMap* >& pattern, int offset); + /*! + * \brief isValidGroup + * \param pattern the pattern to test + * \param offset the column to test + * isValidGroup checks if there is at least one 1 in the column offset of pattern. + */ + bool isValidDataGroup(const QMap* >& pattern, int offset); + /*! + * \brief isOnlyXGroup + * \param pattern the pattern to test + * \param offset the column to test + * isOnlyXGroup checks if there is only X in the column offset of pattern. + */ + bool isOnlyXDataGroup(const QMap* >& pattern, int offset); + /*! + * \brief shifRightPattern + * \param pattern the pattern to shift + * \param offset the column where to shift + * shiftRightPattern insert a null colmun in pattern, which leads to shift right the pattern at offset. + * this method is used during admittance generation + */ + void shiftRightPattern(const QMap* >& pattern, int offset); + + QMap* > consumptionPattern; + QMap admittanceCyclic; // the admittance expressed as prologue-cyclic part-eppilogue, deduced from admittance + QMap* > admittance; // the admittance taking into account nb exec. + QMap* > productionPattern; + QMap* > inputPattern; + QMap* > outputPattern; // CAUTION: the QList* must also be stored in the outputPattern attributes of AbstractInterface + QList productionCounter; // only usefull for control output interfaces + QList triggers; // the clock cycles at which the block is triggered, taking into account IP + int lengthIP; // for convenience, set in createInputPattern() + int lengthCP; // for convenience, set in createConsumptionPattern() + int lengthAP; // for convenience, set in createAdmittance() + int lengthPP; // for convenience, set in createProductionPattern() + int lengthOP; // for convenience, set in computeOutputPattern() int delta; - - char** consumptionPattern; - int nbConsumingPorts; - int lengthCP; - char** productionPattern; - int nbProducingPorts; - int lengthPP; + ArithmeticEvaluator* evaluator; ReferenceBlock* reference;