X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/1b7818e18ed7bcf3464e307b97c6e0e6d72cc69b..e40a5399ec7887c2606f18575c809b0d05b09278:/Dispatcher.cpp?ds=inline diff --git a/Dispatcher.cpp b/Dispatcher.cpp index da4bae2..94cdfb6 100644 --- a/Dispatcher.cpp +++ b/Dispatcher.cpp @@ -29,7 +29,9 @@ #include "DelayInputModifier.h" -#include "InterfacePropertiesWindow.h" +#include "InterfacePropertiesDialog.h" + +#include int Dispatcher::sceneCounter = 0; @@ -111,7 +113,7 @@ bool Dispatcher::createConnection(Context context, InterfaceItem *iface1, Interf ref1->connectTo(ref2); ok1 = true; } - // if the frist one did not work, test ref2->ref1 + // if the first one did not work, test ref2->ref1 if ((ok1 == false) && (ref2->canConnectTo(ref1)) && (ref1->canConnectFrom(ref2))) { ref2->connectTo(ref1); ok2 = true; @@ -621,7 +623,7 @@ void Dispatcher::duplicateInterfaceItem(Context context, InterfaceItem *item) { } -BoxItem* Dispatcher::addBlock(Context context, int idCategory, int idBlock, int idScene) { +BoxItem* Dispatcher::addBlock(Context context, int idCategory, int idBlock, int idScene, QHash clkRstToGen) { static QString fctName = "Dispatcher::addBlock()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; @@ -645,9 +647,26 @@ BoxItem* Dispatcher::addBlock(Context context, int idCategory, int idBlock, int scene->createSourceItem(newOne); } else { + GroupBlock* group = AB_TO_GRP(scene->getGroupItem()->getRefBlock()); FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(group, ref, true); + + // creating the box item item = scene->createBoxItem(newOne); + if (params->autoConnMainClk) { + // for now just use the first one + QHashIterator iter(clkRstToGen); + while (iter.hasNext()) { + iter.next(); + AbstractInterface* iface = newOne->getIfaceFromName(iter.key()); + if (iface->getPurpose() == AbstractInterface::Clock) { + newOne->connectClock(iface->getName(), iter.value()); + } + else if (iface->getPurpose() == AbstractInterface::Reset) { + newOne->connectReset(iface->getName(), iter.value()); + } + } + } params->blockToItem.insert(newOne,item); } params->unsaveModif = true; @@ -656,6 +675,67 @@ BoxItem* Dispatcher::addBlock(Context context, int idCategory, int idBlock, int return item; } +void Dispatcher::addClkRstGenBlock(Context context, double frequency) { + static QString fctName = "Dispatcher::addClkRstGenBlock()"; +#ifdef DEBUG_FCTNAME + cout << "call to " << qPrintable(fctName) << endl; +#endif + + + if (context == Design) { + + params->clocks.append(frequency); + + // get the top group + GroupBlock *group = params->getGraph()->getTopGroup(); + GroupScene *scene = topGroupWidget->getScene(); + + // creating the clkrstgen block + ReferenceBlock* ref = params->getHiddenReferenceBlock("clkrstgen"); + FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(group, ref, true); + + QString name = "clkrstgen_"; + name += QString::number(params->clocks.size()-1); + newOne->setName(name); + + // creating the box item + BoxItem* item = scene->createBoxItem(newOne, BoxItem::Left, AbstractBoxItem::Dimension); + item->setVisible(false); + + ConnectedInterface* fromIfaceClk = NULL; + ConnectedInterface* fromIfaceReset = NULL; + QString clkName = "ext_clk_"+QString::number(params->clocks.size()-1); + QString rstName = "ext_reset_"+QString::number(params->clocks.size()-1); + fromIfaceClk = new GroupInterface(group,clkName, AbstractInterface::Input, AbstractInterface::Clock); + fromIfaceReset = new GroupInterface(group,rstName, AbstractInterface::Input, AbstractInterface::Reset); + group->addInterface(fromIfaceClk); + group->addInterface(fromIfaceReset); + // creating top group ext_clk iface item + GroupItem* groupItem = scene->getGroupItem(); + InterfaceItem* fromIfaceItemClk = new InterfaceItem(0.5 , Parameters::West, fromIfaceClk, groupItem, params, true); + groupItem->addInterfaceItem(fromIfaceItemClk,true); + // creating top group ext_reset iface item + InterfaceItem* fromIfaceItemReset = new InterfaceItem(0.5 , Parameters::West, fromIfaceReset, groupItem, params, false); + groupItem->addInterfaceItem(fromIfaceItemReset,true); + // connecting ext_clk iface items + InterfaceItem* toIfaceItemClk = item->searchInterfaceItemByName("ext_clk"); + if (toIfaceItemClk == NULL) { + cerr << "Abnormal case while connecting top group ext_clk to clkrstgen" << endl; + } + createConnection(context,fromIfaceItemClk, toIfaceItemClk, false); + // connecting ext_reset iface items + InterfaceItem* toIfaceItemReset = item->searchInterfaceItemByName("ext_reset"); + if (toIfaceItemReset == NULL) { + cerr << "Abnormal case while connecting top group ext_reset to clkrstgen" << endl; + } + createConnection(context,fromIfaceItemReset, toIfaceItemReset, false); + + params->blockToItem.insert(newOne,item); + params->unsaveModif = true; + } +} + + GroupWidget *Dispatcher::createTopScene(Context context){ static QString fctName = "Dispatcher::createTopScene()"; @@ -690,21 +770,12 @@ GroupWidget *Dispatcher::createTopScene(Context context){ if (context == Design) { - // creating the clkrstgen block - ReferenceBlock* ref = params->getHiddenReferenceBlock("clkrstgen"); - FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(topBlock, ref, true); - 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); - // create the clkrstgen boxitem - BoxItem* item = scene->createBoxItem(newOne, GroupScene::Left, GroupScene::Top, AbstractBoxItem::Position, BoxItem::HSpan); - params->blockToItem.insert(newOne,item); + // create clkrstgen + double freq = params->clocks.at(0); + params->clocks.clear(); + addClkRstGenBlock(context,freq); } - groupList.append(topGroupWidget); return topGroupWidget; } @@ -714,11 +785,15 @@ GroupWidget* Dispatcher::addNewEmptyGroup(Context context, GroupScene* scene, bo #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; #endif + bool createIfaces = true; + if (context == Load) { + createIfaces = false; + } // getting the parent block in the graph GroupBlock* parent = AB_TO_GRP(scene->getGroupItem()->getRefBlock()); cout << "new group : parent = "<< qPrintable(parent->getName()) << endl; - GroupBlock* groupBlock = params->getGraph()->createChildGroupBlock(parent); + GroupBlock* groupBlock = params->getGraph()->createChildGroupBlock(parent, createIfaces); cout << "new group : child = "<< qPrintable(groupBlock->getName()) << ", child of " << qPrintable(groupBlock->getParent()->getName()) << endl; // creating the BlockItem in the scene BoxItem* newItem = scene->createBoxItem(groupBlock); @@ -1190,7 +1265,8 @@ void Dispatcher::showBlocksLibrary(){ } void Dispatcher::showProperties(Context context, InterfaceItem *inter) { - new InterfacePropertiesWindow(inter); + QDialog* dial = new InterfacePropertiesDialog(inter); + dial->exec(); } /* connectInterToGroup() :