1 #include "FunctionalBlock.h"
\r
2 #include "ReferenceBlock.h"
\r
3 #include "GroupBlock.h"
\r
4 #include "AbstractInterface.h"
\r
5 #include "FunctionalInterface.h"
\r
6 #include "ReferenceInterface.h"
\r
7 #include "BlockParameter.h"
\r
8 #include "ArithmeticEvaluator.h"
\r
11 FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference) throw(Exception) : AbstractBlock() {
\r
12 //if (! _reference->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));
\r
13 //if (! _group->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE));
\r
14 reference = _reference;
\r
16 name = reference->getName();
\r
18 if (reference->getImplementations().isEmpty()) {
\r
19 implementation = NULL;
\r
20 cout << "block has no implementation" << endl;
\r
23 implementation = reference->getImplementations().at(0);
\r
28 void FunctionalBlock::parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock *> *blocksToConfigure) {
\r
30 checkedBlocks->append(this);
\r
32 foreach(BlockParameter* param, params){
\r
33 if(param->isUserParameter() && !param->isValueSet()){
\r
34 if(!blocksToConfigure->contains(param->getOwner())){
\r
35 blocksToConfigure->append(param->getOwner());
\r
39 foreach(AbstractInterface *inter, outputs){
\r
40 foreach(AbstractInterface *connectedInter, inter->getConnectedTo()){
\r
41 if(!checkedBlocks->contains(connectedInter->getOwner())){
\r
42 connectedInter->getOwner()->parametersValidation(checkedBlocks, blocksToConfigure);
\r
49 bool FunctionalBlock::isFunctionalBlock() {
\r
53 bool FunctionalBlock::isSourceBlock() {
\r
54 if (parent == NULL) return true;
\r
58 void FunctionalBlock::populate() {
\r
61 AbstractInterface* inter;
\r
63 // create parameters from reference block
\r
64 QList<BlockParameter*> lstParam = reference->getParameters();
\r
65 for(i=0;i<lstParam.size();i++) {
\r
66 p = lstParam.at(i)->clone();
\r
70 // create interfaces from reference block
\r
71 QList<AbstractInterface *> lstRef = reference->getInterfaces();
\r
72 // store relation between functional and reference
\r
73 QHash<AbstractInterface *, AbstractInterface *> hashIface;
\r
74 for(i=0;i<lstRef.size();i++) {
\r
76 inter = new FunctionalInterface(this, AI_TO_REF(lstRef.at(i)));
\r
78 catch(Exception e) {
\r
79 cerr << "Abnormal case: " << qPrintable(e.getDefaultMessage()) << endl << "Aborting execution." << endl;
\r
82 hashIface.insert(lstRef.at(i),inter);
\r
84 addInterface(inter);
\r
87 AbstractInterface* funCtlIface = NULL;
\r
88 AbstractInterface* funDataIface = NULL;
\r
90 for(i=0;i<lstRef.size();i++) {
\r
91 AbstractInterface* refIface = lstRef.at(i);
\r
92 if (refIface->getPurpose() == AbstractInterface::Control) {
\r
93 funCtlIface = hashIface.value(refIface);
\r
94 funDataIface = hashIface.value(refIface->getAssociatedIface());
\r
95 if (! funCtlIface->setAssociatedIface(funDataIface)) {
\r
96 cerr << "Abnormal case when associating a control interface to data" << endl << "Aborting execution." << endl;
\r
104 QString FunctionalBlock::getReferenceXmlFile() {
\r
105 return ((ReferenceBlock *)reference)->getXmlFile();
\r
108 QString FunctionalBlock::getReferenceHashMd5() {
\r
109 return ((ReferenceBlock *)reference)->getHashMd5();
\r
112 bool FunctionalBlock::createPatterns() {
\r
113 static QString fctName = "FunctionalBlock::createPatterns()";
\r
114 #ifdef DEBUG_FCTNAME
\r
115 cout << "call to " << qPrintable(fctName) << endl;
\r
118 cout << "create patterns for block " << qPrintable(name) << endl;
\r
119 evaluator = new ArithmeticEvaluator();
\r
121 if (! isGeneratorBlock()) {
\r
122 ok = ok & createDelta();
\r
123 if (ok) ok = ok & createConsumptionPattern();
\r
124 if (ok) ok = ok & createProductionCounter();
\r
126 if (ok) ok = ok & createProductionPattern();
\r
131 bool FunctionalBlock::createDelta() {
\r
132 static QString fctName = "FunctionalBlock::createDelta()";
\r
133 #ifdef DEBUG_FCTNAME
\r
134 cout << "call to " << qPrintable(fctName) << endl;
\r
137 QString deltaStr = implementation->getDelta();
\r
138 cout << "delta for " << qPrintable(name) << " = " << qPrintable(deltaStr) << endl;
\r
139 if (deltaStr.isEmpty()) {
\r
144 // look for parameter names
\r
146 double result = evaluateExpression(deltaStr, &ok);
\r
147 if (!ok) return false;
\r
150 cout << "delta = " << delta << endl;
\r
155 bool FunctionalBlock::createConsumptionPattern() {
\r
156 static QString fctName = "FunctionalBlock::createConsumptionPattern()";
\r
157 #ifdef DEBUG_FCTNAME
\r
158 cout << "call to " << qPrintable(fctName) << endl;
\r
163 QHash<QString,QString> consPattern = implementation->getConsumptionPattern();
\r
165 foreach(AbstractInterface* iface, getControlInputs()) {
\r
166 FunctionalInterface* connIface = AI_TO_FUN(iface);
\r
167 QString refName = connIface->getReference()->getName();
\r
168 if (! consPattern.contains(refName)) {
\r
169 cerr << "no consumption pattern for reference interface " << qPrintable(refName) << endl;
\r
172 QList<char>* pattern = expandPattern(consPattern.value(refName),&ok);
\r
173 if (!ok) return false;
\r
174 consumptionPattern.insert(connIface,pattern);
\r
175 if (lengthCP == -1) {
\r
176 lengthCP = pattern->size();
\r
179 if (pattern->size() != lengthCP) return false;
\r
185 bool FunctionalBlock::createProductionPattern() {
\r
186 static QString fctName = "FunctionalBlock::createProductionPattern()";
\r
187 #ifdef DEBUG_FCTNAME
\r
188 cout << "call to " << qPrintable(fctName) << endl;
\r
193 QHash<QString,QString> prodPattern = implementation->getProductionPattern();
\r
195 foreach(AbstractInterface* iface, getControlOutputs()) {
\r
196 FunctionalInterface* connIface = AI_TO_FUN(iface);
\r
197 QString refName = connIface->getReference()->getName();
\r
198 if (! prodPattern.contains(refName)) {
\r
199 cerr << "no production pattern for reference interface " << qPrintable(refName) << endl;
\r
202 QList<char>* pattern = expandPattern(prodPattern.value(refName),&ok);
\r
203 if (!ok) return false;
\r
204 productionPattern.insert(connIface,pattern);
\r
205 if (lengthPP == -1) {
\r
206 lengthPP = pattern->size();
\r
209 if (pattern->size() != lengthPP) return false;
\r
215 bool FunctionalBlock::createProductionCounter() {
\r
216 static QString fctName = "FunctionalBlock::createProductionCounter()";
\r
217 #ifdef DEBUG_FCTNAME
\r
218 cout << "call to " << qPrintable(fctName) << endl;
\r
221 QStringList counterParts = implementation->getProductionCounter().split(",");
\r
222 foreach(QString s, counterParts) {
\r
223 cout << "cont part = " << qPrintable(s) << endl;
\r
225 double val = s.toDouble(&ok);
\r
227 productionCounter.append(val);
\r
229 else if (s.at(0) == '{') {
\r
232 QStringList gen = s.split(":");
\r
233 if (gen.size() != 3) return false;
\r
237 for(int i=0;i<3;i++) {
\r
239 double result = evaluateExpression(gen.at(i),&okVal);
\r
240 if (!okVal) return false;
\r
241 if (i==0) start = result;
\r
242 else if (i==1) nb = result;
\r
243 else if (i==2) step = result;
\r
245 for(int j=0;j<nb;j++) {
\r
246 productionCounter.append(start+j*step);
\r
251 double result = evaluateExpression(s,&okVal);
\r
253 if (!okVal) return false;
\r
254 productionCounter.append(result);
\r
257 foreach(int val, productionCounter) {
\r
258 cout << val << ",";
\r
265 QList<char>* FunctionalBlock::expandPattern(const QString& patternIn, bool* ok) {
\r
266 static QString fctName = "FunctionalBlock::expandPattern()";
\r
267 #ifdef DEBUG_FCTNAME
\r
268 cout << "call to " << qPrintable(fctName) << endl;
\r
272 QString p = patternIn;
\r
275 QList<char>* patternOut = new QList<char>();
\r
276 expandPatternRecur(p,&offset,ok,patternOut);
\r
280 void FunctionalBlock::expandPatternRecur(const QString& patternIn, int *offset, bool *ok, QList<char>* patternOut) {
\r
282 while ((*offset < patternIn.size()) && (patternIn.at(*offset) != ')')) {
\r
284 QChar c = patternIn.at(*offset);
\r
287 expandPatternRecur(patternIn,offset, ok, patternOut);
\r
292 else if (c == '0') {
\r
293 patternOut->append(0);
\r
295 else if (c == '1') {
\r
296 patternOut->append(1);
\r
298 else if (c == 'X') {
\r
299 patternOut->append(-1);
\r
301 else if (c == '{') {
\r
303 QString expr = "";
\r
304 while ((*offset < patternIn.size()) && (patternIn.at(*offset) != '}')) {
\r
305 expr += patternIn.at(*offset);
\r
308 if (*offset == patternIn.size()) {
\r
312 double repeat = evaluateExpression(expr,ok);
\r
316 // repeat just the last value in currentGroup
\r
317 char last = patternOut->last();
\r
318 //cout << "repeat last char " << repeat << " times : " << (int)last << endl;
\r
320 for(int i=1;i<(int)repeat;i++) {
\r
321 patternOut->append(last);
\r
327 // must check if after ), there is a {
\r
328 if ((*offset < patternIn.size()-1) && (patternIn.at(*offset+1) == '{')) {
\r
330 QString expr = "";
\r
331 while ((*offset < patternIn.size()) && (patternIn.at(*offset) != '}')) {
\r
332 expr += patternIn.at(*offset);
\r
335 if (*offset == patternIn.size()) {
\r
339 double repeat = evaluateExpression(expr,ok);
\r
344 cout << "repeat last group " << repeat << " times : ";
\r
345 foreach (char c, currentGroup) cout <<(int)c;
\r
348 QList<char> single = *patternOut;
\r
349 for(int i=1;i<(int)repeat;i++) {
\r
350 patternOut->append(single);
\r
357 double FunctionalBlock::evaluateExpression(const QString& expression, bool* ok) {
\r
358 static QString fctName = "FunctionalBlock::evaluateExpression()";
\r
359 #ifdef DEBUG_FCTNAME
\r
360 cout << "call to " << qPrintable(fctName) << endl;
\r
364 QHash<QString,double> vars;
\r
365 evaluator->setExpression(expression);
\r
366 QList<QString> varNames = evaluator->getVariableNames();
\r
367 foreach (QString name, varNames) {
\r
368 QString paramName = name;
\r
369 paramName.remove(0,1);
\r
370 BlockParameter* param = reference->getParameterFromName(paramName);
\r
371 if (param == NULL) {
\r
372 cerr << "found an unknown parameter in delta"<< endl;
\r
377 int val = param->getDoubleValue(&okVal);
\r
379 cerr << "cannot obtain double value of paramter " << qPrintable(paramName) << endl;
\r
383 vars.insert(name,(double)val);
\r
386 evaluator->setVariablesValue(vars);
\r
389 result = evaluator->evaluate();
\r
392 cerr << "Error at index " << index << ": " << qPrintable(evaluator->getError()) << endl;
\r
399 void FunctionalBlock::createInputPattern() {
\r
401 foreach(AbstractInterface* iface, getControlInputs()) {
\r
402 ConnectedInterface* connIface = AI_TO_CON(iface);
\r
403 QList<char>* out = connIface->getConnectedFrom()->getOutputPattern();
\r
404 if (lengthIP == -1) {
\r
405 lengthIP = out->size();
\r
408 if (out->size() < lengthIP) lengthIP = out->size();
\r
410 if (out->size() > 0) {
\r
411 QList<char>* in = new QList<char>(*out);
\r
412 foreach(char c, *in) {
\r
417 inputPattern.insert(connIface,in);
\r
420 inputPattern.insert(connIface,NULL);
\r
425 bool FunctionalBlock::createAdmittance(int nbExec) {
\r
426 static QString fctName = "FunctionalBlock::createAdmittance()";
\r
427 #ifdef DEBUG_FCTNAME
\r
428 cout << "call to " << qPrintable(fctName) << endl;
\r
431 // firstly, copy CP in AP
\r
432 QMapIterator<AbstractInterface*,QList<char>* > iterC(consumptionPattern);
\r
433 while (iterC.hasNext()) {
\r
435 QList<char>* pattern = new QList<char>(*(iterC.value()));
\r
436 admittance.insert(iterC.key(), pattern);
\r
438 lengthAP = lengthCP;
\r
440 cout << "trigger 1 at c.c. 0" << endl;
\r
441 for(int i=1;i<nbExec;i++) {
\r
442 // searching for the clock cycle for which a new exec starts
\r
444 while ((clock < lengthAP) && (nbGroup < delta)) {
\r
445 if (isValidDataGroup(admittance,clock)) nbGroup+=1;
\r
448 while ((clock < lengthAP) && (! isValidDataGroup(admittance,clock))) clock+=1;
\r
449 cout << "trigger " << (i+1) << " at c.c. " << clock << endl;
\r
451 // combine CP with AP at sc
\r
452 for(int j=0;j<lengthCP;j++) {
\r
453 // first case : column of CP must be placed beyond AP's end.
\r
454 if (sc == lengthAP) {
\r
455 cout << i << "," << j << " append in AP at " << sc << endl;
\r
456 appendToPattern(consumptionPattern,j,admittance,1);
\r
460 // second case : CP and AP can be combined directly (i.e. no X | 1 to do)
\r
461 else if (canCombinePatterns(consumptionPattern,j,admittance,sc)) {
\r
462 cout << i << "," << j << " combine at " << sc << endl;
\r
463 combinePatterns(consumptionPattern,j,admittance,sc);
\r
466 // third case : CP has an X column
\r
467 else if (isOnlyXDataGroup(consumptionPattern,j)) {
\r
468 cout << i << "," << j << " shift rigth AP to combine at " << sc << endl;
\r
469 shiftRightPattern(admittance,sc);
\r
471 if (! canCombinePatterns(consumptionPattern,j,admittance,sc)) {
\r
472 cerr << "Abnormal case when combining AP and CP" << endl;
\r
474 combinePatterns(consumptionPattern,j,admittance,sc);
\r
477 // fourth case : AP has an X column
\r
478 else if (isOnlyXDataGroup(admittance,sc)) {
\r
479 cout << i << "," << j << " jump c.c. for CP at " << sc << endl;
\r
484 cout << "AP and CP are not consistent" << endl;
\r
493 bool FunctionalBlock::checkInputPatternCompatibility() {
\r
494 static QString fctName = "FunctionalBlock::checkInputPatternCompatibility()";
\r
495 #ifdef DEBUG_FCTNAME
\r
496 cout << "call to " << qPrintable(fctName) << endl;
\r
500 // firstly, create input pattern
\r
501 createInputPattern();
\r
502 // if some patterns are not available, end now, returning false
\r
503 if (lengthIP == 0) {
\r
504 clearInputPattern();
\r
507 int nbExec = getNumberOfExecution();
\r
508 ok = createAdmittance(nbExec);
\r
509 if (!ok) return false;
\r
514 bool FunctionalBlock::computeOutputPattern(int nbExec) {
\r
515 static QString fctName = "FunctionalBlock::computeOutputPattern()";
\r
516 #ifdef DEBUG_FCTNAME
\r
517 cout << "call to " << qPrintable(fctName) << endl;
\r
520 /* case 1: the block is a generator for which output pattern
\r
521 must be computed for a nbExec following executions
\r
526 cout << "computing output pattern of " << qPrintable(name) << " for " << nbExec << " executions" << endl;
\r
527 foreach(AbstractInterface* iface, getControlOutputs()) {
\r
528 FunctionalInterface* connIface = AI_TO_FUN(iface);
\r
529 // create output pattern
\r
530 QList<char>* pp = productionPattern.value(connIface);
\r
531 QList<char>* pattern = new QList<char>(*pp);
\r
532 for(int i=1;i<nbExec;i++) pattern->append(*pp);
\r
533 // assign pattern to interface
\r
534 connIface->setOutputPattern(pattern);
\r
535 // store it in QMap
\r
536 outputPattern.insert(connIface,pattern);
\r
540 cout << "computing output pattern of " << qPrintable(name) << endl;
\r
542 // in case of inputPattern not created, do it
\r
543 if (lengthIP <= 0) {
\r
544 // collect the input patterns for each input
\r
545 createInputPattern();
\r
546 // if some patterns are not available, end now, returning false
\r
547 if (lengthIP == 0) {
\r
548 clearInputPattern();
\r
551 cout << "input pattern array initialized with min. len " << lengthIP << endl;
\r
554 // initialize the output pattern
\r
556 foreach(AbstractInterface* iface, getControlOutputs()) {
\r
557 FunctionalInterface* connIface = AI_TO_FUN(iface);
\r
558 lengthOP = lengthIP+productionPattern.value(connIface)->size();
\r
559 QList<char>* pattern = new QList<char>();
\r
560 for(int i=0;i<lengthOP;i++) pattern->append(0);
\r
561 connIface->setOutputPattern(pattern);
\r
562 outputPattern.insert(connIface,pattern);
\r
564 cout << "output pattern array initialized" << endl;
\r
568 // search for the beginning of the first execution.
\r
569 while ((clock < lengthIP) && (! isValidDataGroup(inputPattern,clock))) clock++;
\r
570 cout << "found 1st exec clock: " << clock << endl;
\r
572 while (clock < lengthIP) {
\r
573 // initialize counters for current execution.
\r
574 int p = 0; // index in production pattern
\r
575 int o = 0; // clock+o will give the clock cycle of each output group
\r
576 int cip = 0; // clock+cip give the clock cycle of an input group
\r
577 int ccp = 0; // ccp give a column in the consumptio pattern
\r
578 int nip = 0; // number of input data groups already consumed during the current execution, used while exploring IP
\r
579 int ncp = 0; // number of input data groups already consumed during the current execution, used while exploring CP
\r
580 bool cannotCompleteExec = false;
\r
581 for(int m=0;m<productionCounter.size();m++) {
\r
582 // search for the first production in PP
\r
583 while (!isValidDataGroup(productionPattern,p)) {
\r
587 int gap = 0; // count the number of extra null columns
\r
588 // search for PC(m) valid input group in IP
\r
589 while (nip < productionCounter.at(m)) {
\r
590 if (clock+cip < lengthIP) {
\r
591 if (isValidDataGroup(inputPattern,clock+cip)) nip += 1;
\r
596 cannotCompleteExec = true;
\r
601 if (cannotCompleteExec) break; // no need to go further since the next search of input data group will lead to go outside inputPattern
\r
603 // search for PC(m) valid input group in IP
\r
604 while (ncp < productionCounter.at(m)) {
\r
605 if (isValidDataGroup(consumptionPattern,ccp)) ncp += 1;
\r
609 o += gap; // to take into acocunt of extra null columns
\r
610 combinePatterns(productionPattern,p,outputPattern,clock+o);
\r
615 if (cannotCompleteExec) break; // no need to go further since the next search of input data group will lead to go outside inputPattern
\r
617 // current exec. taken into accunt
\r
620 // search for the next exec.
\r
623 while ((clock < lengthIP) && (nip < delta)) {
\r
624 if (isValidDataGroup(inputPattern,clock)) nip += 1;
\r
625 if (nip < delta) clock += 1;
\r
627 cout << "found exec " << nbExec << " at clock: " << clock << endl;
\r
629 // find the last valid output data group
\r
630 while(! isValidDataGroup(outputPattern,lengthOP-1)) {
\r
631 removeDataGroup(outputPattern,lengthOP-1);
\r
635 // clear input pattern
\r
636 clearInputPattern();
\r
641 bool FunctionalBlock::canCombinePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, QMap<AbstractInterface*, QList<char>* > patternDest, int destCol) {
\r
642 if (patternSrc.size() != patternDest.size()) return false;
\r
643 QMapIterator<AbstractInterface*, QList<char>* > iterSrc(patternSrc);
\r
644 QMapIterator<AbstractInterface*, QList<char>* > iterDest(patternDest);
\r
645 while (iterSrc.hasNext()) {
\r
648 QList<char>* srcPat = iterSrc.value();
\r
649 QList<char>* destPat = iterDest.value();
\r
650 if (srcCol >= srcPat->size()) return false;
\r
651 if (destCol >= destPat->size()) return false;
\r
652 if ((srcPat->at(srcCol) == -1) && (destPat->at(destCol) == 1)) return false;
\r
653 if ((srcPat->at(srcCol) == 1) && (destPat->at(destCol) == -1)) return false;
\r
658 void FunctionalBlock::combinePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, QMap<AbstractInterface*, QList<char>* > patternDest, int destCol) {
\r
659 if (patternSrc.size() != patternDest.size()) return;
\r
660 QMapIterator<AbstractInterface*, QList<char>* > iterSrc(patternSrc);
\r
661 QMapIterator<AbstractInterface*, QList<char>* > iterDest(patternDest);
\r
662 while (iterSrc.hasNext()) {
\r
665 QList<char>* srcPat = iterSrc.value();
\r
666 QList<char>* destPat = iterDest.value();
\r
667 if (srcCol >= srcPat->size()) return;
\r
668 if (destCol >= destPat->size()) return;
\r
669 if ((srcPat->at(srcCol) == -1) && (destPat->at(destCol) == 1)) return;
\r
670 if ((srcPat->at(srcCol) == 1) && (destPat->at(destCol) == -1)) return;
\r
671 destPat->replace(destCol,destPat->at(destCol) | srcPat->at(srcCol));
\r
675 void FunctionalBlock::appendToPattern(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, QMap<AbstractInterface*, QList<char>* > patternDest, int nbCols) {
\r
676 if (patternSrc.size() != patternDest.size()) return;
\r
677 QMapIterator<AbstractInterface*, QList<char>* > iterSrc(patternSrc);
\r
678 QMapIterator<AbstractInterface*, QList<char>* > iterDest(patternDest);
\r
679 while (iterSrc.hasNext()) {
\r
682 QList<char>* srcPat = iterSrc.value();
\r
683 QList<char>* destPat = iterDest.value();
\r
685 while ((srcCol+i < srcPat->size()) && (i<nbCols)) {
\r
686 destPat->append(srcPat->at(srcCol+i));
\r
692 void FunctionalBlock::removeDataGroup(QMap<AbstractInterface *, QList<char> *> &pattern, int offset) {
\r
693 QMapIterator<AbstractInterface*, QList<char>* > iterSrc(pattern);
\r
694 while (iterSrc.hasNext()) {
\r
696 QList<char>* srcPat = iterSrc.value();
\r
697 if (offset < srcPat->size()) {
\r
698 srcPat->removeAt(offset);
\r
703 void FunctionalBlock::shiftRightPattern(const QMap<AbstractInterface *, QList<char> *> &pattern, int offset) {
\r
704 QMapIterator<AbstractInterface*, QList<char>* > iterSrc(pattern);
\r
705 while (iterSrc.hasNext()) {
\r
707 QList<char>* srcPat = iterSrc.value();
\r
708 if (offset < srcPat->size()) {
\r
709 srcPat->insert(offset,0);
\r
714 bool FunctionalBlock::isValidDataGroup(const QMap<AbstractInterface *, QList<char> *> &pattern, int offset) {
\r
715 QMapIterator<AbstractInterface*, QList<char>* > iterSrc(pattern);
\r
716 while (iterSrc.hasNext()) {
\r
718 QList<char>* srcPat = iterSrc.value();
\r
719 if (offset >= srcPat->size()) return false;
\r
720 if (srcPat->at(offset) == 1) return true;
\r
725 bool FunctionalBlock::isOnlyXDataGroup(const QMap<AbstractInterface *, QList<char> *> &pattern, int offset) {
\r
726 QMapIterator<AbstractInterface*, QList<char>* > iterSrc(pattern);
\r
727 while (iterSrc.hasNext()) {
\r
729 QList<char>* srcPat = iterSrc.value();
\r
730 if (offset >= srcPat->size()) return false;
\r
731 if (srcPat->at(offset) != -1) return false;
\r
736 void FunctionalBlock::clearConsumptionPattern() {
\r
737 QMapIterator<AbstractInterface*, QList<char>* > iterP(consumptionPattern);
\r
738 while (iterP.hasNext()) {
\r
740 QList<char>* pattern = iterP.value();
\r
741 if (pattern != NULL) delete pattern;
\r
743 consumptionPattern.clear();
\r
747 void FunctionalBlock::clearProductionPattern() {
\r
748 QMapIterator<AbstractInterface*, QList<char>* > iterP(productionPattern);
\r
749 while (iterP.hasNext()) {
\r
751 QList<char>* pattern = iterP.value();
\r
752 if (pattern != NULL) delete pattern;
\r
754 productionPattern.clear();
\r
758 void FunctionalBlock::clearInputPattern() {
\r
760 QMapIterator<AbstractInterface*,QList<char>* > iterI(inputPattern);
\r
761 while (iterI.hasNext()) {
\r
763 QList<char>* pattern = iterI.value();
\r
764 if (pattern != NULL) delete pattern;
\r
766 inputPattern.clear();
\r
770 int FunctionalBlock::getNumberOfExecution() {
\r
771 /* NB: this method returns the number of executions that have been started
\r
772 but not necessary completed.
\r
774 if (delta <= 0) return 0;
\r
777 // search for the first exec.
\r
778 while ((offset < lengthIP) && (! isValidDataGroup(inputPattern,offset))) offset++;
\r
779 if (offset == lengthIP) return 0;
\r
782 for(int i = offset;i<lengthIP;i++) {
\r
783 if (isValidDataGroup(inputPattern,offset)) nbGroup++;
\r
784 if (nbGroup == delta+1) {
\r