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

Private GIT Repository
finished VHDL gen. (but have to test further
[blast.git] / Dispatcher.cpp
index c3ff33fd91b713078ff111e3ec9e2389b630477c..b9e09a946151f447a71b6eb287cffa586f6fe39b 100644 (file)
@@ -2,6 +2,8 @@
 #include "Parameters.h"
 #include "MainWindow.h"
 
 #include "Parameters.h"
 #include "MainWindow.h"
 
+#include "ExternalResource.h"
+
 #include "Graph.h"
 #include "ReferenceBlock.h"
 #include "GroupBlock.h"
 #include "Graph.h"
 #include "ReferenceBlock.h"
 #include "GroupBlock.h"
@@ -71,6 +73,7 @@ GroupWidget *Dispatcher::loadProject(const QString& filename) {
 
   QFileInfo info(filename);
   params->projectPath = info.absolutePath();
 
   QFileInfo info(filename);
   params->projectPath = info.absolutePath();
+  params->projectName = info.baseName();
   cout << "project path = " << qPrintable(params->projectPath) << endl;
   groupList.append(topGroup);
   return topGroup;
   cout << "project path = " << qPrintable(params->projectPath) << endl;
   groupList.append(topGroup);
   return topGroup;
@@ -174,6 +177,93 @@ void Dispatcher::changeConnectionMode(int mode){
   */
 }
 
   */
 }
 
+void Dispatcher::generateVHDL() throw(Exception) {
+  static QString fctName = "Dispatcher::generateVHDL()";
+#ifdef DEBUG_FCTNAME
+  cout << "call to " << qPrintable(fctName) << endl;
+#endif
+
+  QDir baseDir(params->projectPath);
+  QDir srcDir(params->projectPath+"/src");
+
+  if (!baseDir.exists()) {
+    cerr << "Project path " << qPrintable(params->projectPath) << " no longer exists. First, recreate it and put the project file within. Then retry to generate." << endl;
+    return;
+  }
+
+  if (srcDir.exists()) {
+    srcDir.removeRecursively();
+  }
+  baseDir.mkdir("src");
+
+  if (! baseDir.exists("testbench")) {
+    baseDir.mkdir("testbench");
+  }
+  if (! baseDir.exists("Makefile")) {
+    QFile make("/home/sdomas/Projet/Blast/code/blast/Makefile-isim");
+    QString dest = params->projectPath;
+    dest += "/Makefile";
+    make.copy(dest);
+  }
+
+  // copying external resources
+  QString dest = params->projectPath;
+  dest += "/src/";
+  try {
+    params->getGraph()->generateVHDL(dest);
+
+    QList<QString> extResources = params->getGraph()->getExternalResources();
+    foreach(QString name, extResources) {
+      cout << qPrintable(name) << endl;
+      QList<ExternalResource*> lstRes = params->searchResourceByName(name);
+      foreach(ExternalResource* res, lstRes) {
+        QFile resFile(res->getFile());
+        QFileInfo info(res->getFile());
+        QString destFile = dest+info.fileName();
+        cout << "copying " << qPrintable(res->getFile()) << " into " << qPrintable(destFile) << endl;
+        resFile.copy(destFile);
+      }
+    }
+  }
+  catch(Exception e) {
+    throw(e);
+  }
+
+  // creating parameters file
+  QString paramName = params->projectPath+"/params-isim.txt";
+  QFile paramFile(paramName);
+  if (!paramFile.open(QIODevice::WriteOnly)) {
+    throw(Exception(PROJECTPATH_NOACCESS));
+  }
+  QTextStream out(&paramFile);
+  out << "PROJECT_NAME := " << params->projectName << endl << endl;
+  out << "SRC_DIR := src" << endl;
+  out << "TB_DIR := testbench" << endl << endl;
+  out << "VHDL_SRC := ";
+  QStringList filter;
+  filter << "*.vhd" ;
+  srcDir.setNameFilters(filter);
+  QStringList listVHDL = srcDir.entryList();
+  for(int j=0;j<listVHDL.size();j++) {
+    if (j > 0) {
+      out << "\t";
+    }
+    out << "$(SRC_DIR)/" << qPrintable(listVHDL.at(j));
+    if (j != listVHDL.size()-1) {
+      out << " \\";
+    }
+    out << endl;
+  }
+  out << endl;
+  out << "VL_SRC := ${XILINX}/verilog/src/glbl.v" << endl << endl;
+  out << "TB_SRC := $(TB_DIR)/$(PROJECT_NAME)_tb.vhd" << endl << endl;
+  out << "SIMU_EXE := $(PROJECT_NAME)_tb" << endl << endl;
+
+  paramFile.close();
+
+
+}
+
 void Dispatcher::generateBlockVHDL(BoxItem *item){
   static QString fctName = "Dispatcher::generateBlockVHDL()";
 #ifdef DEBUG_FCTNAME
 void Dispatcher::generateBlockVHDL(BoxItem *item){
   static QString fctName = "Dispatcher::generateBlockVHDL()";
 #ifdef DEBUG_FCTNAME