X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/1b7818e18ed7bcf3464e307b97c6e0e6d72cc69b..3fb762e7042d9b4a1cf78556ad9ed7f117cc53ba:/Parameters.cpp?ds=sidebyside diff --git a/Parameters.cpp b/Parameters.cpp index 60d7971..d7621d2 100644 --- a/Parameters.cpp +++ b/Parameters.cpp @@ -9,7 +9,7 @@ #include "GroupScene.h" #include "GroupItem.h" #include "BoxItem.h" -#include "SourceItem.h" +#include "StimuliItem.h" #include "InterfaceItem.h" #include "ConnectionItem.h" @@ -52,6 +52,8 @@ Parameters::Parameters() { projectPath = ""; projectName = ""; projectFile = ""; + + graph = new Graph(); } Parameters::~Parameters() { @@ -69,8 +71,8 @@ void Parameters::clear() { refPathes.clear(); } -Graph* Parameters::createGraph(bool createTopGroupIfaces) { - graph = new Graph(createTopGroupIfaces); +Graph* Parameters::initGraph(bool createTopGroupIfaces) { + graph->createTopGroup(createTopGroupIfaces); return graph; } @@ -95,6 +97,72 @@ ReferenceBlock* Parameters::getHiddenReferenceBlock(QString blockName) { return ref; } +double Parameters::getFeedingClockFrequency(AbstractInterface *iface) { + + int idClock = 0; + + if (iface->isReferenceInterface()) return 0.0; + + if (iface->getClockIfaceType() == AbstractInterface::ParameterName) { + BlockParameter* param = iface->getOwner()->getParameterFromName(iface->getClockIfaceString()); + if (!param->isUserParameter()) return 0.0; + bool ok; + double freq = param->getDoubleValue(&ok); + if (!ok) { + cerr << "Abnormal case: cannot retrieve clock id from parameter " << qPrintable(param->getName()) << endl; + } + return freq; + } + else if ( (iface->getClockIfaceType() == AbstractInterface::ClockName) || ((iface->getDirection() == AbstractInterface::Input) && (iface->getPurpose() == AbstractInterface::Clock))) { + + // if iface is not clock, retrieve the clock related to it + if (iface->getClockIfaceType() == AbstractInterface::ClockName) { + iface = iface->getClockIface(); + } + // if iface is a group interface, then iface name is ext_clk_X, thus extract the X + if (iface->isGroupInterface()) { + QString name = iface->getName(); + name.remove(0,8); + bool ok; + idClock = name.toInt(&ok); + if (!ok) { + cerr << "Abnormal case: cannot retrieve clock id from iface name " << qPrintable(iface->getName()) << endl; + return 0.0; + } + } + // if iface is a functional interface, it is connected to clkrstgen_X (in top group) or to ext_clk_X (in subgroup) + else if (iface->isFunctionalInterface()) { + FunctionalInterface* funIface = AI_TO_FUN(iface); + ConnectedInterface* connFrom = funIface->getConnectedFrom(); + if (connFrom == NULL) { + cerr << "Abnormal case: input clock " << qPrintable(iface->getName()) << " is not connected" << endl; + return 0.0; + } + if (iface->getOwner()->isTopGroupBlock()) { + QString name = connFrom->getOwner()->getName(); + name.remove(0,10); + bool ok; + idClock = name.toInt(&ok); + if (!ok) { + cerr << "Abnormal case: cannot retrieve clock id for " << qPrintable(iface->getName()) << endl; + return 0.0; + } + } + else { + QString name = connFrom->getName(); + name.remove(0,8); + bool ok; + idClock = name.toInt(&ok); + if (!ok) { + cerr << "Abnormal case: cannot retrieve clock id for " << qPrintable(iface->getName()) << endl; + return 0.0; + } + } + } + } + return graph->getClock(idClock); +} + void Parameters::createDelayBlock() { delayRef = new ReferenceBlock("no.xml"); delayRef->addCategory(100); @@ -280,6 +348,11 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { else { cout << "trying to create scene n°" << idScene << " with upper scene n°" <addNewEmptyGroup(Dispatcher::Load, upperScene,false); groupWidget->getScene()->setId(idScene); groupItem = groupWidget->getScene()->getGroupItem(); @@ -325,7 +398,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { cout << "top scene has " << sourceNodes.length() << " sources" << endl; for(int j=0; jload(currentSBNode); } @@ -334,7 +407,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { } cout << "source item has been read, add it to the scene" << endl; // add the block to the GroupScene - currentScene->addSourceItem(sourceItem); + currentScene->addStimuliItem(sourceItem); } } /********************************************************** @@ -1303,7 +1376,7 @@ InterfaceItem* Parameters::searchInterfaceItemById(int id, GroupScene* scene) { } } if (scene->isTopScene()) { - foreach(SourceItem *block, scene->getSourceItems()){ + foreach(StimuliItem *block, scene->getSourceItems()){ foreach(InterfaceItem *item, block->getInterfaces()){ if(item->getId() == id){ return item;