]> AND Private Git Repository - blast.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
moved vhdl gen. into block
authorstephane Domas <stephane.domas@univ-fcomte.fr>
Thu, 22 Mar 2018 07:51:47 +0000 (08:51 +0100)
committerstephane Domas <stephane.domas@univ-fcomte.fr>
Thu, 22 Mar 2018 07:51:47 +0000 (08:51 +0100)
BlockImplementation.cpp
BlockImplementation.h
Dispatcher.cpp
FunctionalBlock.cpp
GroupBlock.cpp
ReferenceBlock.cpp
blast.creator.user

index 1553ebbd6e685e58cec5f5448b72e731bf09a2f9..5ae6edac0fd7ab848fd62fb699937701f53d89f7 100644 (file)
@@ -102,312 +102,6 @@ bool BlockImplementation::checkPatterns() {
   return true;  \r
 }\r
 \r
   return true;  \r
 }\r
 \r
-void BlockImplementation::generateVHDL(FunctionalBlock* _block, const QString &path) throw(Exception) {\r
-\r
-  block = _block;\r
-\r
-  QFile implFile(xmlFile);\r
-\r
-  // reading in into QDomDocument\r
-  QDomDocument document("implFile");\r
-\r
-  if (!implFile.open(QIODevice::ReadOnly)) {\r
-    throw(Exception(IMPLFILE_NOACCESS));\r
-  }\r
-  if (!document.setContent(&implFile)) {\r
-    implFile.close();\r
-    throw(Exception(IMPLFILE_NOACCESS));\r
-  }\r
-  implFile.close();\r
-\r
-  bool genController = false;\r
-  QString coreFile = "";\r
-  QString controllerFile = "";\r
-\r
-  if (reference->isWBConfigurable()) {\r
-    genController = true;\r
-    controllerFile = path;\r
-    controllerFile += "/";\r
-    controllerFile.append(block->getName());\r
-    controllerFile.append("_ctrl.vhd");    \r
-  }\r
-  else {\r
-    controllerFile = "nofile.vhd";    \r
-  }\r
-  coreFile = path;\r
-  coreFile += "/";\r
-  coreFile.append(block->getName());\r
-  coreFile.append(".vhd");\r
-\r
-  QFile vhdlCore(coreFile);\r
-  QFile vhdlController(controllerFile);\r
-\r
-  if (!vhdlCore.open(QIODevice::WriteOnly)) {\r
-    throw(Exception(VHDLFILE_NOACCESS));\r
-  }\r
-\r
-  if (genController) {\r
-    if (!vhdlController.open(QIODevice::WriteOnly)) {\r
-      throw(Exception(VHDLFILE_NOACCESS));\r
-    }\r
-  }\r
-  QTextStream outCore(&vhdlCore);\r
-  QTextStream outController;\r
-  if (genController) {\r
-    outController.setDevice(&vhdlController);\r
-  }\r
-\r
-  try {\r
-\r
-\r
-    //Get the root element\r
-    QDomElement impl = document.documentElement();\r
-    QDomElement eltComments = impl.firstChildElement("comments");\r
-    generateComments(eltComments, coreFile, outCore);\r
-    QDomElement eltLibs = eltComments.nextSiblingElement("libraries");\r
-    generateLibraries(eltLibs, outCore);\r
-    generateEntity(outCore, genController);\r
-    QDomElement eltArch = eltLibs.nextSiblingElement("architecture");\r
-    generateArchitecture(eltArch, outCore);\r
-    if (genController) {\r
-      generateController(outController);\r
-    }\r
-  }\r
-  catch(Exception err) {\r
-    throw(err);\r
-  }\r
-\r
-  vhdlCore.close();\r
-  vhdlController.close();\r
-}\r
-\r
-// This function generates the comments part of the VHDL document\r
-void BlockImplementation::generateComments(QTextStream& out, QDomElement &elt, QString coreFile) throw(Exception) {\r
-\r
-  for(int i = 0; i < 50; i++) {\r
-    out << "--";\r
-  }\r
-  out << "\n--" << endl;\r
-  QString fileName = coreFile;\r
-  out << "--  File        : " << fileName << endl;\r
-  out << "--" << endl;\r
-  QDomElement eltAuthor = elt.firstChildElement("author");\r
-  QString firstName = eltAuthor.attribute("firstname","");\r
-  QString lastName = eltAuthor.attribute("lastname","");\r
-  QString mail = eltAuthor.attribute("mail","");\r
-  out << "--  Author(s)   : "<<firstName+" "<<lastName<<" ("<<mail<<")" << endl;\r
-  out << "--" << endl;\r
-  QDomElement eltDate = eltAuthor.nextSiblingElement("date");\r
-  QString crea = eltDate.attribute("creation","");\r
-  out << "--  Creation Date   : "<<crea<< endl;\r
-  out << "--" << endl;\r
-  QDomElement eltRelated = eltDate.nextSiblingElement("related_files");\r
-  QString relateds = eltRelated.attribute("list","");\r
-  out << "--  Related files   :\n"<<relateds<<endl;\r
-  out << "--" << endl;\r
-  QDomElement eltDesc = eltRelated.nextSiblingElement("description");\r
-  QDomElement desc = eltDesc.firstChildElement();\r
-  QString descTxt = desc.text();\r
-  out << "--  Decription      :\n"<<descTxt<<endl;\r
-  out << "--" << endl;\r
-  QDomElement eltNote = eltDesc.nextSiblingElement("description");\r
-  QDomElement note = eltNote.firstChildElement();\r
-  QString noteTxt = note.text();\r
-  out << "--  Note          :\n"<<noteTxt<<endl;\r
-  out << "--" << endl;\r
-  for(int i = 0; i < 50; i++) {\r
-    out << "--";\r
-  }\r
-  out << endl << endl;\r
-}\r
-\r
-// This function generates the library part of the VHDL document\r
-void BlockImplementation::generateLibraries(QTextStream& out, QDomElement &elt) throw(Exception) {\r
-\r
-  QDomNodeList listLib = elt.elementsByTagName("library");\r
-  for(int i = 0; i < listLib.length(); i++) {\r
-    QDomNode nodeLib = listLib.item(i);\r
-    QDomElement eltLib = nodeLib.toElement();\r
-    QString nameLib = eltLib.attribute("name","none");\r
-    out << "library " << nameLib << ";" << endl;\r
-    QDomNodeList listPack = eltLib.elementsByTagName("package");\r
-    for(int j = 0; j < listPack.length(); j++) {\r
-      QDomNode nodePack = listPack.item(j);\r
-      QDomElement eltPack = nodePack.toElement();\r
-      QString namePack = eltPack.attribute("name","none");\r
-      QString usePack = eltPack.attribute("use","none");\r
-      out << "use " << nameLib << "." << namePack << "." << usePack << endl;\r
-    }\r
-    out << endl;\r
-  }\r
-}\r
-\r
-// This function generates the entity part of the VHDL document\r
-void BlockImplementation::generateEntity(QTextStream& out, bool hasController) throw(Exception) {\r
-\r
-  int i=0;\r
-  nameEnt = block->getName();\r
-  //QList<BlockParameter*> listParams = reference->getParameters();\r
-  QList<AbstractInterface*> listInputs = block->getInputs();\r
-  QList<AbstractInterface*> listOutputs = block->getOutputs();\r
-  QList<AbstractInterface*> listBidirs = block->getBidirs();\r
-  QString typePort, namePort;\r
-\r
-  out << "entity " << nameEnt << " is" << endl;\r
-\r
-\r
-  /* TODO : rewrite the generation to take into acocunt the new object hierarchy */\r
-\r
-  // Generation of the generics\r
-  QList<BlockParameter*> listGenerics = block->getGenericParameters();\r
-  if ((!listGenerics.isEmpty()) || (hasController)) {\r
-    out << "  generic (" << endl;\r
-    if (hasController) {\r
-      out << "    wb_data_width : integer = 16;" << endl;\r
-      out << "    wb_addr_width : integer = 12";\r
-      if (!listGenerics.isEmpty()) out << ";";\r
-      out << endl;\r
-    }\r
-    for(i=0;i<listGenerics.size()-1;i++) {\r
-      out << "    " << listGenerics.at(i)->toVHDL(BlockParameter::Entity, 0) << endl;\r
-    }\r
-    out << "    " << listGenerics.at(i)->toVHDL(BlockParameter::Entity,BlockParameter::NoComma) << endl;\r
-\r
-    out << "    );" << endl;\r
-  }\r
-\r
-  out << "  port (" << endl;\r
-\r
-  // Generation of the clk & rst signals\r
-  out << "    -- clk/rst" << endl;\r
-  foreach(AbstractInterface* iface, listInputs) {\r
-    if(iface->getPurpose() == AbstractInterface::Clock || iface->getPurpose() == AbstractInterface::Reset) {\r
-      out << "    " << iface->getName() << " : in std_logic;" << endl;\r
-    }\r
-  }\r
-\r
-  if (hasController) {\r
-    // Generation of the wishbone signals\r
-    out << "    -- registers r/w via wishbone" << endl;\r
-    QList<BlockParameter*> listWB = reference->getWishboneParameters();\r
-    for(i=0;i<listWB.size()-1;i++) {\r
-      out << "    " << listWB.at(i)->toVHDL(BlockParameter::Entity, 0) << endl;\r
-    }\r
-    out << "    " << listWB.at(i)->toVHDL(BlockParameter::Entity,BlockParameter::NoComma) << endl;\r
-  }\r
-\r
-\r
-  int count = 0;\r
-  foreach(AbstractInterface* iface, block->getInterfaces()) {\r
-    if((iface->getPurpose() == AbstractInterface::Data)||(iface->getPurpose() == AbstractInterface::Control)) count++;\r
-  }\r
-  // Generation of the data/control signals\r
-\r
-  int flag = 0;\r
-  bool first = true;\r
-\r
-  foreach(AbstractInterface* iface, listInputs) {\r
-    if(iface->getPurpose() == AbstractInterface::Data) {\r
-      if (first) {\r
-        out << "    -- input data ports" << endl;\r
-        first = false;\r
-      }\r
-      count--;\r
-      if (count == 0) flag = AbstractInterface::NoComma;\r
-      out << "    " << iface->toVHDL(AbstractInterface::Entity, flag) << endl;\r
-    }\r
-  }\r
-  first = true;\r
-  foreach(AbstractInterface* iface, listInputs) {\r
-    if(iface->getPurpose() == AbstractInterface::Control) {\r
-      if (first) {\r
-        out << "    -- input control ports" << endl;\r
-        first = false;\r
-      }\r
-      count--;\r
-      if (count == 0) flag = AbstractInterface::NoComma;\r
-      out << "    " << iface->toVHDL(AbstractInterface::Entity, flag) << endl;\r
-    }\r
-  }\r
-  first = true;\r
-  foreach(AbstractInterface* iface, listOutputs) {\r
-    if(iface->getPurpose() == AbstractInterface::Data) {\r
-      if (first) {\r
-        out << "    -- output data ports" << endl;\r
-        first = false;\r
-      }\r
-      count--;\r
-      if (count == 0) flag = AbstractInterface::NoComma;\r
-      out << "    " << iface->toVHDL(AbstractInterface::Entity, flag) << endl;\r
-    }\r
-  }\r
-  first = true;\r
-  foreach(AbstractInterface* iface, listOutputs) {\r
-    if(iface->getPurpose() == AbstractInterface::Control) {\r
-      if (first) {\r
-        out << "    -- output control ports" << endl;\r
-        first = false;\r
-      }\r
-      count--;\r
-      if (count == 0) flag = AbstractInterface::NoComma;\r
-      out << "    " << iface->toVHDL(AbstractInterface::Entity, flag) << endl;\r
-    }\r
-  }\r
-  first = true;\r
-  foreach(AbstractInterface* iface, listBidirs) {\r
-    if(iface->getPurpose() == AbstractInterface::Data) {\r
-      if (first) {\r
-        out << "    -- bidirs data ports" << endl;\r
-        first = false;\r
-      }\r
-      count--;\r
-      if (count == 0) flag = AbstractInterface::NoComma;\r
-      out << "    " << iface->toVHDL(AbstractInterface::Entity, flag) << endl;\r
-    }\r
-  }\r
-  out << "    );" << endl << endl;\r
-  out << "end " << nameEnt << ";" << endl << endl;\r
-}\r
-\r
-// This function generates the architecture part of the VHDL document\r
-void BlockImplementation::generateArchitecture(QTextStream& out, QDomElement &elt) throw(Exception) {\r
-\r
-  QString expr;\r
-  QString code = elt.text();\r
-  cout << qPrintable(code) << endl;\r
-  out << "architecture rtl of " << nameEnt << " is" << endl;\r
-\r
-  QStringList listLine = code.split("\n");\r
-  for(int i =0; i < listLine.size(); i++) {\r
-    QString line = listLine.at(i).simplified();\r
-\r
-    /*\r
-    if(listLine.at(i).contains(QRegularExpression("@foreach{"))) {\r
-      while(listLine.at(i).compare("@endforeach") != -1) {\r
-        expr = expr + listLine.at(i) + '\n';\r
-        i++;\r
-      }\r
-      expr = expr + listLine.at(i);\r
-      out << evalComplex(expr, 1) << '\n';\r
-    }\r
-    if(listLine.at(i).contains(QRegularExpression("@caseeach{"))) {\r
-      while(listLine.at(i).compare("@endcaseeach") != -1) {\r
-        expr = expr + listLine.at(i) + '\n';\r
-        i++;\r
-      }\r
-      expr = expr + listLine.at(i);\r
-      out << evalComplex(expr, 2) << '\n';\r
-    }\r
-*/\r
-    if(line.contains("@{")) {\r
-      out << line << endl;\r
-    }\r
-  }\r
-}\r
-\r
-void BlockImplementation::generateController(QTextStream &out) throw(Exception) {\r
-}\r
-\r
 QString BlockImplementation::eval(QString line, QTextStream& out) {\r
   QString res, s, begLine, endLine, expr;\r
   evaluator->setExpression(line);\r
 QString BlockImplementation::eval(QString line, QTextStream& out) {\r
   QString res, s, begLine, endLine, expr;\r
   evaluator->setExpression(line);\r
index 8bbc29752c21d440e5bf4c6bdd1b27a22c5cb6ff..fb9c77c92be6a276b97bce1afedbb5d32ebd0dcb 100644 (file)
@@ -52,8 +52,7 @@ public:
   inline void setReference(ReferenceBlock* _reference) { reference = _reference; }\r
 \r
   void loadPatterns(QDomElement &root) throw(Exception);\r
   inline void setReference(ReferenceBlock* _reference) { reference = _reference; }\r
 \r
   void loadPatterns(QDomElement &root) throw(Exception);\r
-  bool checkPatterns();\r
-  void generateVHDL(FunctionalBlock* _block, const QString& path) throw(Exception); // main entry to generate the VHDL code\r
+  bool checkPatterns();  \r
   \r
 \r
 private:  \r
   \r
 \r
 private:  \r
@@ -70,12 +69,6 @@ private:
   QHash<QString,QString> productionPattern; // key = reference interface name, value = pattern expression\r
   QString productionCounter;\r
 \r
   QHash<QString,QString> productionPattern; // key = reference interface name, value = pattern expression\r
   QString productionCounter;\r
 \r
-  void generateComments(QTextStream& out, QDomElement &elt, QString coreFile) throw(Exception); // generates comments from <comments> element\r
-  void generateLibraries(QTextStream& out, QDomElement &elt) throw(Exception); // generates libraries from <libraries> element\r
-  void generateEntity(QTextStream& out, bool hasController=false) throw(Exception); // generate the entity using reference\r
-  void generateArchitecture(QTextStream& out, QDomElement &elt ) throw(Exception); // generate the architecture using <architecture> element\r
-  void generateController(QTextStream& out) throw(Exception); // generate the wishbone controller of the block\r
-\r
   QString getIfaceUserName(AbstractInterface* refIface); // get the name of an interface given by the user, from the reference interface\r
 \r
   friend QDataStream &operator<<(QDataStream &out, const BlockImplementation &impl);\r
   QString getIfaceUserName(AbstractInterface* refIface); // get the name of an interface given by the user, from the reference interface\r
 \r
   friend QDataStream &operator<<(QDataStream &out, const BlockImplementation &impl);\r
index 638c991a08d8b6d892b557c1ff5aa3e4cb229a5d..946f5ec4adc9ba238748325cc4e0f8cecf03e259 100644 (file)
@@ -179,10 +179,8 @@ void Dispatcher::generateBlockVHDL(BoxItem *item){
 
   if (item->getRefBlock()->isFunctionalBlock()) {
     FunctionalBlock* block = AB_TO_FUN(item->getRefBlock());
 
   if (item->getRefBlock()->isFunctionalBlock()) {
     FunctionalBlock* block = AB_TO_FUN(item->getRefBlock());
-    ReferenceBlock* ref = block->getReference();
-    BlockImplementation* impl = ref->getImplementations().at(0);
     try {
     try {
-      impl->generateVHDL(block,params->projectPath);
+      block->generateVHDL(params->projectPath);      
     }
     catch(Exception e) {
       cout << qPrintable(e.getMessage()) << endl;
     }
     catch(Exception e) {
       cout << qPrintable(e.getMessage()) << endl;
index b54e4e38c0aff86dde2fb90e19c868aae84f654c..2d455dbf90648079c1a9c203a9b70a6e44d98ce8 100644 (file)
@@ -1314,20 +1314,302 @@ int FunctionalBlock::createTriggers() {
 }\r
 \r
 void FunctionalBlock::generateVHDL(const QString& path) throw(Exception){\r
 }\r
 \r
 void FunctionalBlock::generateVHDL(const QString& path) throw(Exception){\r
+    \r
+  BlockImplementation* impl = reference->getImplementations().at(0); // for now only take first impl available\r
+  QFile implFile(impl->getXmlFile());\r
+\r
+  // reading in into QDomDocument\r
+  QDomDocument document("implFile");\r
+\r
+  if (!implFile.open(QIODevice::ReadOnly)) {\r
+    throw(Exception(IMPLFILE_NOACCESS));\r
+  }\r
+  if (!document.setContent(&implFile)) {\r
+    implFile.close();\r
+    throw(Exception(IMPLFILE_NOACCESS));\r
+  }\r
+  implFile.close();\r
+\r
+  bool genController = false;\r
+  QString coreFile = "";\r
+  QString controllerFile = "";\r
+\r
+  if (reference->isWBConfigurable()) {\r
+    genController = true;\r
+    controllerFile = path;\r
+    controllerFile += "/";\r
+    controllerFile.append(name);\r
+    controllerFile.append("_ctrl.vhd");    \r
+  }\r
+  else {\r
+    controllerFile = "nofile.vhd";    \r
+  }\r
+  coreFile = path;\r
+  coreFile += "/";\r
+  coreFile.append(name);\r
+  coreFile.append(".vhd");\r
+\r
+  QFile vhdlCore(coreFile);\r
+  QFile vhdlController(controllerFile);\r
+\r
+  if (!vhdlCore.open(QIODevice::WriteOnly)) {\r
+    throw(Exception(VHDLFILE_NOACCESS));\r
+  }\r
+\r
+  if (genController) {\r
+    if (!vhdlController.open(QIODevice::WriteOnly)) {\r
+      throw(Exception(VHDLFILE_NOACCESS));\r
+    }\r
+  }\r
+  QTextStream outCore(&vhdlCore);\r
+  QTextStream outController;\r
+  if (genController) {\r
+    outController.setDevice(&vhdlController);\r
+  }\r
+\r
+  try {\r
+    //Get the root element\r
+    QDomElement impl = document.documentElement();\r
+    QDomElement eltComments = impl.firstChildElement("comments");\r
+    generateComments(outCore,eltComments, coreFile);\r
+    QDomElement eltLibs = eltComments.nextSiblingElement("libraries");\r
+    generateLibraries(outCore, eltLibs);\r
+    generateEntity(outCore, genController);\r
+    QDomElement eltArch = eltLibs.nextSiblingElement("architecture");\r
+    generateArchitecture(outCore, eltArch );\r
+    if (genController) {\r
+      generateController(outController);\r
+    }\r
+  }\r
+  catch(Exception err) {\r
+    throw(err);\r
+  }\r
+\r
+  vhdlCore.close();\r
+  vhdlController.close();\r
+  \r
  }\r
 \r
 void FunctionalBlock::generateComments(QTextStream& out, QDomElement &elt, QString coreFile) throw(Exception) {\r
 \r
  }\r
 \r
 void FunctionalBlock::generateComments(QTextStream& out, QDomElement &elt, QString coreFile) throw(Exception) {\r
 \r
+  for(int i = 0; i < 50; i++) {\r
+    out << "--";\r
+  }\r
+  out << "\n--" << endl;\r
+  QString fileName = coreFile;\r
+  out << "--  File        : " << fileName << endl;\r
+  out << "--" << endl;\r
+  QDomElement eltAuthor = elt.firstChildElement("author");\r
+  QString firstName = eltAuthor.attribute("firstname","");\r
+  QString lastName = eltAuthor.attribute("lastname","");\r
+  QString mail = eltAuthor.attribute("mail","");\r
+  out << "--  Author(s)   : "<<firstName+" "<<lastName<<" ("<<mail<<")" << endl;\r
+  out << "--" << endl;\r
+  QDomElement eltDate = eltAuthor.nextSiblingElement("date");\r
+  QString crea = eltDate.attribute("creation","");\r
+  out << "--  Creation Date   : "<<crea<< endl;\r
+  out << "--" << endl;\r
+  QDomElement eltRelated = eltDate.nextSiblingElement("related_files");\r
+  QString relateds = eltRelated.attribute("list","");\r
+  out << "--  Related files   :\n"<<relateds<<endl;\r
+  out << "--" << endl;\r
+  QDomElement eltDesc = eltRelated.nextSiblingElement("description");\r
+  QDomElement desc = eltDesc.firstChildElement();\r
+  QString descTxt = desc.text();\r
+  out << "--  Decription      :\n"<<descTxt<<endl;\r
+  out << "--" << endl;\r
+  QDomElement eltNote = eltDesc.nextSiblingElement("description");\r
+  QDomElement note = eltNote.firstChildElement();\r
+  QString noteTxt = note.text();\r
+  out << "--  Note          :\n"<<noteTxt<<endl;\r
+  out << "--" << endl;\r
+  for(int i = 0; i < 50; i++) {\r
+    out << "--";\r
+  }\r
+  out << endl << endl;\r
 }\r
 \r
 void FunctionalBlock::generateLibraries(QTextStream& out, QDomElement &elt) throw(Exception) {\r
 }\r
 \r
 void FunctionalBlock::generateLibraries(QTextStream& out, QDomElement &elt) throw(Exception) {\r
-\r
+  \r
+  QDomNodeList listLib = elt.elementsByTagName("library");\r
+  for(int i = 0; i < listLib.length(); i++) {\r
+    QDomNode nodeLib = listLib.item(i);\r
+    QDomElement eltLib = nodeLib.toElement();\r
+    QString nameLib = eltLib.attribute("name","none");\r
+    out << "library " << nameLib << ";" << endl;\r
+    QDomNodeList listPack = eltLib.elementsByTagName("package");\r
+    for(int j = 0; j < listPack.length(); j++) {\r
+      QDomNode nodePack = listPack.item(j);\r
+      QDomElement eltPack = nodePack.toElement();\r
+      QString namePack = eltPack.attribute("name","none");\r
+      QString usePack = eltPack.attribute("use","none");\r
+      out << "use " << nameLib << "." << namePack << "." << usePack << endl;\r
+    }\r
+    out << endl;\r
+  }\r
 }\r
 \r
 }\r
 \r
-void FunctionalBlock::generateEntity(QTextStream& out, bool hasController=false) throw(Exception) {\r
+void FunctionalBlock::generateEntity(QTextStream& out, bool hasController) throw(Exception) {\r
+\r
+  int i=0;\r
+  \r
+  //QList<BlockParameter*> listParams = reference->getParameters();\r
+  QList<AbstractInterface*> listInputs = getInputs();\r
+  QList<AbstractInterface*> listOutputs = getOutputs();\r
+  QList<AbstractInterface*> listBidirs = getBidirs();\r
+  QString typePort, namePort;\r
+\r
+  out << "entity " << name << " is" << endl;\r
+\r
+\r
+  /* TODO : rewrite the generation to take into acocunt the new object hierarchy */\r
+\r
+  // Generation of the generics\r
+  QList<BlockParameter*> listGenerics = getGenericParameters();\r
+  if ((!listGenerics.isEmpty()) || (hasController)) {\r
+    out << "  generic (" << endl;\r
+    if (hasController) {\r
+      out << "    wb_data_width : integer = 16;" << endl;\r
+      out << "    wb_addr_width : integer = 12";\r
+      if (!listGenerics.isEmpty()) out << ";";\r
+      out << endl;\r
+    }\r
+    for(i=0;i<listGenerics.size()-1;i++) {\r
+      out << "    " << listGenerics.at(i)->toVHDL(BlockParameter::Entity, 0) << endl;\r
+    }\r
+    out << "    " << listGenerics.at(i)->toVHDL(BlockParameter::Entity,BlockParameter::NoComma) << endl;\r
+\r
+    out << "    );" << endl;\r
+  }\r
+\r
+  out << "  port (" << endl;\r
 \r
 \r
+  // Generation of the clk & rst signals\r
+  out << "    -- clk/rst" << endl;\r
+  foreach(AbstractInterface* iface, listInputs) {\r
+    if(iface->getPurpose() == AbstractInterface::Clock || iface->getPurpose() == AbstractInterface::Reset) {\r
+      out << "    " << iface->getName() << " : in std_logic;" << endl;\r
+    }\r
+  }\r
+\r
+  if (hasController) {\r
+    // Generation of the wishbone signals\r
+    out << "    -- registers r/w via wishbone" << endl;\r
+    QList<BlockParameter*> listWB = reference->getWishboneParameters();\r
+    for(i=0;i<listWB.size()-1;i++) {\r
+      out << "    " << listWB.at(i)->toVHDL(BlockParameter::Entity, 0) << endl;\r
+    }\r
+    out << "    " << listWB.at(i)->toVHDL(BlockParameter::Entity,BlockParameter::NoComma) << endl;\r
+  }\r
+\r
+\r
+  int count = 0;\r
+  foreach(AbstractInterface* iface, getInterfaces()) {\r
+    if((iface->getPurpose() == AbstractInterface::Data)||(iface->getPurpose() == AbstractInterface::Control)) count++;\r
+  }\r
+  // Generation of the data/control signals\r
+\r
+  int flag = 0;\r
+  bool first = true;\r
+\r
+  foreach(AbstractInterface* iface, listInputs) {\r
+    if(iface->getPurpose() == AbstractInterface::Data) {\r
+      if (first) {\r
+        out << "    -- input data ports" << endl;\r
+        first = false;\r
+      }\r
+      count--;\r
+      if (count == 0) flag = AbstractInterface::NoComma;\r
+      out << "    " << iface->toVHDL(AbstractInterface::Entity, flag) << endl;\r
+    }\r
+  }\r
+  first = true;\r
+  foreach(AbstractInterface* iface, listInputs) {\r
+    if(iface->getPurpose() == AbstractInterface::Control) {\r
+      if (first) {\r
+        out << "    -- input control ports" << endl;\r
+        first = false;\r
+      }\r
+      count--;\r
+      if (count == 0) flag = AbstractInterface::NoComma;\r
+      out << "    " << iface->toVHDL(AbstractInterface::Entity, flag) << endl;\r
+    }\r
+  }\r
+  first = true;\r
+  foreach(AbstractInterface* iface, listOutputs) {\r
+    if(iface->getPurpose() == AbstractInterface::Data) {\r
+      if (first) {\r
+        out << "    -- output data ports" << endl;\r
+        first = false;\r
+      }\r
+      count--;\r
+      if (count == 0) flag = AbstractInterface::NoComma;\r
+      out << "    " << iface->toVHDL(AbstractInterface::Entity, flag) << endl;\r
+    }\r
+  }\r
+  first = true;\r
+  foreach(AbstractInterface* iface, listOutputs) {\r
+    if(iface->getPurpose() == AbstractInterface::Control) {\r
+      if (first) {\r
+        out << "    -- output control ports" << endl;\r
+        first = false;\r
+      }\r
+      count--;\r
+      if (count == 0) flag = AbstractInterface::NoComma;\r
+      out << "    " << iface->toVHDL(AbstractInterface::Entity, flag) << endl;\r
+    }\r
+  }\r
+  first = true;\r
+  foreach(AbstractInterface* iface, listBidirs) {\r
+    if(iface->getPurpose() == AbstractInterface::Data) {\r
+      if (first) {\r
+        out << "    -- bidirs data ports" << endl;\r
+        first = false;\r
+      }\r
+      count--;\r
+      if (count == 0) flag = AbstractInterface::NoComma;\r
+      out << "    " << iface->toVHDL(AbstractInterface::Entity, flag) << endl;\r
+    }\r
+  }\r
+  out << "    );" << endl << endl;\r
+  out << "end " << name << ";" << endl << endl;\r
 }\r
 \r
 void FunctionalBlock::generateArchitecture(QTextStream& out, QDomElement &elt ) throw(Exception) {\r
 }\r
 \r
 void FunctionalBlock::generateArchitecture(QTextStream& out, QDomElement &elt ) throw(Exception) {\r
+  QString expr;\r
+  QString code = elt.text();\r
+  cout << qPrintable(code) << endl;\r
+  out << "architecture rtl of " << name << " is" << endl;\r
+\r
+  QStringList listLine = code.split("\n");\r
+  for(int i =0; i < listLine.size(); i++) {\r
+    QString line = listLine.at(i).simplified();\r
 \r
 \r
+    /*\r
+    if(listLine.at(i).contains(QRegularExpression("@foreach{"))) {\r
+      while(listLine.at(i).compare("@endforeach") != -1) {\r
+        expr = expr + listLine.at(i) + '\n';\r
+        i++;\r
+      }\r
+      expr = expr + listLine.at(i);\r
+      out << evalComplex(expr, 1) << '\n';\r
+    }\r
+    if(listLine.at(i).contains(QRegularExpression("@caseeach{"))) {\r
+      while(listLine.at(i).compare("@endcaseeach") != -1) {\r
+        expr = expr + listLine.at(i) + '\n';\r
+        i++;\r
+      }\r
+      expr = expr + listLine.at(i);\r
+      out << evalComplex(expr, 2) << '\n';\r
+    }\r
+*/\r
+    if(line.contains("@{")) {\r
+      out << line << endl;\r
+    }\r
+  }\r
 }\r
 }\r
+\r
+void FunctionalBlock::generateController(QTextStream &out) throw(Exception) {\r
+  \r
+}\r
+\r
index a3966bddb34e9ad163c370c7ee7f92b05240aa98..17b7bbada131ceca48d267eb6b056b427486e230 100644 (file)
@@ -281,11 +281,12 @@ void GroupBlock::generateVHDL(const QString& path) throw(Exception) {
 
   QTextStream outCore(&vhdlCore);
 
 
   QTextStream outCore(&vhdlCore);
 
+  QDomElement dummyElt;
   try {
   try {
-    generateComments(outCore);
-    generateLibraries(outCore);
+    generateComments(outCore,dummyElt,"");
+    generateLibraries(outCore,dummyElt);
     generateEntity(outCore);
     generateEntity(outCore);
-    generateArchitecture(outCore);
+    generateArchitecture(outCore,dummyElt);
   }
   catch(Exception err) {
     throw(err);
   }
   catch(Exception err) {
     throw(err);
@@ -307,7 +308,7 @@ void GroupBlock::generateLibraries(QTextStream& out, QDomElement &elt) throw(Exc
 
 }
 
 
 }
 
-void GroupBlock::generateEntity(QTextStream& out) throw(Exception) {
+void GroupBlock::generateEntity(QTextStream& out, bool hasController) throw(Exception) {
 
   int i;
 
 
   int i;
 
@@ -414,3 +415,7 @@ void GroupBlock::generateArchitecture(QTextStream& out, QDomElement &elt) throw(
 
 }
 
 
 }
 
+void GroupBlock::generateController(QTextStream &out) throw(Exception) {
+  
+}
+
index f6fd9c7eb0d099cab4c2758a858b0793599220ab..70677dfa233020f9cfea9d9ee9b70c8e95a2dc81 100644 (file)
@@ -648,7 +648,7 @@ void ReferenceBlock::generateLibraries(QTextStream& out, QDomElement &elt) throw
   throw(Exception(INVALID_REFBLOCK_USE));
 }
 
   throw(Exception(INVALID_REFBLOCK_USE));
 }
 
-void ReferenceBlock::generateEntity(QTextStream& out, bool hasController=false) throw(Exception) {
+void ReferenceBlock::generateEntity(QTextStream& out, bool hasController) throw(Exception) {
   throw(Exception(INVALID_REFBLOCK_USE));
 }
 
   throw(Exception(INVALID_REFBLOCK_USE));
 }
 
index 37faf88f305ebea4e89d9617933c63cda87440bf..1aea169400b81fdabdeab41c20901b2a515257d3 100644 (file)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.2.0, 2018-03-05T12:13:31. -->
+<!-- Written by QtCreator 4.2.0, 2018-03-21T17:45:46. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
-  <value type="QByteArray">{94112477-caab-4897-8f75-5f412f2c883a}</value>
+  <value type="QByteArray">{3701e197-5b6c-48ea-9e98-a6cf6de18672}</value>
  </data>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
  </data>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -19,7 +19,7 @@
    <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
     <value type="QString" key="language">Cpp</value>
     <valuemap type="QVariantMap" key="value">
    <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
     <value type="QString" key="language">Cpp</value>
     <valuemap type="QVariantMap" key="value">
-     <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
+     <value type="QByteArray" key="CurrentPreferences">qt2</value>
     </valuemap>
    </valuemap>
    <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
     </valuemap>
    </valuemap>
    <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
@@ -31,7 +31,7 @@
    <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
    <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
    <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
    <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
    <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
    <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
-   <value type="int" key="EditorConfiguration.IndentSize">4</value>
+   <value type="int" key="EditorConfiguration.IndentSize">2</value>
    <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
    <value type="int" key="EditorConfiguration.MarginColumn">80</value>
    <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
    <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
    <value type="int" key="EditorConfiguration.MarginColumn">80</value>
    <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
    <value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
    <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
    <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
    <value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
    <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
    <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
-   <value type="int" key="EditorConfiguration.TabSize">8</value>
-   <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
+   <value type="int" key="EditorConfiguration.TabSize">4</value>
+   <value type="bool" key="EditorConfiguration.UseGlobal">false</value>
    <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
    <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
    <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
    <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
    <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
    <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
-   <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
+   <value type="bool" key="EditorConfiguration.cleanWhitespace">false</value>
    <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
   </valuemap>
  </data>
    <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
   </valuemap>
  </data>
@@ -61,7 +61,7 @@
   <valuemap type="QVariantMap">
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
   <valuemap type="QVariantMap">
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{c934e180-ebc6-41ed-be82-502cc94f41f6}</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{ed04208c-8774-456b-99b9-4a02094ca7a4}</value>
    <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
    <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
     <value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
     <value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
    <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
     <value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
     <value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
-    <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
+    <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">0</value>
     <value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
     <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
     <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
     <value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
     <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
     <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
     <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
     <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
     <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
     <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
     <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
     <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
+    <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
     <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
     <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Exécutable personnalisé</value>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
     <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
     <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>