X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/48f48e6a26a54751ecd0ab90b10ab972cc5e89cd..4327c2b8817b627249d98d889835726217c81a4e:/FunctionalInterface.cpp?ds=sidebyside diff --git a/FunctionalInterface.cpp b/FunctionalInterface.cpp index 145b86a..55f65ec 100644 --- a/FunctionalInterface.cpp +++ b/FunctionalInterface.cpp @@ -5,7 +5,6 @@ #include "FunctionalBlock.h" #include "GroupBlock.h" - FunctionalInterface::FunctionalInterface(AbstractBlock* _owner, ReferenceInterface *_reference) throw(Exception) : ConnectedInterface(_owner) { if (_owner == NULL) throw(Exception(BLOCK_NULL)); @@ -17,7 +16,9 @@ FunctionalInterface::FunctionalInterface(AbstractBlock* _owner, ReferenceInterfa reference = _reference; name = reference->getName(); - width = reference->getWidth(); + type = reference->getType(); + endianess = reference->getEndianess(); + width = reference->getWidthString(); direction = reference->getDirection(); purpose = reference->getPurpose(); connectedFrom = NULL; @@ -89,7 +90,7 @@ bool FunctionalInterface::canConnectTo(AbstractInterface *iface) { - iface type must be functional or group interface - iface->connectedFrom must be NULL - valid cases: + valid "normal" cases: 1 - iface is owned by a block (group or func) that is within the same group as the block that own this 1.1 - this is output and iface is input 1.2 - both are inout @@ -98,24 +99,34 @@ 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 + special case : clk/reset from clkrstgen can connect to stimuli clk/reset + */ if (direction == Input) return false; if (iface->isReferenceInterface()) return false; ConnectedInterface* connIface = AI_TO_CON(iface); if (connIface->getConnectedFrom() != NULL) return false; + // special case + if ((getOwner()->getName().startsWith("clkrstgen")) && (iface->getOwner()->isStimuliBlock())) { + if ((direction == Output) && (iface->getDirection() == Input)) { + if ((purpose == AbstractInterface::Clock) && (iface->getPurpose() == AbstractInterface::Clock)) return true; + else if ((purpose == AbstractInterface::Reset) && (iface->getPurpose() == AbstractInterface::Reset)) return true; + } + } + // first case: interface of blocks within the same group if (getOwner()->getParent() == iface->getOwner()->getParent()) { - if ((direction == Output) && (iface->getDirection() == Input)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return 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)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } - else if ((getOwner()->isSourceBlock()) && (iface->getOwner()->isTopGroupBlock())) { - if ((direction == Output) && (iface->getDirection() == Input)) return true; + else if ((getOwner()->isStimuliBlock()) && (iface->getOwner()->isTopGroupBlock())) { + if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; } return false; @@ -137,24 +148,73 @@ bool FunctionalInterface::canConnectFrom(AbstractInterface *iface) { 2 - iface is owned by the parent group of the block that owns this 2.1 - this is an input, iface is an input of the group 2.2 - both are inout + + special case : clk/reset of stimuli can connect from clk/reset of clkrstgen */ if (direction == Output) return false; if (iface->isReferenceInterface()) return false; if (connectedFrom != NULL) return false; + // special case + if ((iface->getOwner()->getName().startsWith("clkrstgen")) && (getOwner()->isStimuliBlock())) { + if ((direction == Input) && (iface->getDirection() == Output)) { + if ((purpose == AbstractInterface::Clock) && (iface->getPurpose() == AbstractInterface::Clock)) return true; + else if ((purpose == AbstractInterface::Reset) && (iface->getPurpose() == AbstractInterface::Reset)) return true; + } + } + if (getOwner()->getParent() == iface->getOwner()->getParent()) { - if ((direction == Input) && (iface->getDirection() == Output)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } else if (getOwner()->getParent() == iface->getOwner()) { - if ((direction == Input) && (iface->getDirection() == Input)) return true; - if ((direction == InOut) && (iface->getDirection() == InOut)) return true; + if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true; + if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true; } return false; } +int FunctionalInterface::getClockDomain() throw(Exception) { + + int idClock = -1; + + FunctionalInterface* iface = NULL; + if (clkIfaceType == ClockName) { + iface = AI_TO_FUN(getClockIface()); + } + else if ((direction == Input) && (purpose == Clock)) { + iface = this; + } + + if ( iface != NULL) { + + // if iface is a functional interface, it is connected to clkrstgen_X (in top group) or to ext_clk_X (in subgroup) + ConnectedInterface* connFrom = iface->getConnectedFrom(); + 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); + 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); + if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this)); + } + } + + return idClock; +} + void FunctionalInterface::connectionsValidation(QStack *interfacetoValidate, QList *validatedInterfaces) throw(Exception) {