X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/4327c2b8817b627249d98d889835726217c81a4e..HEAD:/FunctionalInterface.cpp diff --git a/FunctionalInterface.cpp b/FunctionalInterface.cpp index 55f65ec..3a225c7 100644 --- a/FunctionalInterface.cpp +++ b/FunctionalInterface.cpp @@ -21,7 +21,9 @@ FunctionalInterface::FunctionalInterface(AbstractBlock* _owner, ReferenceInterfa width = reference->getWidthString(); direction = reference->getDirection(); purpose = reference->getPurpose(); - connectedFrom = NULL; + connectedFrom = NULL; + clkIfaceName = reference->getClockIfaceString(); + clkIfaceType = reference->getClockIfaceType(); } bool FunctionalInterface::isFunctionalInterface() { @@ -82,7 +84,12 @@ AbstractInterface *FunctionalInterface::clone() { return inter; } -bool FunctionalInterface::canConnectTo(AbstractInterface *iface) { +bool FunctionalInterface::canConnectTo(AbstractInterface *iface, bool testClock) { + static QString fctName = "FunctionalInterface::canConnectTo()"; +#ifdef DEBUG_FCTNAME + cout << "call to " << qPrintable(fctName) << endl; +#endif + /* NOTE : necessary conditions : @@ -99,14 +106,19 @@ bool FunctionalInterface::canConnectTo(AbstractInterface *iface) { 2.2 - both are inout 3 - this is owned by a source block and iface is owned by the top group + + if testClock is true, must test if both ifaces are in the same clock domain. Note that a group interface + has always special case : clk/reset from clkrstgen can connect to stimuli clk/reset */ + bool ok = false; + if (direction == Input) return false; if (iface->isReferenceInterface()) return false; ConnectedInterface* connIface = AI_TO_CON(iface); if (connIface->getConnectedFrom() != NULL) return false; - // special case + + // special case, NB: never tests clocks if ((getOwner()->getName().startsWith("clkrstgen")) && (iface->getOwner()->isStimuliBlock())) { if ((direction == Output) && (iface->getDirection() == Input)) { if ((purpose == AbstractInterface::Clock) && (iface->getPurpose() == AbstractInterface::Clock)) return true; @@ -117,23 +129,48 @@ bool FunctionalInterface::canConnectTo(AbstractInterface *iface) { // first case: interface of blocks within the same group if (getOwner()->getParent() == iface->getOwner()->getParent()) { - if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; - if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; + + + if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) ok = true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) ok = true; } // second case: iface = interface of the group that contains owner of this else if (getOwner()->getParent() == iface->getOwner()) { - if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; - if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; + if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) ok = true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) ok = true; } else if ((getOwner()->isStimuliBlock()) && (iface->getOwner()->isTopGroupBlock())) { - if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; + if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) ok = true; } + if (ok) { + if (testClock) { + int dom1 = -1,dom2 = -2; + try { + dom1 = getClockDomain(); + dom2 = iface->getClockDomain(); + } + catch(Exception e) { + cerr << qPrintable(fctName) << " - " << qPrintable(e.getMessage()) << endl; + return false; + } + if (dom1 != dom2) { + cout << "cannot connect interface that are in different clock domains" << endl; + return false; + } + } + return true; + } return false; } -bool FunctionalInterface::canConnectFrom(AbstractInterface *iface) { +bool FunctionalInterface::canConnectFrom(AbstractInterface *iface, bool testClock) { + + static QString fctName = "FunctionalInterface::canConnectFrom()"; +#ifdef DEBUG_FCTNAME + cout << "call to " << qPrintable(fctName) << endl; +#endif /* NOTE : necessary conditions : @@ -151,11 +188,13 @@ bool FunctionalInterface::canConnectFrom(AbstractInterface *iface) { special case : clk/reset of stimuli can connect from clk/reset of clkrstgen */ + bool ok = false; + if (direction == Output) return false; if (iface->isReferenceInterface()) return false; if (connectedFrom != NULL) return false; - // special case + // special case, NB: never tests clock if ((iface->getOwner()->getName().startsWith("clkrstgen")) && (getOwner()->isStimuliBlock())) { if ((direction == Input) && (iface->getDirection() == Output)) { if ((purpose == AbstractInterface::Clock) && (iface->getPurpose() == AbstractInterface::Clock)) return true; @@ -163,14 +202,32 @@ bool FunctionalInterface::canConnectFrom(AbstractInterface *iface) { } } - if (getOwner()->getParent() == iface->getOwner()->getParent()) { - - if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; - if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; + if (getOwner()->getParent() == iface->getOwner()->getParent()) { + if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) ok = true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) ok = true; } else if (getOwner()->getParent() == iface->getOwner()) { - if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; - if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; + if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) ok = true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) ok = true; + } + + if (ok) { + if (testClock) { + int dom1 = -1,dom2 = -2; + try { + dom1 = getClockDomain(); + dom2 = iface->getClockDomain(); + } + catch(Exception e) { + cerr << qPrintable(e.getMessage()) << endl; + return false; + } + if (dom1 != dom2) { + cout << "cannot connect interfaces that are in different clock domains" << endl; + return false; + } + } + return true; } return false; @@ -195,21 +252,27 @@ int FunctionalInterface::getClockDomain() throw(Exception) { if (connFrom == NULL) throw(Exception(IFACE_INVALID_CLKFREQ,this)); if (connFrom->getOwner()->isFunctionalBlock()) { - QString name = connFrom->getOwner()->getName(); - cout << "conn from clkrstgen: searching for clkdomain in " << qPrintable(name) << endl; - name.remove(0,10); - bool ok; - idClock = name.toInt(&ok); + QString domName = connFrom->getOwner()->getName(); + domName.remove(0,10); + cout << "conn from clkrstgen: searching for clkdomain in " << qPrintable(domName) << endl; + + bool ok = true; + idClock = domName.toInt(&ok); + cout << "id clock = " << idClock << endl; if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this)); } - else { - QString name = connFrom->getName(); - cout << "conn from group: searching for clkdomain in " << qPrintable(name) << endl; - name.remove(0,8); - bool ok; - idClock = name.toInt(&ok); + else if (connFrom->getOwner()->isGroupBlock()) { + QString domName = connFrom->getName(); + domName.remove(0,8); + cout << "conn from group: searching for clkdomain in " << qPrintable(domName) << endl; + + bool ok = true; + idClock = domName.toInt(&ok); if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this)); } + else { + cout << "abnormal case while searching for clkdomain" << endl; + } } return idClock;