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

Private GIT Repository
moved vhdl gen. into block
[blast.git] / AbstractBlock.cpp
index 66c8f37a13c208a0646f7043fd120590351af2b5..336b677a10aeb7f3b75ab64967af1e283181d85c 100644 (file)
@@ -3,16 +3,22 @@
 #include <QMessageBox>\r
 #include "AbstractInterface.h"\r
 #include "BlockParameter.h"\r
+#include "Parameters.h"\r
+#include "GroupBlock.h"\r
+#include "ConnectedInterface.h"\r
+\r
 \r
 AbstractBlock::AbstractBlock() {\r
   name = "";\r
   parent = NULL;\r
 }\r
 \r
+/*\r
 AbstractBlock::AbstractBlock(const QString& _name) {\r
-  name = _name;\r
+  name = Parameters::normalizeName(_name);\r
   parent = NULL;\r
 }\r
+*/\r
 \r
 AbstractBlock::~AbstractBlock() {\r
 \r
@@ -25,7 +31,7 @@ AbstractBlock::~AbstractBlock() {
 }\r
 \r
 void AbstractBlock::setName(const QString& str) {\r
-  name = str;\r
+  name = Parameters::normalizeName(str);\r
 }\r
 \r
 void AbstractBlock::setParent(AbstractBlock* _parent) {\r
@@ -234,3 +240,52 @@ QList<BlockParameter *> AbstractBlock::getWishboneParameters() {
   }\r
   return lst;\r
 }\r
+\r
+\r
+\r
+void AbstractBlock::connectClkReset() throw(Exception) {\r
+\r
+  GroupBlock* parentBlock = AB_TO_GRP(parent);\r
+\r
+  cout << "connecting clk/rst for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl;\r
+\r
+  QList<AbstractInterface* > lstClk = getInterfaces(AbstractInterface::Input,AbstractInterface::Clock);\r
+  QList<AbstractInterface* > lstRst = getInterfaces(AbstractInterface::Input,AbstractInterface::Reset);\r
+\r
+  if ((lstClk.isEmpty()) || (lstRst.isEmpty())) {\r
+    throw(Exception(IFACE_GROUP_NOCLKRST,this));\r
+  }\r
+\r
+  ConnectedInterface* toClk = AI_TO_CON(lstClk.at(0));\r
+  ConnectedInterface* toRst = AI_TO_CON(lstRst.at(0));\r
+\r
+  ConnectedInterface* fromClk = NULL;\r
+  ConnectedInterface* fromRst = NULL;\r
+\r
+  if (parentBlock->isTop()) {\r
+    AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName("clkrstgen");\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
+  }\r
+  else {\r
+    fromClk = AI_TO_CON(parentBlock->getIfaceFromName("clk"));\r
+    fromRst = AI_TO_CON(parentBlock->getIfaceFromName("reset"));\r
+  }\r
+  if ((fromClk == NULL) || (fromRst == NULL)) {\r
+    throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock));\r
+  }\r
+  else {\r
+    fromClk->connectTo(toClk);\r
+    fromRst->connectTo(toRst);\r
+  }\r
+\r
+\r
+}\r
+\r
+\r
+\r