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

Private GIT Repository
added clk/rst link when creating a block
[blast.git] / GroupItem.cpp
index c165d029c214f3301c090fb0125ac1aa667d69de..385b352e3e86d4373257005db1800a8d63871f96 100644 (file)
@@ -683,6 +683,7 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
   QAction* removeAction = NULL;
   QAction* renameAction = NULL;
   QAction* showParameters = NULL;
   QAction* removeAction = NULL;
   QAction* renameAction = NULL;
   QAction* showParameters = NULL;
+  QAction* addExtClkAction = NULL;
 
   InterfaceItem* ifaceItem = getInterfaceItemFromCursor(event->pos().x(), event->pos().y());
 
 
   InterfaceItem* ifaceItem = getInterfaceItemFromCursor(event->pos().x(), event->pos().y());
 
@@ -713,6 +714,10 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
       showParameters = menu.addAction("Show parameters");
     }
     renameAction = menu.addAction("Rename");
       showParameters = menu.addAction("Show parameters");
     }
     renameAction = menu.addAction("Rename");
+    if (refBlock->isTopGroupBlock()) {
+      addExtClkAction = menu.addAction("Add new external clock/reset");
+    }
+
   }
   QAction* selectedAction = menu.exec(event->screenPos());
 
   }
   QAction* selectedAction = menu.exec(event->screenPos());
 
@@ -732,7 +737,13 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
   }
   else if(selectedAction == showParameters) {
     new ParametersWindow(refBlock, params, NULL);
   }
   else if(selectedAction == showParameters) {
     new ParametersWindow(refBlock, params, NULL);
-  }   
+  }
+  else if (selectedAction == addExtClkAction) {
+    bool ok = false;
+    double freq = QInputDialog::getDouble(NULL,"Adding a clkrstgen","External clock frequency (in MHz)",100,0,100000,1,&ok);
+    if (!ok) return;
+    dispatcher->addClkRstGenBlock(Dispatcher::Design, freq);
+  }
 }
 
 InterfaceItem* GroupItem::isHoverInterface(QPointF point) {
 }
 
 InterfaceItem* GroupItem::isHoverInterface(QPointF point) {
@@ -802,15 +813,16 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) {
     if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
     
     GroupInterface *groupIface = new GroupInterface(groupBlock,name,direction,purpose);
     if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
     
     GroupInterface *groupIface = new GroupInterface(groupBlock,name,direction,purpose);
-    GroupInterface *groupCtlIface = new GroupInterface(groupBlock,name+"_enb",direction,AbstractInterface::Control);
-    groupCtlIface->setAssociatedIface(groupIface);
-    
+    groupBlock->addInterface(groupIface);
     InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupIface,this,params);
     interfaceItem->setId(id);
     InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupIface,this,params);
     interfaceItem->setId(id);
-
-    groupBlock->addInterface(groupIface);
-    groupBlock->addInterface(groupCtlIface);
     addInterfaceItem(interfaceItem, false);
     addInterfaceItem(interfaceItem, false);
+
+    if (purpose == AbstractInterface::Data) {
+      GroupInterface *groupCtlIface = new GroupInterface(groupBlock,name+"_enb",direction,AbstractInterface::Control);
+      groupCtlIface->setAssociatedIface(groupIface);
+      groupBlock->addInterface(groupCtlIface);
+    }
     cout << "interface add to " << groupBlock->getName().toStdString() << endl;
   }
 
     cout << "interface add to " << groupBlock->getName().toStdString() << endl;
   }