X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/6e2b3026c6a496e81642c373796bd39dad33d2a6..e40a5399ec7887c2606f18575c809b0d05b09278:/AbstractBlock.cpp?ds=inline diff --git a/AbstractBlock.cpp b/AbstractBlock.cpp index 3bb808e..116494e 100644 --- a/AbstractBlock.cpp +++ b/AbstractBlock.cpp @@ -59,7 +59,7 @@ bool AbstractBlock::isSourceBlock() { } /* NB: a generator 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 + * By the way, blocks that have no data input/output * (like clkrstgen) are not generators ! */ bool AbstractBlock::isGeneratorBlock() { @@ -243,47 +243,70 @@ QList AbstractBlock::getWishboneParameters() { return lst; } +void AbstractBlock::connectClock(QString clkName, int idGen) throw(Exception) { + GroupBlock* parentBlock = AB_TO_GRP(parent); + ConnectedInterface* fromClk = NULL; + ConnectedInterface* toClk = AI_TO_CON(getIfaceFromName(clkName)); -void AbstractBlock::connectClkReset() throw(Exception) { - - GroupBlock* parentBlock = AB_TO_GRP(parent); - - cout << "connecting clk/rst for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl; - - QList lstClk = getInterfaces(AbstractInterface::Input,AbstractInterface::Clock); - QList lstRst = getInterfaces(AbstractInterface::Input,AbstractInterface::Reset); + if (parentBlock->isTop()) { + QString genName = "clkrstgen_" + QString::number(idGen); + AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName(genName); + if (clkrstgen == NULL) { + throw(Exception(IFACE_TOP_NOCLKRSTGEN,this)); + } + else { + fromClk = AI_TO_CON(clkrstgen->getIfaceFromName("clk")); + } + cout << "connecting clock for " << qPrintable(name) << " to " << qPrintable(genName) << endl; + } + else { + // searching for ext_clk_idGen + QString name = "ext_clk_"+QString::number(idGen); + fromClk = AI_TO_CON(parentBlock->getIfaceFromName(name)); + cout << "connecting clk for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl; + } - if ((lstClk.isEmpty()) || (lstRst.isEmpty())) { - throw(Exception(IFACE_GROUP_NOCLKRST,this)); + if (fromClk == NULL) { + throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock)); + } + else { + fromClk->connectTo(toClk); + cout << "connection done between " << qPrintable(toClk->getConnectedFrom()->getOwner()->getName()) << "/" << qPrintable(toClk->getConnectedFrom()->getName()); + cout << " and " << qPrintable(toClk->getOwner()->getName()) << "/" << qPrintable(toClk->getName()) << endl; } +} - ConnectedInterface* toClk = AI_TO_CON(lstClk.at(0)); - ConnectedInterface* toRst = AI_TO_CON(lstRst.at(0)); +void AbstractBlock::connectReset(QString rstName, int idGen) throw(Exception) { - ConnectedInterface* fromClk = NULL; + GroupBlock* parentBlock = AB_TO_GRP(parent); ConnectedInterface* fromRst = NULL; + ConnectedInterface* toRst = AI_TO_CON(getIfaceFromName(rstName)); if (parentBlock->isTop()) { - AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName("clkrstgen"); + QString genName = "clkrstgen_" + QString::number(idGen); + AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName(genName); 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 reset for " << qPrintable(name) << " to " << qPrintable(genName) << endl; } else { - fromClk = AI_TO_CON(parentBlock->getIfaceFromName("clk")); - fromRst = AI_TO_CON(parentBlock->getIfaceFromName("reset")); + QString name = "ext_reset_"+QString::number(idGen); + fromRst = AI_TO_CON(parentBlock->getIfaceFromName(name)); + cout << "connecting reset for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl; } - if ((fromClk == NULL) || (fromRst == NULL)) { + + if (fromRst == NULL) { throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock)); } else { - fromClk->connectTo(toClk); fromRst->connectTo(toRst); + cout << "connection done between " << qPrintable(toRst->getConnectedFrom()->getOwner()->getName()) << "/" << qPrintable(toRst->getConnectedFrom()->getName()); + cout << " and " << qPrintable(toRst->getOwner()->getName()) << "/" << qPrintable(toRst->getName()) << endl; } } @@ -308,7 +331,7 @@ void AbstractBlock::generateComponent(QTextStream& out, bool hasController) thro catch(Exception e) { throw(e); } - out << " end component " << endl << endl; + out << " end component; " << endl << endl; }