X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/e40a5399ec7887c2606f18575c809b0d05b09278..3fb762e7042d9b4a1cf78556ad9ed7f117cc53ba:/SpecialBlock.cpp?ds=sidebyside diff --git a/SpecialBlock.cpp b/SpecialBlock.cpp index 8edff6f..fdec328 100644 --- a/SpecialBlock.cpp +++ b/SpecialBlock.cpp @@ -1,20 +1,30 @@ #include "SpecialBlock.h" +#include "FunctionalInterface.h" -SpecialBlock::SpecialBlock(SpecialType _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces) throw(Exception) : FunctionalBlock(_parent, _reference, createIfaces) { - type = _type; +SpecialBlock::SpecialBlock(int _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces) throw(Exception) : FunctionalBlock(_parent, _reference, createIfaces) { + specialType = _type; } SpecialBlock::~SpecialBlock() { } +bool SpecialBlock::isSpecialBlock() { + return true; +} + void SpecialBlock::checkInputPatternCompatibility() throw(Exception) { try { - switch(type) { - case ClockConvert : + switch(specialType) { + case Source : + checkInputPatternCompatibilitySource(); + break; + case Sink : + checkInputPatternCompatibilitySink(); + break; + case ClkConvert : checkInputPatternCompatibilityClockConvert(); break; - case ClkRstGen: - checkInputPatternCompatibilityClkRstGen(); + default: break; } } @@ -25,12 +35,17 @@ void SpecialBlock::checkInputPatternCompatibility() throw(Exception) { void SpecialBlock::computeOutputPattern(int nbExec) throw(Exception) { try { - switch(type) { - case ClockConvert : - computeOutputPatternClockConvert(nbExec); + switch(specialType) { + case Source : + computeOutputPatternSource(nbExec); + break; + case Sink : + computeOutputPatternSink(nbExec); break; - case ClkRstGen: - computeOutputPatternClkRstGen(nbExec); + case ClkConvert : + computeOutputPatternClockConvert(nbExec); + break; + default: break; } } @@ -39,13 +54,86 @@ void SpecialBlock::computeOutputPattern(int nbExec) throw(Exception) { } } -void SpecialBlock::checkInputPatternCompatibilityClockConvert() throw(Exception) { +void SpecialBlock::checkInputPatternCompatibilitySource() throw(Exception) { } -void SpecialBlock::computeOutputPatternClockConvert(int nbExec) throw(Exception) { +void SpecialBlock::computeOutputPatternSource(int nbExec) throw(Exception) { + + 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); + } + setOutputPatternComputed(true); } +void SpecialBlock::checkInputPatternCompatibilitySink() throw(Exception) { +} +void SpecialBlock::computeOutputPatternSink(int nbExec) throw(Exception) { +} -void SpecialBlock::checkInputPatternCompatibilityClkRstGen() throw(Exception) { +void SpecialBlock::checkInputPatternCompatibilityClockConvert() throw(Exception) { + static QString fctName = "SpecialBlock::checkInputPatternCompatibilityClockConvert()"; +#ifdef DEBUG_FCTNAME + cout << "call to " << qPrintable(fctName) << endl; +#endif + // just create input pattern + try { + createInputPattern(); + } + catch(Exception e) { + throw(e); + } } -void SpecialBlock::computeOutputPatternClkRstGen(int nbExec) throw(Exception) { + +void SpecialBlock::computeOutputPatternClockConvert(int nbExec) throw(Exception) { + static QString fctName = "SpecialBlock::computeOutputPatternClockConvert()"; +#ifdef DEBUG_FCTNAME + cout << "call to " << qPrintable(fctName) << endl; +#endif + cout << "computing output pattern of " << qPrintable(name) << endl; + + /* CAUTION: it is assumed that all clock domain converters are using + * a clk_in and clk_out signals for input and output clocks. + */ + AbstractInterface* clkIn = getIfaceFromName("clk_in"); + AbstractInterface* clkOut = getIfaceFromName("clk_out"); + //cout << "freq clk_in = " << clkIn- + + // 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; + } + + // 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; + } + +