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

Private GIT Repository
added clk/rst link when creating a block
[blast.git] / AbstractBlock.cpp
index 3c3dd55567143665fb453afe507fac18330e9e97..116494e1922f1ac830500aed518db2efc1a468f5 100644 (file)
@@ -243,51 +243,70 @@ QList<BlockParameter *> AbstractBlock::getWishboneParameters() {
   return lst;\r
 }\r
 \r
+void AbstractBlock::connectClock(QString clkName, int idGen) throw(Exception) {\r
 \r
+  GroupBlock* parentBlock = AB_TO_GRP(parent);  \r
+  ConnectedInterface* fromClk = NULL;\r
+  ConnectedInterface* toClk = AI_TO_CON(getIfaceFromName(clkName));\r
 \r
-void AbstractBlock::connectClkReset() throw(Exception) {\r
-\r
-  GroupBlock* parentBlock = AB_TO_GRP(parent);\r
-\r
-\r
-\r
-  QList<AbstractInterface* > lstClk = getInterfaces(AbstractInterface::Input,AbstractInterface::Clock);\r
-  QList<AbstractInterface* > lstRst = getInterfaces(AbstractInterface::Input,AbstractInterface::Reset);\r
+  if (parentBlock->isTop()) {\r
+    QString genName = "clkrstgen_" + QString::number(idGen);\r
+    AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName(genName);\r
+    if (clkrstgen == NULL) {\r
+      throw(Exception(IFACE_TOP_NOCLKRSTGEN,this));\r
+    }\r
+    else {\r
+      fromClk = AI_TO_CON(clkrstgen->getIfaceFromName("clk"));      \r
+    }\r
+    cout << "connecting clock for " << qPrintable(name) << " to " << qPrintable(genName) << endl;\r
+  }\r
+  else {\r
+    // searching for ext_clk_idGen\r
+    QString name = "ext_clk_"+QString::number(idGen);\r
+    fromClk = AI_TO_CON(parentBlock->getIfaceFromName(name));\r
+    cout << "connecting clk for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl;\r
+  }\r
 \r
-  if ((lstClk.isEmpty()) || (lstRst.isEmpty())) {\r
-    throw(Exception(IFACE_GROUP_NOCLKRST,this));\r
+  if (fromClk == NULL) {\r
+    throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock));\r
+  }\r
+  else {\r
+    fromClk->connectTo(toClk);\r
+    cout << "connection done between " << qPrintable(toClk->getConnectedFrom()->getOwner()->getName()) << "/" << qPrintable(toClk->getConnectedFrom()->getName());\r
+    cout << " and " << qPrintable(toClk->getOwner()->getName()) << "/" << qPrintable(toClk->getName()) << endl;\r
   }\r
+}\r
 \r
-  ConnectedInterface* toClk = AI_TO_CON(lstClk.at(0));\r
-  ConnectedInterface* toRst = AI_TO_CON(lstRst.at(0));\r
+void AbstractBlock::connectReset(QString rstName, int idGen) throw(Exception) {\r
 \r
-  ConnectedInterface* fromClk = NULL;\r
+  GroupBlock* parentBlock = AB_TO_GRP(parent);\r
   ConnectedInterface* fromRst = NULL;\r
+  ConnectedInterface* toRst = AI_TO_CON(getIfaceFromName(rstName));\r
 \r
   if (parentBlock->isTop()) {\r
-    AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName("clkrstgen");\r
+    QString genName = "clkrstgen_" + QString::number(idGen);\r
+    AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName(genName);\r
     if (clkrstgen == NULL) {\r
       throw(Exception(IFACE_TOP_NOCLKRSTGEN,this));\r
     }\r
     else {\r
-      fromClk = AI_TO_CON(clkrstgen->getIfaceFromName("clk"));\r
       fromRst = AI_TO_CON(clkrstgen->getIfaceFromName("reset"));\r
     }\r
-    cout << "connecting clk/rst for " << qPrintable(name) << " to clkrstgen" << endl;\r
+    cout << "connecting reset for " << qPrintable(name) << " to " << qPrintable(genName) << endl;\r
   }\r
   else {\r
-    fromClk = AI_TO_CON(parentBlock->getIfaceFromName("clk"));\r
-    fromRst = AI_TO_CON(parentBlock->getIfaceFromName("reset"));\r
-    cout << "connecting clk/rst for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl;\r
+    QString name = "ext_reset_"+QString::number(idGen);\r
+    fromRst = AI_TO_CON(parentBlock->getIfaceFromName(name));\r
+    cout << "connecting reset for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl;\r
   }\r
-  if ((fromClk == NULL) || (fromRst == NULL)) {\r
+\r
+  if (fromRst == NULL) {\r
     throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock));\r
   }\r
   else {\r
-    fromClk->connectTo(toClk);\r
     fromRst->connectTo(toRst);\r
-    cout << "connection done between " << qPrintable(toClk->getConnectedFrom()->getOwner()->getName()) << "/" << qPrintable(toClk->getConnectedFrom()->getName());\r
-    cout << " and " << qPrintable(toClk->getOwner()->getName()) << "/" << qPrintable(toClk->getName()) << endl;\r
+    cout << "connection done between " << qPrintable(toRst->getConnectedFrom()->getOwner()->getName()) << "/" << qPrintable(toRst->getConnectedFrom()->getName());\r
+    cout << " and " << qPrintable(toRst->getOwner()->getName()) << "/" << qPrintable(toRst->getName()) << endl;\r
   }\r
 }\r
 \r