+ QDomElement archi = doc.createElement("architecture");\r
+ eBlock.appendChild(archi);\r
+ QDomText tName = doc.createTextNode("");\r
+ foreach(QString line, archLines) {\r
+ tName.appendData(line+"\n");\r
+ }\r
+ archi.appendChild(tName);\r
+\r
+ QDomElement patterns = doc.createElement("patterns");\r
+ eBlock.appendChild(patterns);\r
+ QDomElement delta = doc.createElement("delta");\r
+ delta.setAttribute("value","to_define");\r
+ patterns.appendChild(delta);\r
+ QDomElement cons = doc.createElement("consumption");\r
+ foreach(AbstractInterface* iface, lstIface) {\r
+ if ((iface->getDirection() == AbstractInterface::Input) && (iface->getPurpose() == AbstractInterface::Control)) {\r
+ QDomElement input = doc.createElement("input");\r
+ input.setAttribute("name",iface->getName());\r
+ input.setAttribute("pattern","to_define");\r
+ cons.appendChild(input);\r
+ }\r
+ }\r
+ patterns.appendChild(cons);\r
+ QDomElement prod = doc.createElement("production");\r
+ prod.setAttribute("counter","to_define");\r
+ foreach(AbstractInterface* iface, lstIface) {\r
+ if ((iface->getDirection() == AbstractInterface::Output) && (iface->getPurpose() == AbstractInterface::Control)) {\r
+ QDomElement output = doc.createElement("output");\r
+ output.setAttribute("name",iface->getName());\r
+ output.setAttribute("pattern","to_define");\r
+ prod.appendChild(output);\r
+ }\r
+ }\r
+ patterns.appendChild(prod);\r
+}\r
+\r
+void VHDLConverter::replaceSignalNames(QString& line) {\r
+ foreach(AbstractInterface* iface, lstIface) {\r
+ QString pattern = iface->getName() + "([^a-zA-Z0-9_])";\r
+ QString repl = "@{"+iface->getName()+"}\\1";\r
+ QRegularExpression rxPort(pattern,QRegularExpression::CaseInsensitiveOption);\r
+ line.replace(rxPort,repl);\r
+ }\r
+\r
+}\r
+\r
+void VHDLConverter::updateArchitecture() {\r
+ QRegularExpression rxLT("<=",QRegularExpression::CaseInsensitiveOption);\r
+ QRegularExpression rxGT("=>",QRegularExpression::CaseInsensitiveOption);\r
+ for(int i=0;i<archLines.size();i++) {\r
+ QString line = archLines.at(i);\r
+ replaceSignalNames(line);\r
+ //line.replace(rxLT,"<=");\r
+ //line.replace(rxGT,"=>");\r
+ archLines.replace(i,line);\r
+ cout << qPrintable(line) << endl;\r
+ }\r
+}\r
+\r
+// This function gets the informations in the table and the descriptions, and creates a XML file with this content\r
+void VHDLConverter::generateXml() {\r
+\r
+\r
+ updateArchitecture();\r
+\r
+ // creating reference xml\r
+ QDomDocument docRef(entityName);\r
+ generateRefXml(docRef);\r
+\r
+ // creating implementation xml\r
+ QDomDocument docImpl(entityName);\r
+ generateImplXml(docImpl);\r
+\r
+ QString dir = QFileDialog::getExistingDirectory(this,tr("Save file in"),".",QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);\r
+\r
+ QString fileName = dir + "/"+ entityName + ".xml";\r
+\r
+ QFile fileRef(fileName);\r
+ if(!fileRef.open(QIODevice::WriteOnly | QIODevice::Text)) {\r
+ cerr << "Cannot save in " << qPrintable(fileName) << endl;\r
+ return;\r
+ }\r
+ QTextStream tsRef(&fileRef);\r
+ docRef.save(tsRef,QDomNode::EncodingFromTextStream);\r
+ fileRef.close();\r
+\r
+ fileName = dir + "/"+ entityName + "_impl.xml";\r
+ QFile fileImpl(fileName);\r
+ if(!fileImpl.open(QIODevice::WriteOnly | QIODevice::Text)) {\r
+ cerr << "Cannot save in " << qPrintable(fileName) << endl;\r
+ return;\r
+ }\r
+ QTextStream tsImpl(&fileImpl);\r
+ docImpl.save(tsImpl,QDomNode::EncodingFromTextStream);\r
+ fileImpl.close();\r