X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/8f0bedf735fe2b306c11c3f4a168245a05e37ccd..HEAD:/AbstractBlock.cpp diff --git a/AbstractBlock.cpp b/AbstractBlock.cpp index 7bdec1b..de28272 100644 --- a/AbstractBlock.cpp +++ b/AbstractBlock.cpp @@ -8,9 +8,11 @@ #include "ConnectedInterface.h" -AbstractBlock::AbstractBlock() { +AbstractBlock::AbstractBlock(Graph *_graph) { name = ""; parent = NULL; + specialType = NotSpecial; + graph = _graph; } /* @@ -34,6 +36,15 @@ void AbstractBlock::setName(const QString& str) { name = Parameters::normalizeName(str); } +void AbstractBlock::setSpecialType(int type) { + if ((type >= NotSpecial) && (type <= ClkConvert)) { + specialType = type; + } + else { + specialType = NotSpecial; + } +} + void AbstractBlock::setParent(AbstractBlock* _parent) { parent = _parent; } @@ -46,6 +57,10 @@ bool AbstractBlock::isFunctionalBlock() { return false; } +bool AbstractBlock::isSpecialBlock() { + return false; +} + bool AbstractBlock::isGroupBlock() { return false; } @@ -54,20 +69,42 @@ bool AbstractBlock::isTopGroupBlock() { return false; } -bool AbstractBlock::isSourceBlock() { +bool AbstractBlock::isStimuliBlock() { return false; } -/* NB: a generator is a block that has no data inputs +/* NB: a source is a block that has no data inputs * and has at least one data output. - * By the way, blokcs that have no data input/output - * (like clkrstgen) are not generators ! + * By the way, blocks that have no data input/output + * (like clkrstgen) are not sources ! + * A source may also be a block of special type source. */ -bool AbstractBlock::isGeneratorBlock() { +bool AbstractBlock::isSourceBlock() { + if (specialType == Source) return true; if (getDataInputs().size() > 0) return false; if (getDataOutputs().size() == 0) return false; return true; } +/* NB: a sink is a block without outputs of any type */ +bool AbstractBlock::isSinkBlock() { + if (getOutputs().size() == 0) return true; + return false; +} + +int AbstractBlock::getSpecialTypeFromString(QString str) { + if (str == "source") { + return Source; + } + else if (str == "sink") { + return Sink; + } + else if (str == "clkconvert") { + return ClkConvert; + } + return NotSpecial; +} + + void AbstractBlock::addParameter(BlockParameter *param) { params.append(param); } @@ -243,54 +280,6 @@ QList AbstractBlock::getWishboneParameters() { return lst; } - - -void AbstractBlock::connectClkReset() throw(Exception) { - - GroupBlock* parentBlock = AB_TO_GRP(parent); - - - - QList lstClk = getInterfaces(AbstractInterface::Input,AbstractInterface::Clock); - QList lstRst = getInterfaces(AbstractInterface::Input,AbstractInterface::Reset); - - if ((lstClk.isEmpty()) || (lstRst.isEmpty())) { - throw(Exception(IFACE_GROUP_NOCLKRST,this)); - } - - ConnectedInterface* toClk = AI_TO_CON(lstClk.at(0)); - ConnectedInterface* toRst = AI_TO_CON(lstRst.at(0)); - - ConnectedInterface* fromClk = NULL; - ConnectedInterface* fromRst = NULL; - - if (parentBlock->isTop()) { - AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName("clkrstgen"); - if (clkrstgen == NULL) { - throw(Exception(IFACE_TOP_NOCLKRSTGEN,this)); - } - else { - fromClk = AI_TO_CON(clkrstgen->getIfaceFromName("clk")); - fromRst = AI_TO_CON(clkrstgen->getIfaceFromName("reset")); - } - cout << "connecting clk/rst for " << qPrintable(name) << " to clkrstgen" << endl; - } - else { - fromClk = AI_TO_CON(parentBlock->getIfaceFromName("clk")); - fromRst = AI_TO_CON(parentBlock->getIfaceFromName("reset")); - cout << "connecting clk/rst for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl; - } - if ((fromClk == NULL) || (fromRst == NULL)) { - throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock)); - } - else { - fromClk->connectTo(toClk); - fromRst->connectTo(toRst); - cout << "connection done between " << qPrintable(toClk->getConnectedFrom()->getOwner()->getName()) << "/" << qPrintable(toClk->getConnectedFrom()->getName()); - cout << " and " << qPrintable(toClk->getOwner()->getName()) << "/" << qPrintable(toClk->getName()) << endl; - } -} - void AbstractBlock::generateEntity(QTextStream& out, bool hasController) throw(Exception) { out << "entity " << name << " is" << endl; @@ -312,7 +301,7 @@ void AbstractBlock::generateComponent(QTextStream& out, bool hasController) thro catch(Exception e) { throw(e); } - out << " end component " << endl << endl; + out << " end component; " << endl << endl; }