#include "GroupScene.h"\r
#include "GroupItem.h"\r
#include "BoxItem.h"\r
-#include "SourceItem.h"\r
+#include "StimuliItem.h"\r
#include "InterfaceItem.h"\r
#include "ConnectionItem.h"\r
\r
projectPath = "";\r
projectName = "";\r
projectFile = "";\r
+\r
+ graph = new Graph();\r
}\r
\r
Parameters::~Parameters() {\r
refPathes.clear();\r
}\r
\r
-Graph* Parameters::createGraph() {\r
- graph = new Graph();\r
+Graph* Parameters::initGraph(bool createTopGroupIfaces) {\r
+ graph->createTopGroup(createTopGroupIfaces);\r
return graph;\r
}\r
\r
return ref;\r
}\r
\r
+double Parameters::getFeedingClockFrequency(AbstractInterface *iface) {\r
+\r
+ int idClock = 0;\r
+\r
+ if (iface->isReferenceInterface()) return 0.0;\r
+\r
+ if (iface->getClockIfaceType() == AbstractInterface::ParameterName) {\r
+ BlockParameter* param = iface->getOwner()->getParameterFromName(iface->getClockIfaceString());\r
+ if (!param->isUserParameter()) return 0.0;\r
+ bool ok;\r
+ double freq = param->getDoubleValue(&ok);\r
+ if (!ok) {\r
+ cerr << "Abnormal case: cannot retrieve clock id from parameter " << qPrintable(param->getName()) << endl;\r
+ }\r
+ return freq;\r
+ }\r
+ else if ( (iface->getClockIfaceType() == AbstractInterface::ClockName) || ((iface->getDirection() == AbstractInterface::Input) && (iface->getPurpose() == AbstractInterface::Clock))) {\r
+\r
+ // if iface is not clock, retrieve the clock related to it\r
+ if (iface->getClockIfaceType() == AbstractInterface::ClockName) {\r
+ iface = iface->getClockIface();\r
+ }\r
+ // if iface is a group interface, then iface name is ext_clk_X, thus extract the X\r
+ if (iface->isGroupInterface()) {\r
+ QString name = iface->getName();\r
+ name.remove(0,8);\r
+ bool ok;\r
+ idClock = name.toInt(&ok);\r
+ if (!ok) {\r
+ cerr << "Abnormal case: cannot retrieve clock id from iface name " << qPrintable(iface->getName()) << endl;\r
+ return 0.0;\r
+ }\r
+ }\r
+ // if iface is a functional interface, it is connected to clkrstgen_X (in top group) or to ext_clk_X (in subgroup)\r
+ else if (iface->isFunctionalInterface()) {\r
+ FunctionalInterface* funIface = AI_TO_FUN(iface);\r
+ ConnectedInterface* connFrom = funIface->getConnectedFrom();\r
+ if (connFrom == NULL) {\r
+ cerr << "Abnormal case: input clock " << qPrintable(iface->getName()) << " is not connected" << endl;\r
+ return 0.0;\r
+ }\r
+ if (iface->getOwner()->isTopGroupBlock()) {\r
+ QString name = connFrom->getOwner()->getName();\r
+ name.remove(0,10);\r
+ bool ok;\r
+ idClock = name.toInt(&ok);\r
+ if (!ok) {\r
+ cerr << "Abnormal case: cannot retrieve clock id for " << qPrintable(iface->getName()) << endl;\r
+ return 0.0;\r
+ }\r
+ }\r
+ else {\r
+ QString name = connFrom->getName();\r
+ name.remove(0,8);\r
+ bool ok;\r
+ idClock = name.toInt(&ok);\r
+ if (!ok) {\r
+ cerr << "Abnormal case: cannot retrieve clock id for " << qPrintable(iface->getName()) << endl;\r
+ return 0.0;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return graph->getClock(idClock);\r
+}\r
+\r
void Parameters::createDelayBlock() {\r
delayRef = new ReferenceBlock("no.xml");\r
delayRef->addCategory(100);\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
\r
if (idUpperScene == -1) {\r
- topGroup = dispatcher->createTopScene();\r
+ topGroup = dispatcher->createTopScene(Dispatcher::Load);\r
topScene->setId(idScene);\r
groupItem = topScene->getGroupItem(); \r
cout << "top group added to scene n°" << idScene << endl;\r
else {\r
cout << "trying to create scene n°" << idScene << " with upper scene n°" <<idUpperScene << endl;\r
GroupScene* upperScene = searchSceneById(idUpperScene, topScene);\r
- groupWidget = dispatcher->addNewEmptyGroup(upperScene,false);\r
+ /* IMPORTANT: calling addNewEmptyGroup() leads to create a new GroupWidget\r
+ * AND a BoxItem in upperScene that represents the GroupItem in the\r
+ * newly created child scene. Thus, it has not to be created when\r
+ * reading bi_group tags in the following but just searched\r
+ */\r
+ groupWidget = dispatcher->addNewEmptyGroup(Dispatcher::Load, upperScene,false);\r
groupWidget->getScene()->setId(idScene);\r
groupItem = groupWidget->getScene()->getGroupItem(); \r
}\r
cout << qPrintable(groupItem->getRefBlock()->getName()) << " has upper box item in " << qPrintable(groupItem->getParentItem()->getScene()->getGroupItem()->getRefBlock()->getName()) << endl;\r
} \r
}\r
- dispatcher->setSceneCounter(maxIdScene+1);\r
+ dispatcher->setSceneCounter(Dispatcher::Load, maxIdScene+1);\r
cout << "groupItems loaded and windows created succefully!" << endl;\r
\r
/**********************************************************\r
cout << "top scene has " << sourceNodes.length() << " sources" << endl;\r
for(int j=0; j<sourceNodes.length(); j++) {\r
QDomElement currentSBNode = sourceNodes.at(j).toElement(); \r
- SourceItem* sourceItem = new SourceItem(dispatcher,this);\r
+ StimuliItem* sourceItem = new StimuliItem(dispatcher,this);\r
try {\r
sourceItem->load(currentSBNode);\r
}\r
}\r
cout << "source item has been read, add it to the scene" << endl;\r
// add the block to the GroupScene\r
- currentScene->addSourceItem(sourceItem);\r
+ currentScene->addStimuliItem(sourceItem);\r
} \r
}\r
/**********************************************************\r
InterfaceItem *iface2 = searchInterfaceItemById(to,topScene);\r
\r
if(iface1 != NULL && iface2 != NULL){\r
- dispatcher->createConnection(iface1,iface2);\r
+ dispatcher->createConnection(Dispatcher::Load, iface1,iface2);\r
} else {\r
cout << "interfaces not found, connect canceled!" << endl;\r
}\r
implPathes.append(path);\r
cout << "impl path : " << qPrintable(path) << endl << endl;\r
}\r
+\r
+ QDomElement eltSource = eltImpl.nextSiblingElement("sources");\r
+ nbPathesStr = eltSource.attribute("nb","none");\r
+ nbPathes = nbPathesStr.toInt(&ok);\r
+ QDomNodeList listSourceDir = eltSource.elementsByTagName("source_lib");\r
+ if ((!ok) || (nbPathes != listSourceDir.size())) throw(Exception(CONFIGFILE_CORRUPTED));\r
+\r
+ for(int i=0;i<listSourceDir.size();i++) {\r
+ QDomNode nodeSourceDir = listSourceDir.at(i);\r
+ QDomElement eltSourceDir = nodeSourceDir.toElement();\r
+ if (eltSourceDir.isNull()) throw(Exception(CONFIGFILE_CORRUPTED));\r
+ QString path = eltSourceDir.attribute("path","none");\r
+ if (path == "none") throw(Exception(CONFIGFILE_CORRUPTED));\r
+ sourcePathes.append(path);\r
+ cout << "core path : " << qPrintable(path) << endl << endl;\r
+ }\r
+\r
// getting elt = the element <defaults>\r
// for each child element, initialize the associated attributes of Parameters\r
\r
- QDomElement eltDefaults = eltImpl.nextSiblingElement("defaults");\r
+ QDomElement eltDefaults = eltSource.nextSiblingElement("defaults");\r
\r
QDomElement eltBlocks = eltDefaults.firstChildElement("blocks");\r
QString attributeStr = eltBlocks.attribute("width", "none");\r
QString refXml = implRoot.attribute("ref_name","none");\r
QString refMd5 = implRoot.attribute("ref_md5","none");\r
BlockImplementation* impl = new BlockImplementation(fileName,refXml,refMd5);\r
+\r
+ QDomNodeList archNode = implRoot.elementsByTagName("architecture");\r
+\r
+ if (archNode.isEmpty()) {\r
+ cout << "impl has no architecture" << endl;\r
+ return;\r
+ }\r
+ QDomElement archElt = archNode.at(0).toElement();\r
+ QString compList = archElt.attribute("comp_list","none");\r
+ if (compList != "none") {\r
+ QStringList compos = compList.split(",");\r
+ foreach(QString s, compos) {\r
+ impl->addResource(s);\r
+ }\r
+ }\r
+\r
try {\r
impl->loadPatterns(implRoot);\r
}\r
libFile.close();\r
\r
}\r
+\r
+\r
+void Parameters::loadSources() throw(Exception) {\r
+\r
+ for(int i=0;i<sourcePathes.size();i++) {\r
+ cout << "analyzing " << qPrintable(sourcePathes.at(i)) << endl;\r
+ QDir dir(sourcePathes.at(i));\r
+ QStringList filter;\r
+ filter << "*.vhd" << "*.ngc";\r
+ dir.setNameFilters(filter);\r
+ QStringList list = dir.entryList();\r
+ for(int j=0;j<list.size();j++) {\r
+ QString fileName = dir.absolutePath();\r
+ fileName.append("/"+list.at(j));\r
+\r
+ if (list.at(j).endsWith(".ngc")) {\r
+ QString netName = list.at(j);\r
+ netName.truncate(list.at(j).size() -4);\r
+ cout << "found netlist " << qPrintable(netName) << endl;\r
+ availableResources.append(new ExternalResource(netName,fileName,ExternalResource::Netlist));\r
+ }\r
+ else {\r
+ cout << "parsing " << qPrintable(fileName) << " ... ";\r
+ QFile srcXML(fileName);\r
+ if (!srcXML.open(QIODevice::ReadOnly)) {\r
+ throw(Exception(IMPLFILE_NOACCESS));\r
+ }\r
+ QTextStream in(&srcXML);\r
+\r
+ QString line = in.readLine();\r
+ while (!line.isNull()) {\r
+ if (line.contains("package", Qt::CaseInsensitive)) {\r
+ QRegularExpression rxPack("^package (.+) is$",QRegularExpression::CaseInsensitiveOption);\r
+ QRegularExpressionMatch matchPack = rxPack.match(line);\r
+ if (matchPack.hasMatch()) {\r
+ QString packName = matchPack.captured(1);\r
+ cout << "found package " << qPrintable(packName) << endl;\r
+ availableResources.append(new ExternalResource(packName,fileName,ExternalResource::Package));\r
+ }\r
+ }\r
+ else if (line.contains("entity", Qt::CaseInsensitive)) {\r
+ QRegularExpression rxEnt("^entity (.+) is$",QRegularExpression::CaseInsensitiveOption);\r
+ QRegularExpressionMatch matchEnt = rxEnt.match(line);\r
+ if (matchEnt.hasMatch()) {\r
+ QString entityName = matchEnt.captured(1);\r
+ cout << "found entity " << qPrintable(entityName) << endl;\r
+ availableResources.append(new ExternalResource(entityName,fileName,ExternalResource::Code));\r
+ }\r
+ }\r
+ line = in.readLine();\r
+ }\r
+ srcXML.close();\r
+ cout << "OK" << endl;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+QList<ExternalResource *> Parameters::searchResourceByName(const QString& name) {\r
+ QList<ExternalResource*> listRes;\r
+ foreach(ExternalResource* s, availableResources) {\r
+ if (s->getName() == name) {\r
+ listRes.append(s);\r
+ }\r
+ }\r
+ return listRes;\r
+}\r
+\r
void Parameters::addAvailableBlock(ReferenceBlock *block) {\r
availableBlocks.append(block);\r
foreach (int id,block->getCategories()) {\r
}\r
}\r
if (scene->isTopScene()) {\r
- foreach(SourceItem *block, scene->getSourceItems()){\r
+ foreach(StimuliItem *block, scene->getSourceItems()){\r
foreach(InterfaceItem *item, block->getInterfaces()){\r
if(item->getId() == id){\r
return item;\r