X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/cf93fd850a8b6e9a6f40faed9f796a0e2fb0cedb..df84660fd98b39737692d57b68c8b2c2d34af0f1:/FunctionalBlock.cpp diff --git a/FunctionalBlock.cpp b/FunctionalBlock.cpp index 534625d..7be000a 100644 --- a/FunctionalBlock.cpp +++ b/FunctionalBlock.cpp @@ -142,7 +142,15 @@ void FunctionalBlock::createPatterns() throw(Exception) { } catch(Exception e) { throw(e); - } + } + cout << "PP of " << qPrintable(name) << endl; + QMapIterator* > it(productionPattern); + while (it.hasNext()) { + it.next(); + QList* pat = it.value(); + foreach(char c, *pat) cout << (int)c; + cout << endl; + } } void FunctionalBlock::createDelta() throw(Exception) { @@ -308,7 +316,7 @@ QList* FunctionalBlock::expandPattern(const QString& patternIn) throw(Exce int offset = 0; QList* patternOut = new QList(); try { - expandPatternRecur(p,&offset, patternOut); + patternOut->append(expandPatternRecur(p,&offset)); } catch(Exception e) { throw(e); @@ -317,28 +325,30 @@ QList* FunctionalBlock::expandPattern(const QString& patternIn) throw(Exce return patternOut; } -void FunctionalBlock::expandPatternRecur(const QString& patternIn, int *offset, QList* patternOut) throw(Exception) { +QList FunctionalBlock::expandPatternRecur(const QString& patternIn, int *offset) throw(Exception) { + QList patternOut; + while ((*offset < patternIn.size()) && (patternIn.at(*offset) != ')')) { QChar c = patternIn.at(*offset); if (c == '(') { *offset += 1; try { - expandPatternRecur(patternIn,offset, patternOut); + patternOut.append(expandPatternRecur(patternIn,offset)); } catch(Exception e) { throw(e); } } else if (c == '0') { - patternOut->append(0); + patternOut.append(0); } else if (c == '1') { - patternOut->append(1); + patternOut.append(1); } else if (c == 'X') { - patternOut->append(-1); + patternOut.append(-1); } else if (c == '{') { *offset += 1; @@ -358,11 +368,11 @@ void FunctionalBlock::expandPatternRecur(const QString& patternIn, int *offset, throw(e); } // repeat just the last value in currentGroup - char last = patternOut->last(); + char last = patternOut.last(); //cout << "repeat last char " << repeat << " times : " << (int)last << endl; for(int i=1;i<(int)repeat;i++) { - patternOut->append(last); + patternOut.append(last); } } *offset += 1; @@ -391,11 +401,12 @@ void FunctionalBlock::expandPatternRecur(const QString& patternIn, int *offset, foreach (char c, currentGroup) cout <<(int)c; cout << endl; */ - QList single = *patternOut; + QList single = patternOut; for(int i=1;i<(int)repeat;i++) { - patternOut->append(single); + patternOut.append(single); } } + return patternOut; } double FunctionalBlock::evaluateExpression(const QString& expression) throw(Exception) { @@ -722,6 +733,132 @@ void FunctionalBlock::computeOutputPattern(int nbExec) throw(Exception) { } } +/* + +void FunctionalBlock::computeOutputPattern(int nbExec) throw(Exception) { + static QString fctName = "FunctionalBlock::computeOutputPattern()"; +#ifdef DEBUG_FCTNAME + cout << "call to " << qPrintable(fctName) << endl; +#endif + + // case 1: the block is a generator for which output pattern + // must be computed for a nbExec following executions + + if (nbExec > 0) { + cout << "computing output pattern of " << qPrintable(name) << " for " << nbExec << " executions" << endl; + foreach(AbstractInterface* iface, getControlOutputs()) { + FunctionalInterface* connIface = AI_TO_FUN(iface); + // create output pattern + QList* pp = productionPattern.value(connIface); + QList* pattern = new QList(*pp); + for(int i=1;iappend(*pp); + // assign pattern to interface + connIface->setOutputPattern(pattern); + // store it in QMap + outputPattern.insert(connIface,pattern); + } + } + else { + cout << "computing output pattern of " << qPrintable(name) << endl; + + // in case of inputPattern not created, do it + if (lengthIP <= 0) { + // collect the input patterns for each input + try { + createInputPattern(); + } + catch(Exception e) { + throw(e); + } + cout << "input pattern array initialized with min. len " << lengthIP << endl; + } + + // initialize the output pattern + lengthOP = 0; + foreach(AbstractInterface* iface, getControlOutputs()) { + FunctionalInterface* connIface = AI_TO_FUN(iface); + lengthOP = lengthIP+productionPattern.value(connIface)->size(); + QList* pattern = new QList(); + for(int i=0;iappend(0); + connIface->setOutputPattern(pattern); + outputPattern.insert(connIface,pattern); + } + cout << "output pattern array initialized" << endl; + + int clock = 0; + nbExec = 0; + // search for the beginning of the first execution. + while ((clock < lengthIP) && (! isValidDataGroup(inputPattern,clock))) clock++; + cout << "found 1st exec clock: " << clock << endl; + + while (clock < lengthIP) { + // initialize counters for current execution. + int p = 0; // index in production pattern + int o = 0; // clock+o will give the clock cycle of each output group + int cip = 0; // clock+cip give the clock cycle of an input group + int ccp = 0; // ccp give a column in the consumptio pattern + int nip = 0; // number of input data groups already consumed during the current execution, used while exploring IP + int ncp = 0; // number of input data groups already consumed during the current execution, used while exploring CP + bool cannotCompleteExec = false; + for(int m=0;m* >& patternSrc, int srcCol, const QMap* >& patternDest, int destCol) { if (patternSrc.size() != patternDest.size()) return false;