#include "FunctionalBlock.h"\r
#include "GroupBlock.h"\r
\r
-\r
FunctionalInterface::FunctionalInterface(AbstractBlock* _owner, ReferenceInterface *_reference) throw(Exception) : ConnectedInterface(_owner) {\r
\r
if (_owner == NULL) throw(Exception(BLOCK_NULL));\r
width = reference->getWidthString();\r
direction = reference->getDirection();\r
purpose = reference->getPurpose(); \r
- connectedFrom = NULL; \r
+ connectedFrom = NULL;\r
+ clkIfaceName = reference->getClockIfaceString();\r
+ clkIfaceType = reference->getClockIfaceType();\r
}\r
\r
bool FunctionalInterface::isFunctionalInterface() {\r
return inter;\r
}\r
\r
-bool FunctionalInterface::canConnectTo(AbstractInterface *iface) {\r
+bool FunctionalInterface::canConnectTo(AbstractInterface *iface, bool testClock) {\r
+ static QString fctName = "FunctionalInterface::canConnectTo()";\r
+#ifdef DEBUG_FCTNAME\r
+ cout << "call to " << qPrintable(fctName) << endl;\r
+#endif\r
+\r
\r
/* NOTE :\r
necessary conditions :\r
- iface type must be functional or group interface\r
- iface->connectedFrom must be NULL\r
\r
- valid cases:\r
+ valid "normal" cases:\r
1 - iface is owned by a block (group or func) that is within the same group as the block that own this\r
1.1 - this is output and iface is input\r
1.2 - both are inout\r
2.2 - both are inout\r
3 - this is owned by a source block and iface is owned by the top group\r
\r
+ + if testClock is true, must test if both ifaces are in the same clock domain. Note that a group interface\r
+ has always\r
+ special case : clk/reset from clkrstgen can connect to stimuli clk/reset\r
+\r
*/\r
+ bool ok = false;\r
+\r
if (direction == Input) return false;\r
if (iface->isReferenceInterface()) return false;\r
ConnectedInterface* connIface = AI_TO_CON(iface);\r
if (connIface->getConnectedFrom() != NULL) return false;\r
+\r
+ // special case, NB: never tests clocks\r
+ if ((getOwner()->getName().startsWith("clkrstgen")) && (iface->getOwner()->isStimuliBlock())) {\r
+ if ((direction == Output) && (iface->getDirection() == Input)) {\r
+ if ((purpose == AbstractInterface::Clock) && (iface->getPurpose() == AbstractInterface::Clock)) return true;\r
+ else if ((purpose == AbstractInterface::Reset) && (iface->getPurpose() == AbstractInterface::Reset)) return true;\r
+ }\r
+ }\r
+\r
// first case: interface of blocks within the same group\r
if (getOwner()->getParent() == iface->getOwner()->getParent()) {\r
\r
- if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true;\r
- if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;\r
+\r
+\r
+ if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) ok = true;\r
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) ok = true;\r
}\r
// second case: iface = interface of the group that contains owner of this\r
else if (getOwner()->getParent() == iface->getOwner()) {\r
- if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true;\r
- if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;\r
+ if ((direction == Output) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) ok = true;\r
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) ok = true;\r
}\r
else if ((getOwner()->isStimuliBlock()) && (iface->getOwner()->isTopGroupBlock())) {\r
- if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true;\r
+ if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) ok = true;\r
}\r
\r
+ if (ok) {\r
+ if (testClock) {\r
+ int dom1 = -1,dom2 = -2;\r
+ try {\r
+ dom1 = getClockDomain();\r
+ dom2 = iface->getClockDomain();\r
+ }\r
+ catch(Exception e) {\r
+ cerr << qPrintable(fctName) << " - " << qPrintable(e.getMessage()) << endl;\r
+ return false;\r
+ }\r
+ if (dom1 != dom2) {\r
+ cout << "cannot connect interface that are in different clock domains" << endl;\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ }\r
return false;\r
\r
}\r
\r
-bool FunctionalInterface::canConnectFrom(AbstractInterface *iface) {\r
+bool FunctionalInterface::canConnectFrom(AbstractInterface *iface, bool testClock) {\r
+\r
+ static QString fctName = "FunctionalInterface::canConnectFrom()";\r
+#ifdef DEBUG_FCTNAME\r
+ cout << "call to " << qPrintable(fctName) << endl;\r
+#endif\r
\r
/* NOTE :\r
necessary conditions :\r
2 - iface is owned by the parent group of the block that owns this\r
2.1 - this is an input, iface is an input of the group\r
2.2 - both are inout\r
+\r
+ special case : clk/reset of stimuli can connect from clk/reset of clkrstgen\r
*/\r
+ bool ok = false;\r
+\r
if (direction == Output) return false;\r
if (iface->isReferenceInterface()) return false;\r
if (connectedFrom != NULL) return false;\r
\r
- if (getOwner()->getParent() == iface->getOwner()->getParent()) {\r
+ // special case, NB: never tests clock\r
+ if ((iface->getOwner()->getName().startsWith("clkrstgen")) && (getOwner()->isStimuliBlock())) {\r
+ if ((direction == Input) && (iface->getDirection() == Output)) {\r
+ if ((purpose == AbstractInterface::Clock) && (iface->getPurpose() == AbstractInterface::Clock)) return true;\r
+ else if ((purpose == AbstractInterface::Reset) && (iface->getPurpose() == AbstractInterface::Reset)) return true;\r
+ }\r
+ }\r
\r
- if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true;\r
- if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;\r
+ if (getOwner()->getParent() == iface->getOwner()->getParent()) { \r
+ if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) ok = true;\r
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) ok = true;\r
}\r
else if (getOwner()->getParent() == iface->getOwner()) {\r
- if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true;\r
- if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) return true;\r
+ if ((direction == Input) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) ok = true;\r
+ if ((direction == InOut) && (iface->getDirection() == InOut) && (purpose == iface->getPurpose())) ok = true;\r
+ }\r
+\r
+ if (ok) {\r
+ if (testClock) {\r
+ int dom1 = -1,dom2 = -2;\r
+ try {\r
+ dom1 = getClockDomain();\r
+ dom2 = iface->getClockDomain();\r
+ }\r
+ catch(Exception e) {\r
+ cerr << qPrintable(e.getMessage()) << endl;\r
+ return false;\r
+ }\r
+ if (dom1 != dom2) {\r
+ cout << "cannot connect interfaces that are in different clock domains" << endl;\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
}\r
\r
return false;\r
}\r
\r
+int FunctionalInterface::getClockDomain() throw(Exception) {\r
+\r
+ int idClock = -1;\r
+\r
+ FunctionalInterface* iface = NULL;\r
+ if (clkIfaceType == ClockName) {\r
+ iface = AI_TO_FUN(getClockIface());\r
+ }\r
+ else if ((direction == Input) && (purpose == Clock)) {\r
+ iface = this;\r
+ }\r
+\r
+ if ( iface != NULL) {\r
+\r
+ // if iface is a functional interface, it is connected to clkrstgen_X (in top group) or to ext_clk_X (in subgroup)\r
+ ConnectedInterface* connFrom = iface->getConnectedFrom();\r
+ if (connFrom == NULL) throw(Exception(IFACE_INVALID_CLKFREQ,this));\r
+\r
+ if (connFrom->getOwner()->isFunctionalBlock()) {\r
+ QString domName = connFrom->getOwner()->getName();\r
+ domName.remove(0,10);\r
+ cout << "conn from clkrstgen: searching for clkdomain in " << qPrintable(domName) << endl;\r
+\r
+ bool ok = true;\r
+ idClock = domName.toInt(&ok);\r
+ cout << "id clock = " << idClock << endl;\r
+ if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this));\r
+ }\r
+ else if (connFrom->getOwner()->isGroupBlock()) {\r
+ QString domName = connFrom->getName();\r
+ domName.remove(0,8);\r
+ cout << "conn from group: searching for clkdomain in " << qPrintable(domName) << endl;\r
+\r
+ bool ok = true;\r
+ idClock = domName.toInt(&ok);\r
+ if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this));\r
+ }\r
+ else {\r
+ cout << "abnormal case while searching for clkdomain" << endl;\r
+ }\r
+ }\r
+\r
+ return idClock;\r
+}\r
+\r
\r
void FunctionalInterface::connectionsValidation(QStack<AbstractInterface *> *interfacetoValidate, QList<AbstractInterface *> *validatedInterfaces) throw(Exception) {\r
\r