- QString line, portName, portType, portId, genName, genType, genValue;\r
- QStringList *portNameList, *portTypeList, *portIdList, *genNameList, *genTypeList, *genValueList;\r
- cpt = 0;\r
- twDataPort->setColumnCount(3);\r
- twDataPort->setRowCount(cpt);\r
- twGenerics->setColumnCount(3);\r
- twGenerics->setRowCount(cpt);\r
- portNameList = new QStringList;\r
- portTypeList = new QStringList;\r
- portIdList = new QStringList;\r
- genNameList = new QStringList;\r
- genTypeList = new QStringList;\r
- genValueList = new QStringList;\r
-\r
- fileName = QFileDialog::getOpenFileName(this,\r
- tr("Open File"), "C:", tr("Files (*.txt *.vhd)"));\r
- QFile file(fileName);\r
-\r
- if(!file.open(QIODevice::ReadOnly | QIODevice::Text))\r
- return;\r
- QTextStream ts(&file);\r
- \r
- readLibraries(ts);\r
- \r
- /*\r
- while (!ts.atEnd())\r
- {\r
- line = ts.readLine();\r
- if(rxComment->indexIn(line) != -1) {\r
- line = rxComment->cap(1);\r
+ QString fileName = QFileDialog::getOpenFileName(this,\r
+ tr("Open File"), QDir::homePath() , tr("Files (*.txt *.vhd)"));\r
+ QFile file(fileName);\r
+\r
+ if(!file.open(QIODevice::ReadOnly | QIODevice::Text))\r
+ return;\r
+ QTextStream ts(&file);\r
+\r
+ block = new ReferenceBlock(fileName);\r
+\r
+ QString entityLine = "";\r
+ try {\r
+ entityLine = readLibraries(ts);\r
+ }\r
+ catch(Exception e) {\r
+ cerr << "VHDL seems to be malformed" << endl;\r
+ return;\r
+ }\r
+\r
+ QRegularExpression rxEnt("^entity (.+) is$",QRegularExpression::CaseInsensitiveOption);\r
+ QRegularExpressionMatch matchEnt = rxEnt.match(entityLine);\r
+ if (!matchEnt.hasMatch()) {\r
+ cerr << "VHDL seems to be malformed" << endl;\r
+ return;\r
+ }\r
+ entityName = matchEnt.captured(1);\r
+ cout << "found entity " << qPrintable(entityName) << endl;\r
+\r
+ QString archLine = "";\r
+ try {\r
+ archLine = readEntity(ts);\r
+ }\r
+ catch(Exception e) {\r
+ cerr << "VHDL seems to be malformed" << endl;\r
+ return;\r
+ }\r
+\r
+ QRegularExpression rxArch("^architecture (.+) of (.+) is$",QRegularExpression::CaseInsensitiveOption);\r
+ QRegularExpressionMatch matchArch = rxArch.match(archLine);\r
+ if (!matchArch.hasMatch()) {\r
+ cerr << "VHDL seems to be malformed" << endl;\r
+ return;\r
+ }\r
+ archName = matchArch.captured(1);\r
+ cout << "found arch " << qPrintable(archName) << " for entity " << qPrintable(matchArch.captured(2)) << endl;\r
+\r
+ try {\r
+ readArchitecture(ts);\r
+ }\r
+ catch(Exception e) {\r
+ cerr << "VHDL seems to be malformed" << endl;\r
+ return;\r
+ }\r
+ file.close();\r
+\r
+\r
+ QList<BlockParameter*> lstGenerics = block->getGenericParameters();\r
+ twGenerics->setRowCount(lstGenerics.size());\r
+ int i = 0;\r
+ foreach(BlockParameter* param, lstGenerics) {\r
+ twGenerics->setItem(i, 0, new QTableWidgetItem(param->getName()));\r
+ twGenerics->setItem(i, 1, new QTableWidgetItem(param->getTypeString()));\r
+ twGenerics->setItem(i, 2, new QTableWidgetItem(param->getValue().toString()));\r
+ i++;\r
+ }\r
+\r
+ lstIface = block->getInputs();\r
+ lstIface.append(block->getOutputs());\r
+ lstIface.append(block->getBidirs());\r
+\r
+ twPorts->setRowCount(lstIface.size());\r
+ purposeDelegate = new IfacePurposeDelegate();\r
+ twPorts->setItemDelegateForColumn(3,purposeDelegate);\r
+\r
+ i=0;\r
+ foreach(AbstractInterface* iface, lstIface) {\r
+ twPorts->setItem(i, 0, new QTableWidgetItem(iface->getName()));\r
+ twPorts->setItem(i, 1, new QTableWidgetItem(iface->getDirectionString()));\r
+ QString widthStr="";\r
+ if (iface->getType() == AbstractInterface::Boolean) {\r
+ widthStr = "std_logic";\r
+ }\r
+ else {\r
+ widthStr = "std_logic_vector(";\r
+ if (iface->getEndianess() == AbstractInterface::LittleEndian) {\r
+ widthStr += iface->getWidth();\r
+ widthStr += " downto 0)";\r
+ }\r
+ else {\r
+ widthStr += "0 to ";\r
+ widthStr += iface->getWidth();\r
+ widthStr += ")";\r
+ }\r
+ }\r
+ twPorts->setItem(i, 2, new QTableWidgetItem(widthStr));\r
+\r
+ QTableWidgetItem* item = new QTableWidgetItem(iface->getPurposeString());\r
+ twPorts->setItem(i, 3, item);\r
+\r
+ // trying to find wihch other iface this one controls\r
+ QString assoInter = "N/A";\r
+ if (iface->getPurpose() == AbstractInterface::Control) {\r
+ QString name = iface->getName();\r
+ name.remove(name.size()-4,4); // remove _enb at the end\r
+ foreach(AbstractInterface* inter, lstIface) {\r
+ if ((inter != iface) && (inter->getName().contains(name))) {\r
+ assoInter = inter->getName();\r
+ iface->setAssociatedIface(inter);\r