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

Private GIT Repository
started top group gen, added project subdirs
[blast.git] / Dispatcher.cpp
index a552f208fa0a1c96064c7ae9aeeac91e893aad93..c3ff33fd91b713078ff111e3ec9e2389b630477c 100644 (file)
@@ -69,6 +69,9 @@ GroupWidget *Dispatcher::loadProject(const QString& filename) {
     return NULL;
   }
 
     return NULL;
   }
 
+  QFileInfo info(filename);
+  params->projectPath = info.absolutePath();
+  cout << "project path = " << qPrintable(params->projectPath) << endl;
   groupList.append(topGroup);
   return topGroup;
 }
   groupList.append(topGroup);
   return topGroup;
 }
@@ -85,7 +88,7 @@ void Dispatcher::closeCurrentProject() {
   sceneCounter = 0;
 }
 
   sceneCounter = 0;
 }
 
-bool Dispatcher::createConnection(InterfaceItem *iface1, InterfaceItem *iface2) {
+bool Dispatcher::createConnection(InterfaceItem *iface1, InterfaceItem *iface2, bool visible) {
     
   ConnectedInterface* ref1 = iface1->refInter;
   ConnectedInterface* ref2 = iface2->refInter;  
     
   ConnectedInterface* ref1 = iface1->refInter;
   ConnectedInterface* ref2 = iface2->refInter;  
@@ -106,7 +109,7 @@ bool Dispatcher::createConnection(InterfaceItem *iface1, InterfaceItem *iface2)
   }
   if ((ok1 == true) || (ok2 == true)) {
 
   }
   if ((ok1 == true) || (ok2 == true)) {
 
-    iface1->getOwner()->getScene()->createConnectionItem(iface1,iface2);
+    iface1->getOwner()->getScene()->createConnectionItem(iface1,iface2, visible);
 
     unselectAllItems();
     params->unsaveModif = true;
 
     unselectAllItems();
     params->unsaveModif = true;
@@ -179,10 +182,8 @@ void Dispatcher::generateBlockVHDL(BoxItem *item){
 
   if (item->getRefBlock()->isFunctionalBlock()) {
     FunctionalBlock* block = AB_TO_FUN(item->getRefBlock());
 
   if (item->getRefBlock()->isFunctionalBlock()) {
     FunctionalBlock* block = AB_TO_FUN(item->getRefBlock());
-    ReferenceBlock* ref = block->getReference();
-    BlockImplementation* impl = ref->getImplementations().at(0);
     try {
     try {
-      impl->generateVHDL(block,"/home/sdomas/");
+      block->generateVHDL(params->projectPath);      
     }
     catch(Exception e) {
       cout << qPrintable(e.getMessage()) << endl;
     }
     catch(Exception e) {
       cout << qPrintable(e.getMessage()) << endl;
@@ -371,10 +372,18 @@ void Dispatcher::showPatterns(InterfaceItem *item) {
     msg += " owned by ";
     msg += item->refInter->getOwner()->getName();
     msg += " is:\n";
     msg += " owned by ";
     msg += item->refInter->getOwner()->getName();
     msg += " is:\n";
-    ConnectedInterface* iface = AI_TO_CON(item->refInter->getAssociatedIface());
-    ConnectedInterface* fromIface = iface->getConnectedFrom();
-    if (fromIface->getOutputPattern() == NULL) return;
-    foreach(char c, *(fromIface->getOutputPattern())) {
+    // get the precursor output pattern
+    ConnectedInterface* connIface = AI_TO_CON(item->refInter->getAssociatedIface());
+    QList<char>* out = connIface->getConnectedFrom()->getOutputPattern();
+    // get the modifier
+    AbstractInputModifier* modifier = connIface->getInputModifier();
+    // check if the input is modified
+    if (modifier != NULL) {
+
+      out = modifier->getModifiedInput(out);
+    }
+
+    foreach(char c, *out) {
       msg += QString::number((int)c);
     }
     msg += "\n";
       msg += QString::number((int)c);
     }
     msg += "\n";
@@ -401,7 +410,8 @@ void Dispatcher::showModifier(InterfaceItem *item) {
   cout << "call to " << qPrintable(fctName) << endl;
 #endif
   QString msg = "";
   cout << "call to " << qPrintable(fctName) << endl;
 #endif
   QString msg = "";
-  AbstractInputModifier* mod = item->refInter->getInputModifier();
+  ConnectedInterface* assoIface = AI_TO_CON(item->refInter->getAssociatedIface());
+  AbstractInputModifier* mod = assoIface->getInputModifier();
   if (mod->isDelay()) {
     DelayInputModifier* delay = (DelayInputModifier *)mod;
     msg = "Pattern of iface ";
   if (mod->isDelay()) {
     DelayInputModifier* delay = (DelayInputModifier *)mod;
     msg = "Pattern of iface ";
@@ -421,7 +431,8 @@ void Dispatcher::removeModifier(InterfaceItem *item) {
   cout << "call to " << qPrintable(fctName) << endl;
 #endif
 
   cout << "call to " << qPrintable(fctName) << endl;
 #endif
 
-  item->refInter->clearInputModifier();
+  ConnectedInterface* assoIface = AI_TO_CON(item->refInter->getAssociatedIface());
+  assoIface->clearInputModifier();
 }
 
 
 }
 
 
@@ -546,7 +557,16 @@ GroupWidget *Dispatcher::createTopScene(){
 
   // creating the model part of the group
   Graph* graph = params->createGraph();
 
   // creating the model part of the group
   Graph* graph = params->createGraph();
-  GroupBlock *refBlock = graph->getTopGroup();
+  GroupBlock *topBlock = graph->getTopGroup();
+  // creating the clkrstgen block
+  ReferenceBlock* ref = params->getHiddenReferenceBlock("clkrstgen");
+  FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(topBlock, ref);  
+  ConnectedInterface* fromIface = AI_TO_CON(topBlock->getIfaceFromName("ext_clk"));
+  ConnectedInterface* toIface = AI_TO_CON(newOne->getIfaceFromName("ext_clk"));
+  fromIface->connectTo(toIface);
+  fromIface = AI_TO_CON(topBlock->getIfaceFromName("ext_reset"));
+  toIface = AI_TO_CON(newOne->getIfaceFromName("ext_reset"));
+  fromIface->connectTo(toIface);
 
   // creating a fake and not connected interface
   //AbstractInterface* iface = new GroupInterface(refBlock,"grp_iface",AbstractInterface::Input,AbstractInterface::Top);
 
   // creating a fake and not connected interface
   //AbstractInterface* iface = new GroupInterface(refBlock,"grp_iface",AbstractInterface::Input,AbstractInterface::Top);
@@ -560,7 +580,7 @@ GroupWidget *Dispatcher::createTopScene(){
   params->setTopScene(scene);
   params->setCurrentScene(scene);
   // creating the view part of the group
   params->setTopScene(scene);
   params->setCurrentScene(scene);
   // creating the view part of the group
-  GroupItem *group = new GroupItem(NULL,refBlock,this,params);
+  GroupItem *group = new GroupItem(NULL,topBlock,this,params);
 
 
   // adding the fake interface to the top group item
 
 
   // adding the fake interface to the top group item
@@ -1073,10 +1093,12 @@ void Dispatcher::connectInterToGroup(InterfaceItem *item){
   // creating/adding the group interface in the graph model
   GroupInterface *groupInter = new GroupInterface(parentBlock,refInter->getName()+"_group",refInter->getDirection(),refInter->getPurpose());  
   parentItem->getRefBlock()->addInterface(groupInter);
   // creating/adding the group interface in the graph model
   GroupInterface *groupInter = new GroupInterface(parentBlock,refInter->getName()+"_group",refInter->getDirection(),refInter->getPurpose());  
   parentItem->getRefBlock()->addInterface(groupInter);
-  // creating/adding the group control interface in the graph model
-  GroupInterface *groupCtlInter = new GroupInterface(parentBlock,refInter->getName()+"_group_enb",refInter->getDirection(),AbstractInterface::Control);
-  groupCtlInter->setAssociatedIface(groupInter);
-  parentItem->getRefBlock()->addInterface(groupCtlInter);  
+  // creating/adding the group control interface in the graph model if the purpose is data
+  if (refInter->getPurpose() == AbstractInterface::Data) {
+    GroupInterface *groupCtlInter = new GroupInterface(parentBlock,refInter->getName()+"_group_enb",refInter->getDirection(),AbstractInterface::Control);
+    groupCtlInter->setAssociatedIface(groupInter);
+    parentItem->getRefBlock()->addInterface(groupCtlInter);
+  }
   // creating/adding the group interface in the current scene model, and connection item
   InterfaceItem *groupIfaceItem = new InterfaceItem(0,item->getOrientation(),groupInter,parentItem,params);
   parentItem->addInterfaceItem(groupIfaceItem,true);
   // creating/adding the group interface in the current scene model, and connection item
   InterfaceItem *groupIfaceItem = new InterfaceItem(0,item->getOrientation(),groupInter,parentItem,params);
   parentItem->addInterfaceItem(groupIfaceItem,true);
@@ -1216,8 +1238,9 @@ void Dispatcher::findGraphModifications(FunctionalBlock *block) {
     QList<int>* delay = iterD.value();
     if (delay->at(0) > 0) {
       // create delay and associate it to the connected input
     QList<int>* delay = iterD.value();
     if (delay->at(0) > 0) {
       // create delay and associate it to the connected input
-      AbstractInputModifier* mod = new DelayInputModifier(delay->at(0));
-      ConnectedInterface* toIface = AI_TO_CON(iterD.key()->getAssociatedIface());
+
+      ConnectedInterface* toIface = AI_TO_CON(iterD.key());
+      AbstractInputModifier* mod = new DelayInputModifier(toIface, delay->at(0));
       cout << "modify input of " << qPrintable(toIface->getName()) << endl;
       toIface->setInputModifier(mod);
       // repaint
       cout << "modify input of " << qPrintable(toIface->getName()) << endl;
       toIface->setInputModifier(mod);
       // repaint