X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/3bcfe4df6fdde086eb1b59f7a0173358170174a1..refs/heads/master:/FunctionalBlock.cpp?ds=sidebyside diff --git a/FunctionalBlock.cpp b/FunctionalBlock.cpp index ccaa7b2..98e5e87 100644 --- a/FunctionalBlock.cpp +++ b/FunctionalBlock.cpp @@ -8,7 +8,7 @@ #include "ArithmeticEvaluator.h" -FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference, bool createIfaces) throw(Exception) : AbstractBlock() { +FunctionalBlock::FunctionalBlock(Graph *_graph, GroupBlock *_parent, ReferenceBlock *_reference, bool createIfaces) throw(Exception) : AbstractBlock(_graph) { //if (! _reference->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE)); //if (! _group->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE)); reference = _reference; @@ -30,10 +30,17 @@ FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference delta = -1; evaluator = NULL; + BlockParameter* p; + // create parameters from reference block + QList lstParam = reference->getParameters(); + for(int i=0;iclone(); + addParameter(p); + } + if (createIfaces) { populate(); } - } FunctionalBlock::~FunctionalBlock() { @@ -65,23 +72,15 @@ bool FunctionalBlock::isFunctionalBlock() { return true; } -bool FunctionalBlock::isSourceBlock() { +bool FunctionalBlock::isStimuliBlock() { if (parent == NULL) return true; return false; } void FunctionalBlock::populate() { - int i; - BlockParameter* p; - AbstractInterface* inter; - - // create parameters from reference block - QList lstParam = reference->getParameters(); - for(i=0;iclone(); - addParameter(p); - } + int i; + AbstractInterface* inter; ConnectedInterface* toClk = NULL; ConnectedInterface* toRst = NULL; // create interfaces from reference block @@ -146,7 +145,7 @@ void FunctionalBlock::createPatterns() throw(Exception) { cout << "create patterns for block " << qPrintable(name) << endl; if (evaluator == NULL) evaluator = new ArithmeticEvaluator(); - if (! isGeneratorBlock()) { + if (! isSourceBlock()) { try { createDelta(); createConsumptionPattern(); @@ -669,6 +668,7 @@ void FunctionalBlock::createInputPattern() throw(Exception) { cout << "call to " << qPrintable(fctName) << endl; #endif + cout << "creating input pattern" << endl; lengthIP = -1; foreach(AbstractInterface* iface, getControlInputs()) { @@ -846,125 +846,113 @@ void FunctionalBlock::computeOutputPattern(int nbExec) throw(Exception) { clearOutputPattern(); - /* case 1: the block is a generator for which output pattern - must be computed for a nbExec following executions - */ + if (specialType != NotSpecial) { + cerr << "Abnormal case: the block is special and output pattern is computed normally" << endl; + throw(Exception(INVALID_FUNBLOCK_USE,this)); + } - 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); + cout << "computing output pattern of " << qPrintable(name) << endl; + + // in case of inputPattern not created, do it + if (lengthIP <= 0) { + + cout << "Strange case: input pattern is not created while it is time to compute output pattern !" << endl; + // collect the input patterns for each input + try { + createInputPattern(); } + catch(Exception e) { + throw(e); + } + cout << "input pattern array initialized with min. len " << lengthIP << endl; } - else { - cout << "computing output pattern of " << qPrintable(name) << endl; - - // in case of inputPattern not created, do it - if (lengthIP <= 0) { - cout << "Strange case: input pattern is not created while it is time to compute output pattern !" << endl; - // collect the input patterns for each input - try { - createInputPattern(); - } - catch(Exception e) { - throw(e); + // 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;msize(); - 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;mgetDescription() << endl; + QStringList lines = reference->getDescription().split("\n"); + foreach(QString line, lines) { + out << "-- " << line << endl; + } out << "--" << endl; QDomElement eltNote = eltLog.nextSiblingElement("notes"); QDomElement note = eltNote.firstChildElement(); QString noteTxt = note.text(); - out << "-- Notes :\n"<