X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/2019e5afdaf7fd0ad21607848710348bbc3be256..84eeae848c9d322ea4c935b8ec7338f69becbc10:/FunctionalBlock.cpp diff --git a/FunctionalBlock.cpp b/FunctionalBlock.cpp index ac27de4..66e89b4 100644 --- a/FunctionalBlock.cpp +++ b/FunctionalBlock.cpp @@ -22,6 +22,12 @@ FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference else { implementation = reference->getImplementations().at(0); } + lengthAP = -1; + lengthCP = -1; + lengthIP = -1; + lengthOP = -1; + lengthPP = -1; + delta = -1; } @@ -397,6 +403,11 @@ double FunctionalBlock::evaluateExpression(const QString& expression, bool* ok) } void FunctionalBlock::createInputPattern() { + static QString fctName = "FunctionalBlock::createInputPattern())"; +#ifdef DEBUG_FCTNAME + cout << "call to " << qPrintable(fctName) << endl; +#endif + lengthIP = -1; foreach(AbstractInterface* iface, getControlInputs()) { ConnectedInterface* connIface = AI_TO_CON(iface); @@ -486,7 +497,15 @@ bool FunctionalBlock::createAdmittance(int nbExec) { } } } - + // turn all X into 0 + QMapIterator* > iterA(admittance); + while (iterA.hasNext()) { + iterA.next(); + QList* pattern = iterA.value(); + for(int i=0;isize();i++) { + if (pattern->at(i) == -1) pattern->replace(i,0); + } + } return true; } @@ -508,6 +527,24 @@ bool FunctionalBlock::checkInputPatternCompatibility() { ok = createAdmittance(nbExec); if (!ok) return false; + int clock = 0; // index in IP + int i = 0; // index in AP + while (clock < lengthIP) { + if (samePatterns(inputPattern,clock,admittance,i)) { + clock++; + i++; + } + else { + if (isValidDataGroup(admittance,i)) { + + } + else { + // IP and AP are not equal and AP is a valid group -> not compatible + return false; + } + + } + } return true; } @@ -638,6 +675,23 @@ bool FunctionalBlock::computeOutputPattern(int nbExec) { return true; } +bool FunctionalBlock::samePatterns(const QMap* >& patternSrc, int srcCol, const QMap* >& patternDest, int destCol) { + + if (patternSrc.size() != patternDest.size()) return false; + QMapIterator* > iterSrc(patternSrc); + QMapIterator* > iterDest(patternDest); + while (iterSrc.hasNext()) { + iterSrc.next(); + iterDest.next(); + QList* srcPat = iterSrc.value(); + QList* destPat = iterDest.value(); + if (srcCol >= srcPat->size()) return false; + if (destCol >= destPat->size()) return false; + if (srcPat->at(srcCol) != destPat->at(destCol)) return false; + } + return true; +} + bool FunctionalBlock::canCombinePatterns(const QMap* >& patternSrc, int srcCol, QMap* > patternDest, int destCol) { if (patternSrc.size() != patternDest.size()) return false; QMapIterator* > iterSrc(patternSrc);