X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/7af5c69c22148510cf8f042552018c9b966860cd..refs/heads/master:/FunctionalBlock.h?ds=sidebyside diff --git a/FunctionalBlock.h b/FunctionalBlock.h index 2cf9a5a..93ac7d1 100644 --- a/FunctionalBlock.h +++ b/FunctionalBlock.h @@ -26,11 +26,16 @@ using namespace Qt; class FunctionalBlock : public AbstractBlock { public: - FunctionalBlock(GroupBlock* _parent, ReferenceBlock* _reference) throw(Exception); - + FunctionalBlock(Graph* _graph, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception); + ~FunctionalBlock(); // getters inline ReferenceBlock* getReference() { return reference; } inline QList<int> getProductionCounter() { return productionCounter; } + inline QMap<AbstractInterface*, QList<char>* > getConsumptionPattern() { return consumptionPattern; } + inline QMap<AbstractInterface*, QList<char>* > getProductionPattern() { return productionPattern; } + inline QMap<AbstractInterface*, QList<int>* > getAdmittanceDelays() { return admittanceDelays; } + inline int getConsumptionPatternLength() { return lengthCP; } + inline int getProductionPatternLength() { return lengthPP; } inline int getDelta() { return delta; } // setters @@ -41,31 +46,58 @@ public: // testers bool isFunctionalBlock(); - bool isSourceBlock(); //! a source block has no parent and has no data inputs + bool isStimuliBlock(); //! a stimuli block has no parent and is out of the top group // others void populate(); // create parameters and interface from reference block + + QList<QString> getExternalResources(); + void generateVHDL(const QString& path) throw(Exception); // main entry to generate the VHDL code + QString getIfaceUserName(AbstractInterface* refIface); // get iface name from reference interface + void parametersValidation(QList<AbstractBlock *> *checkedBlocks, QList<AbstractBlock*>* blocksToConfigure); QString getReferenceXmlFile(); QString getReferenceHashMd5(); // patterns - bool createPatterns(); - bool createDelta(); - bool createConsumptionPattern(); // initialize a QList<char> for each interface from patterns defined in implementation - bool createProductionPattern(); // initialize a QList<char> for each interface from patterns defined in implementation - bool createProductionCounter(); // initialize a QList<int> from counter defined in implementation + void createPatterns() throw(Exception); // called in Graph, before checking compatibility and computing output pattern + virtual void checkInputPatternCompatibility() throw(Exception); + virtual void computeOutputPattern(int nbExec = -1) throw(Exception); + void computeAdmittanceDelays() throw(Exception); // compute differences between IP and admittance + +protected: + // patterns + void createDelta() throw(Exception); + void createConsumptionPattern() throw(Exception); // initialize a QList<char> for each interface from patterns defined in implementation + void createProductionPattern() throw(Exception); // initialize a QList<char> for each interface from patterns defined in implementation + void createProductionCounter() throw(Exception); // initialize a QList<int> from counter defined in implementation + void createAdmittance(int nbExec) throw(Exception); // initialize a QList<char> from consumption pattern and delta + void createInputPattern() throw(Exception); + void clearConsumptionPattern(); - void clearProductionPattern(); - bool computeOutputPattern(int nbExec = -1); + void clearProductionPattern(); + void clearInputPattern(); + void clearOutputPattern(); + void clearAdmittanceDelays(); + int createTriggers(); // compute the clock cycle at which the block is triggered -private: - // patterns - double evaluateExpression(const QString& expression, bool* ok); - QList<char>* expandPattern(const QString& patternIn, bool* ok); - void expandPatternRecur(const QString& patternIn, int* offset, bool* ok, QList<char> *patternOut); + double evaluateExpression(const QString& expression) throw(Exception); + QList<char>* expandPattern(const QString& patternIn) throw(Exception); + QList<char> expandPatternRecur(const QString& patternIn, int* offset) throw(Exception); + QString replaceExpressions(const QString& patternIn) 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<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, const QMap<AbstractInterface*, QList<char>* >& patternDest, int destCol); + bool samePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, const QList<int>& srcCols, const QMap<AbstractInterface*, QList<char>* >& patternDest, int destCol); /*! * \brief canCombinePatterns * \param patternSrc the pattern that must be combined with patternDest (patternDest = patternDest OR patternSrc) @@ -109,6 +141,7 @@ private: * isValidGroup checks if there is at least one 1 in the column offset of pattern. */ bool isValidDataGroup(const QMap<AbstractInterface*, QList<char>* >& pattern, int offset); + bool isValidDataGroup(const QMap<AbstractInterface*, QList<char>* >& pattern, const QList<int> offsets); /*! * \brief isOnlyXGroup * \param pattern the pattern to test @@ -125,13 +158,26 @@ private: */ void shiftRightPattern(const QMap<AbstractInterface*, QList<char>* >& pattern, int offset); + void generateComments(QTextStream& out, QDomElement &elt, QString coreFile) throw(Exception); // generates comments from <comments> element + void generateLibraries(QTextStream& out, QDomElement &elt) throw(Exception); // generates libraries from <libraries> element + void generateArchitecture(QTextStream& out, QDomElement &elt ) throw(Exception); // generate the architecture using <architecture> element + void generateController(QTextStream& out) throw(Exception); // generate the wishbone controller of the block + void generateEntityOrComponentBody(QTextStream& out, int indentLevel, bool hasController=false) throw(Exception); // generate the entity/compo body using reference + QMap<AbstractInterface*, QList<char>* > consumptionPattern; - QMap<AbstractInterface*, QString > admittance; // the admittance expressed as prologue-cyclic part-eppilogue - QMap<AbstractInterface*, QList<char>* > admittanceExpanded; // the admittance expanded by taking into account nb exec. + QMap<AbstractInterface*, QString > admittanceCyclic; // the admittance expressed as prologue-cyclic part-epilogue, deduced from admittance + QMap<AbstractInterface*, QList<char>* > admittance; // the admittance taking into account nb exec. + QMap<AbstractInterface*, QList<int>* > admittanceDelays; // the delay between what should be consumed and IP QMap<AbstractInterface*, QList<char>* > productionPattern; + QMap<AbstractInterface*,QList<char>* > inputPattern; QMap<AbstractInterface*, QList<char>* > outputPattern; // CAUTION: the QList<char>* must also be stored in the outputPattern attributes of AbstractInterface - QList<int> productionCounter; //! only usefull for control output interfaces - + QList<int> productionCounter; // only usefull for control output interfaces + QList<int> 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; ArithmeticEvaluator* evaluator;