]> AND Private Git Repository - blast.git/blobdiff - FunctionalInterface.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
started clkconvert output gen
[blast.git] / FunctionalInterface.cpp
index 2fc093e324dc1ecff92335bc973250f6a1a58fe5..7d1217a88a31bec7c76f89fca1632e432ec0f16f 100644 (file)
@@ -5,7 +5,6 @@
 #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
@@ -17,8 +16,9 @@ FunctionalInterface::FunctionalInterface(AbstractBlock* _owner, ReferenceInterfa
   reference = _reference;\r
 \r
   name = reference->getName();\r
+  type = reference->getType();\r
   endianess = reference->getEndianess();\r
-  width = reference->getWidth();\r
+  width = reference->getWidthString();\r
   direction = reference->getDirection();\r
   purpose = reference->getPurpose();  \r
   connectedFrom = NULL;  \r
@@ -107,16 +107,16 @@ bool FunctionalInterface::canConnectTo(AbstractInterface *iface) {
   // first case: interface of blocks within the same group\r
   if (getOwner()->getParent() == iface->getOwner()->getParent()) {\r
 \r
-    if ((direction == Output) && (iface->getDirection() == Input)) return true;\r
-    if ((direction == InOut) && (iface->getDirection() == InOut)) return true;\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
   // 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)) return true;\r
-    if ((direction == InOut) && (iface->getDirection() == InOut)) return true;\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
   }\r
-  else if ((getOwner()->isSourceBlock()) && (iface->getOwner()->isTopGroupBlock())) {\r
-    if ((direction == Output) && (iface->getDirection() == Input)) return true;\r
+  else if ((getOwner()->isStimuliBlock()) && (iface->getOwner()->isTopGroupBlock())) {\r
+    if ((direction == Output) && (iface->getDirection() == Input) && (purpose == iface->getPurpose())) return true;\r
   }\r
 \r
   return false;\r
@@ -145,17 +145,56 @@ bool FunctionalInterface::canConnectFrom(AbstractInterface *iface) {
 \r
   if (getOwner()->getParent() == iface->getOwner()->getParent()) {\r
 \r
-    if ((direction == Input) && (iface->getDirection() == Output)) return true;\r
-    if ((direction == InOut) && (iface->getDirection() == InOut)) return true;\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
   }\r
   else if (getOwner()->getParent() == iface->getOwner()) {\r
-    if ((direction == Input) && (iface->getDirection() == Input)) return true;\r
-    if ((direction == InOut) && (iface->getDirection() == InOut)) return true;\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
   }\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 name = connFrom->getOwner()->getName();\r
+      cout << "conn from clkrstgen: searching for clkdomain in " << qPrintable(name) << endl;\r
+      name.remove(0,10);\r
+      bool ok;\r
+      idClock = name.toInt(&ok);\r
+      if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this));\r
+    }\r
+    else {\r
+      QString name = connFrom->getName();\r
+      cout << "conn from group: searching for clkdomain in " << qPrintable(name) << endl;\r
+      name.remove(0,8);\r
+      bool ok;\r
+      idClock = name.toInt(&ok);\r
+      if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this));\r
+    }\r
+  }\r
+\r
+  return idClock;\r
+}\r
+\r
 \r
 void FunctionalInterface::connectionsValidation(QStack<AbstractInterface *> *interfacetoValidate, QList<AbstractInterface *> *validatedInterfaces) throw(Exception) {\r
 \r