+ }
+ catch(Exception e) {
+ throw(e);
+ }
+ // generate testbench
+ dest = params->projectPath;
+ dest += "/testbench/";
+ dest += params->projectName;
+ dest += "_tb.vhd";
+ try {
+ params->getGraph()->generateTestbench(params->projectName, dest);
+ }
+ 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(¶mFile);
+ 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();
+
+ QString msg = "VHDL generation completed successfully. Go to ";
+ msg += params->projectPath+" and type the following commands to launch a simulation:\n";
+ msg += "\tmake clean\n";
+ msg += "\tmake\n";
+ msg += "\tmake view\n";
+ QMessageBox::information(mainWindow,"VHDL generation", msg, QMessageBox::Ok);
+
+}
+
+void Dispatcher::generateBlockVHDL(Context context, BoxItem *item){
+ static QString fctName = "Dispatcher::generateBlockVHDL()";
+#ifdef DEBUG_FCTNAME
+ cout << "call to " << qPrintable(fctName) << endl;
+#endif
+ /* NB: only called in Design context */
+ if (context != Design) {
+ cout << "Abnormal case: call to " << qPrintable(fctName) << " not in Design context" << endl;
+ return;
+ }
+
+
+ if (item->getRefBlock()->isFunctionalBlock()) {
+ FunctionalBlock* block = AB_TO_FUN(item->getRefBlock());
+ try {
+ block->generateVHDL(params->projectPath);
+ }
+ catch(Exception e) {
+ cout << qPrintable(e.getMessage()) << endl;
+ }
+ }
+}
+
+void Dispatcher::renameFunctionalBlock(Context context, BoxItem *item){
+ static QString fctName = "Dispatcher::renameFunctionalBlock()";
+#ifdef DEBUG_FCTNAME
+ cout << "call to " << qPrintable(fctName) << endl;
+#endif
+ /* NB: only called in Design context */
+ if (context != Design) {
+ cout << "Abnormal case: call to " << qPrintable(fctName) << " not in Design context" << endl;
+ return;
+ }
+
+
+ GroupWidget* win = item->getScene()->getGroupWidget();
+
+ bool ok = false;
+ QString text = "";
+ while (!ok) {
+ text = QInputDialog::getText(win, "Rename a functional block",
+ "New name:", QLineEdit::Normal,
+ item->getRefBlock()->getName(), &ok);
+ if (!ok) return;
+
+ if (text == item->getRefBlock()->getName()) return;
+
+ if( (text.isEmpty()) || (text.length() > 30)) {
+ QMessageBox::warning(win,"Error in given name",
+ "the block name must be shorter than 30 characters, cannot be empty",
+ QMessageBox::Ok);
+ ok = false;
+ }