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

Private GIT Repository
finished conn mode of library
authorstephane Domas <stephane.domas@univ-fcomte.fr>
Wed, 2 May 2018 14:34:45 +0000 (16:34 +0200)
committerstephane Domas <stephane.domas@univ-fcomte.fr>
Wed, 2 May 2018 14:34:45 +0000 (16:34 +0200)
BlockLibraryWidget.cpp
BlockLibraryWidget.h
MainWindow.cpp
blast.creator.user

index 62603b43cbda45514a8b04ce5280977abc9b8ea3..5dfd4b0f6fe71bd974f3197a71cfda05c477e7a7 100644 (file)
@@ -13,6 +13,7 @@ BlockLibraryWidget::BlockLibraryWidget(Dispatcher* _dispatcher,
   comboClkGen = NULL;
   nbRst = 0;
   comboRstGen = NULL;
+  currentRefBlock = NULL;
 
   // creating the widget : tree, buttons, ...
   QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
@@ -26,19 +27,44 @@ BlockLibraryWidget::BlockLibraryWidget(Dispatcher* _dispatcher,
   layAdd->addWidget(buttonAdd);
   layAdd->addWidget(comboScenes);
 
+  boxClkRst = new QGroupBox("Clock/reset connection");
+
+
+  QString msg = "Connect to main clock/rst ext_clk/reset_0 (";
+  msg += QString::number(params->clocks.at(0));
+  msg += ")";
+  radAutoClk = new QRadioButton(msg);
+  radChooseClk = new QRadioButton("Choose among available clk/rst");
+  if (params->autoConnMainClk) {
+    radAutoClk->setChecked(true);
+  }
+  else {
+    radChooseClk->setChecked(true);
+  }
+
   layClkRst = new QGridLayout;
 
-  boxClkRst = new QGroupBox("Clock/reset connection");
-  boxClkRst->setLayout(layClkRst);
+  QVBoxLayout* layConn = new QVBoxLayout;
+  layConn->addWidget(radAutoClk,0,0);
+  layConn->addWidget(radChooseClk,1,0);
+  stack = new QStackedWidget();
+  QLabel* labDummy = new QLabel("");
+  stack->addWidget(labDummy);
+  QWidget* w = new QWidget();
+  w->setLayout(layClkRst);
+  stack->addWidget(w);
+  layConn->addWidget(stack);
+
+  boxClkRst->setLayout(layConn);
 
   QVBoxLayout* layBottom = new QVBoxLayout;
   layBottom->addLayout(layAdd);
   layBottom->addWidget(boxClkRst);
 
-
   connect(tree, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(clicked()));
   connect(tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(doubleClicked()));
   connect(buttonAdd, SIGNAL(clicked()), this, SLOT(addClicked()));  
+  connect(radChooseClk, SIGNAL(toggled(bool)), this, SLOT(enableAvailableClocks(bool)));
 
   BlockCategory* cat = params->categoryTree->searchCategory(0);
 
@@ -127,24 +153,55 @@ void BlockLibraryWidget::addClicked() {
 }
 
 void BlockLibraryWidget::clicked() {
-  if(tree->selectedItems().length() > 0){
+  if(tree->selectedItems().length() > 0) {
+
     QTreeWidgetItem *item = tree->selectedItems().at(0);
+
     if(item->data(1,Qt::DisplayRole).isValid()) {
+
+
       buttonAdd->setEnabled(true);
-      int idParent = item->data(1,Qt::DisplayRole).toInt();
+      int idCat = item->data(1,Qt::DisplayRole).toInt();
       int idBlock = item->data(2,Qt::DisplayRole).toInt();
-      updateClkRst(idParent, idBlock);
+      currentRefBlock = params->getReferenceBlock(idCat,idBlock);
+      QList<AbstractInterface*> lstClocks = currentRefBlock->getInterfaces(AbstractInterface::Input, AbstractInterface::Clock);
+      //if there are more than one input clock, force to choose
+      if ((lstClocks.size()>1) || (! params->autoConnMainClk)) {
+        radChooseClk->setChecked(true);
+        //enableAvailableClocks(true);
+      }
+      else {
+        radAutoClk->setChecked(true);
+      }
+      updateClkRst(idCat, idBlock);
     }
     else {
       buttonAdd->setEnabled(false);
+      updateClkRst(-1,-1);
     }
   }
 }
 
 void BlockLibraryWidget::doubleClicked() {
+  clicked();
   addClicked();
 }
 
+void BlockLibraryWidget::updateBoxConn() {
+  if (params->autoConnMainClk) {
+    radAutoClk->setChecked(true);
+    //enableAvailableClocks(false);
+  }
+  else {
+    radChooseClk->setChecked(true);
+    //enableAvailableClocks(true);
+  }
+  QString msg = "Auto-connect to main clk/rst (ext_clk_0 at ";
+  msg += QString::number(params->clocks.at(0));
+  msg += " MHz)";
+  radAutoClk->setText(msg);
+}
+
 void BlockLibraryWidget::updateComboScene() {
   comboScenes->clear();
   QMap<int,QString> list = dispatcher->getAllGroupNames();
@@ -164,22 +221,19 @@ void BlockLibraryWidget::updateClkRst(int idCat, int idBlock) {
   }
 
   if (nbClock != 0) {
-    for(int i=0;i<nbClock;i++) {
-      comboClkGen[i]->deleteLater();
-    }
     delete [] comboClkGen;
+    nbClock = 0;
   }
   if (nbRst != 0) {
-    for(int i=0;i<nbRst;i++) {
-      comboRstGen[i]->deleteLater();
-    }
     delete [] comboRstGen;
+    nbRst = 0;
   }
 
-  ReferenceBlock* ref = params->getReferenceBlock(idCat,idBlock);
-  QList<AbstractInterface*> lstClocks = ref->getInterfaces(AbstractInterface::Input, AbstractInterface::Clock);
+  if ((idCat == -1) || (idBlock == -1)) return;
+
+  QList<AbstractInterface*> lstClocks = currentRefBlock->getInterfaces(AbstractInterface::Input, AbstractInterface::Clock);
   nbClock = lstClocks.size();
-  QList<AbstractInterface*> lstRst = ref->getInterfaces(AbstractInterface::Input, AbstractInterface::Reset);
+  QList<AbstractInterface*> lstRst = currentRefBlock->getInterfaces(AbstractInterface::Input, AbstractInterface::Reset);
   nbRst = lstRst.size();
 
   comboClkGen = new QComboBox*[lstClocks.size()];
@@ -212,10 +266,21 @@ void BlockLibraryWidget::updateClkRst(int idCat, int idBlock) {
     layClkRst->addWidget(comboClkGen[row-1],row, 1);
     row++;
   }
+
   foreach(AbstractInterface* iface, lstRst) {
     layClkRst->addWidget(new QLabel(iface->getName()), row,0);
     layClkRst->addWidget(comboRstGen[row-1-nbClock],row, 1);
     row++;
   }
+}
+
+void BlockLibraryWidget::enableAvailableClocks(bool state) {
 
+  if (state == false) {
+    stack->setCurrentIndex(0);
+  }
+  else {
+    stack->setCurrentIndex(1);
+  }
 }
+
index bf17316ccbdcc1e5a4dc8ad461b46833480acc58..5ab7e4d2ba13409386d084f7682449fef1f17874 100644 (file)
@@ -24,6 +24,7 @@ public:
   ~BlockLibraryWidget();
 
 public slots:
+  void updateBoxConn();
   void updateComboScene();
   void updateClkRst(int idCat, int idBlock);
 
@@ -31,6 +32,7 @@ private slots:
   void addClicked();
   void clicked();
   void doubleClicked();
+  void enableAvailableClocks(bool state);
 
 
 private:
@@ -40,6 +42,10 @@ private:
   QPushButton* buttonAdd;
   QComboBox* comboScenes;
 
+  QGroupBox* boxConnMode;
+  QRadioButton* radAutoClk;
+  QRadioButton* radChooseClk;
+
   QGroupBox* boxClkRst;
   QGridLayout* layClkRst;
   QComboBox** comboClkGen;
@@ -47,6 +53,9 @@ private:
   QComboBox** comboRstGen;
   int nbRst;
 
+  ReferenceBlock* currentRefBlock;
+
+  QStackedWidget* stack;
   // other attributes
   
   void addChild(BlockCategory *catParent, QTreeWidgetItem* itemParent);
index c7ff634194becd6261e230c5d2c859a47adc18eb..8169dd0f255506d24544acf602b1faf9021aaa91 100644 (file)
@@ -319,7 +319,8 @@ void MainWindow::slotLoadProject(){
     GroupWidget* topGroup = dispatcher->loadProject(params->projectFile);
     if (topGroup != NULL) {
       addTopGroup(topGroup);
-      library->updateComboScene();      
+      library->updateComboScene();
+      library->updateBoxConn();
       params->isCurrentProject = true;
       enableProjectActions(true, PROJECT_CLOSE | PROJECT_SAVE | PROJECT_SAVEAS | PROJECT_LIB, OP_RAZ);
       enableAnalysisActions(true, ANALYSIS_ANALYZE | ANALYSIS_GENERATE, OP_RAZ);
@@ -346,7 +347,8 @@ void MainWindow::slotNewProject(){
     enableAnalysisActions(true, ANALYSIS_ANALYZE | ANALYSIS_GENERATE, OP_RAZ);
     GroupWidget* topGroup = dispatcher->createTopScene(Dispatcher::Design);
     addTopGroup(topGroup);
-    library->updateComboScene();    
+    library->updateComboScene();
+    library->updateBoxConn();
     library->show();
     params->isCurrentProject = true;
   }
index 53965192aac5abe863c968de9037acd2d54870d5..abc9d49e6fb387c7a007997cdedfb5d17a86a8f8 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.2.0, 2018-04-30T11:05:13. -->
+<!-- Written by QtCreator 4.2.0, 2018-05-02T16:34:14. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>