+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;
+ }
+}
+
+