diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/createKicadLibrary.py | 6 | ||||
-rw-r--r-- | src/ghdlserver/ghdlserver.c | 18 | ||||
-rw-r--r-- | src/model_generation.py | 38 | ||||
-rwxr-xr-x | src/ngspice_ghdl.py | 36 |
4 files changed, 51 insertions, 47 deletions
diff --git a/src/createKicadLibrary.py b/src/createKicadLibrary.py index 49c298e..a75413c 100644 --- a/src/createKicadLibrary.py +++ b/src/createKicadLibrary.py @@ -28,8 +28,8 @@ class AutoSchematic(QtGui.QWidget): self.createLib() elif (xmlFound == self.xml_loc + '/Nghdl'): print 'Library already exists...' - ret = QtGui.QMessageBox.critical(self, "Critical",'''<b>The Libraries of this model already exist.Do you want to overwrite it?</b><br/> - <b>If yes, press ok else cancel it and change the name of your vhdl file</b>''', QtGui.QMessageBox.Ok, QtGui.QMessageBox.Cancel) + ret = QtGui.QMessageBox.warning(self, "Warning",'''<b>Library files for this model already exist. Do you want to overwrite it?</b><br/> + If yes press ok, else cancel it and change the name of your vhdl file.''', QtGui.QMessageBox.Ok, QtGui.QMessageBox.Cancel) if ret == QtGui.QMessageBox.Ok: print "Overwriting existing libraries" self.getPortInformation() @@ -41,7 +41,7 @@ class AutoSchematic(QtGui.QWidget): quit() else: print 'Pre existing library...' - ret = QtGui.QMessageBox.critical(self, "Error",'''<b>A standard library already exists in this name.</b><br/> + ret = QtGui.QMessageBox.critical(self, "Error",'''<b>A standard library already exists with this name.</b><br/> <b>Please change the name of your vhdl file and upload it again</b>''', QtGui.QMessageBox.Ok) # quit() diff --git a/src/ghdlserver/ghdlserver.c b/src/ghdlserver/ghdlserver.c index e05a156..60e1a20 100644 --- a/src/ghdlserver/ghdlserver.c +++ b/src/ghdlserver/ghdlserver.c @@ -100,7 +100,7 @@ static int get_ngspice_pid(void) if ((dirp = opendir("/proc/")) == NULL) { - perror("opendir /proc failed"); + perror("get_ngspice_pid() - opendir /proc failed "); exit(-1); } @@ -112,7 +112,7 @@ static int get_ngspice_pid(void) int tmp = strtol(dir_entry->d_name, &nptr, 10); if ((errno == ERANGE) && (tmp == LONG_MAX || tmp == LONG_MIN)) { - perror("strtol"); // Number out of range. + perror("get_ngspice_pid() - strtol"); // Number out of range. return(-1); } if (dir_entry->d_name == nptr) @@ -133,7 +133,7 @@ static int get_ngspice_pid(void) } } - if (fp) fclose(fp); + if (fp) fclose(fp); return(pid); } @@ -165,7 +165,7 @@ static void create_pid_file(int sock_port) fprintf(pid_file,"%d\n", my_pid); fclose(pid_file); } else { - perror("fopen() - PID file"); + perror("create_pid_file() - cannot open PID file "); syslog(LOG_ERR, "create_pid_file(): Unable to open PID file in /tmp"); exit(1); } @@ -323,7 +323,7 @@ static void receive_string(int sock_id, char* buffer) nbytes = recv(sock_id, buffer, MAX_BUF_SIZE, 0); if (nbytes <= 0) { - perror("READ FAILURE"); + perror("receive_string() - READ FAILURE "); exit(1); } } @@ -394,13 +394,13 @@ void Vhpi_Initialize(int sock_port, char sock_ip[]) if(server_socket_id >= 0) { - syslog(LOG_INFO,"Started the server on port %d SRV:%d", - DEFAULT_SERVER_PORT, server_socket_id); + syslog(LOG_INFO,"Started the server on port %d SRV:%d", + DEFAULT_SERVER_PORT, server_socket_id); break; } syslog(LOG_ERR,"Could not start server on port %d,will try again", - DEFAULT_SERVER_PORT); + DEFAULT_SERVER_PORT); usleep(1000); try_limit--; @@ -408,7 +408,7 @@ void Vhpi_Initialize(int sock_port, char sock_ip[]) { syslog(LOG_ERR, "Error:Tried to start server on port %d, failed..giving up.", - DEFAULT_SERVER_PORT); + DEFAULT_SERVER_PORT); exit(1); } } diff --git a/src/model_generation.py b/src/model_generation.py index 5bfa960..e507b55 100644 --- a/src/model_generation.py +++ b/src/model_generation.py @@ -212,7 +212,7 @@ systime_info=''' time_t systime; systime = time(NULL); printf(ctime(&systime)); - printf("Client-Initialising GHDL..."); + printf("Client-Initialising GHDL...\\n\\n"); fprintf(log_client,"Setup Client Server Connection at %s \\n",ctime(&systime)); ''' @@ -266,7 +266,7 @@ client_setup_ip=''' fprintf(fptr, "%s\\n", my_ip); fclose(fptr); } else { - perror("fopen() - Common IP"); + perror("Client - cannot open Common_IP file "); exit(1); } @@ -279,7 +279,6 @@ client_fetch_ip=''' char* my_ip = STATIC_VAR(my_ip); host = gethostbyname(my_ip); - printf("\\n\\nClient-Creating Socket \\n"); fprintf(log_client,"Creating client socket \\n"); ''' @@ -287,13 +286,12 @@ create_socket=''' //Creating socket for client if ((socket_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - perror("Client-Error while creating client Socket \\n"); + perror("Client-Error while creating client Socket "); fprintf(log_client,"Error while creating client socket \\n"); exit(1); } - printf("Client-Client Socket created successfully \\n"); - printf("Client- Socket Id : %d \\n",socket_fd); + printf("Client-Socket (Id : %d) created\\n", socket_fd); fprintf(log_client,"Client-Client Socket created successfully \\n"); fprintf(log_client,"Client- Socket Id : %d \\n",socket_fd); @@ -306,7 +304,6 @@ create_socket=''' ''' connect_server=''' - printf("Client-Connecting to server \\n"); fprintf(log_client,"Client-Connecting to server \\n"); //Connecting to server @@ -368,8 +365,6 @@ for item in input_port: else: snprintf_stmt.append(",") -snprintf_stmt.append('\n\tprintf("Client-Value of buffer string is %s \\n",send_data);') -snprintf_stmt.append('\n\tprintf("Client-Sending data to server from client \\n");') send_data=''' @@ -381,7 +376,7 @@ send_data=''' } else { - printf("Client-Message being sent: %s \\n",send_data); + printf("Client-Message sent: %s \\n",send_data); fprintf(log_client,"Socket Id : %d & Message sent : %s \\n",socket_fd,send_data); } @@ -392,12 +387,12 @@ recv_data=''' bytes_recieved=recv(socket_fd,recv_data,sizeof(recv_data),0); if ( bytes_recieved <= 0 ) { - printf("Client-Either Connection Closed or Error \\n"); + perror("Client-Either Connection Closed or Error "); exit(1); } recv_data[bytes_recieved] = '\\0'; - printf("Client-Message Received From Server - %s\\n",recv_data); + printf("Client-Message Received - %s\\n\\n",recv_data); fprintf(log_client,"Message Received From Server- %s\\n",recv_data); ''' @@ -413,13 +408,10 @@ for item in output_port: \t\twhile(*key_iter++ != ':');\n\ \t\tfor(Ii=0;*key_iter != ';';Ii++,key_iter++)\n\ \t\t{\n\ -\t\t\tprintf(\"Client- Bit val is %c \\n\",*key_iter);\n\ \t\t\tfprintf(log_client,\"Client-Bit val is %c \\n\",*key_iter);\n\ \t\t\tif(*key_iter=='0')\n\t\t\t{\n\ -\t\t\t\tprintf(\"Client-Zero Received \");\n\ \t\t\t\t_op_"+item.split(':')[0]+"[Ii]=ZERO;\n\t\t\t}\n\ \t\t\telse if(*key_iter=='1')\n\t\t\t{\n\ -\t\t\t\tprintf(\"Client-One Received \\n\");\n\ \t\t\t\t_op_"+item.split(':')[0]+"[Ii]=ONE;\n\ \t\t\t}\n\t\t\telse\n\t\t\t{\n\ \t\t\t\tfprintf(log_client,\"Unknow value return from server \\n\");\n\ @@ -626,9 +618,11 @@ print "Starting with testbench file" testbench=open(fname.split('.')[0]+'_tb.vhdl','w') print fname.split('.')[0] + '_tb.vhdl' #comment -comment_vhdl="--------------------------------------------------------------------------------\n--This testbench has been created by Ambikeshwar Srivastava, FOSSEE, IIT Bombay\n--------------------------------------------------------------------------------\n" -comment_vhdl+="--------------------------------------------------------------------------------\n--Modified by Rahul Paknikar, FOSSEE, IIT Bombay\n" -comment_vhdl+="--retrieves the IP-Addr from sock_pkg and forwards it to the ghdlserver\n--------------------------------------------------------------------------------\n" +comment_vhdl="--------------------------------------------------------------------------------\n" +comment_vhdl+="--This testbench has been created by Ambikeshwar Srivastava, Rahul Paknikar \n" +comment_vhdl+="--------------------------- FOSSEE, IIT Bombay ---------------------------------\n" +comment_vhdl+="--------------------------------------------------------------------------------\n" + #Adding header, entity and architecture statement tb_header=''' library ieee; @@ -737,7 +731,8 @@ process_Vhpi=[] process_Vhpi.append("\tprocess\n\t\tvariable sock_port : integer;\n\t\ttype string_ptr is access string;\n\t\tvariable sock_ip : string_ptr;\n\t\tbegin\n\t\tsock_port := sock_port_fun;\n\t\tsock_ip := new string'(sock_ip_fun);\n\t\tVhpi_Initialize(sock_port, Pack_String_To_Vhpi_String(sock_ip.all));\n\t\twait until clk_s = '1';\n\t\twhile true loop\n\t\t\twait until clk_s = '0';\n\t\t\tVhpi_Listen;\n\t\t\twait for 1 us;\n\t\t\tVhpi_Send;\n\t\tend loop;\n\t\twait;\n\tend process;\n\n") #Adding process block process=[] -process.append("\tprocess\n\n") +process.append("\tprocess\n") +process.append("\t\tvariable count : integer:=0;\n") for item in input_port: process.append("\t\tvariable "+item.split(':')[0]+"_v : VhpiString;\n") @@ -755,7 +750,6 @@ port_vector_count = 0 for item in input_port: process.append('\t\t\tobj_ref := Pack_String_To_Vhpi_String("'+item.split(':')[0]+'");\n') process.append('\t\t\tVhpi_Get_Port_Value(obj_ref,'+item.split(':')[0]+'_v,'+item.split(':')[1]+');\n') - process.append('\t\t\tassert false report "Get port value '+item.split(':')[0]+' returns " &'+item.split(':')[0]+'_v severity note;\n') if port_vector_info[port_vector_count]: process.append('\t\t\t'+item.split(':')[0]+' <= Unpack_String('+item.split(':')[0]+'_v,'+item.split(':')[1]+');\n') else: @@ -774,8 +768,10 @@ for item in output_port: process.append('\t\t\tobj_ref := Pack_String_To_Vhpi_String("'+item.split(':')[0]+'");\n') process.append('\t\t\tVhpi_Set_Port_Value(obj_ref,'+item.split(':')[0]+'_v,'+item.split(':')[1]+');\n') - process.append('\t\t\tassert false report "Set port value '+item.split(':')[0]+' returns " &'+item.split(':')[0]+'_v severity note;\n') process.append("\n") + +process.append('\t\t\treport "Iteration - "' + "& integer'image(count) severity note;\n") +process.append('\t\t\tcount := count + 1;\n') process.append("\t\tend loop;\n") process.append("\tend process;\n\n") process.append("end architecture;") diff --git a/src/ngspice_ghdl.py b/src/ngspice_ghdl.py index a4c3637..4afeef3 100755 --- a/src/ngspice_ghdl.py +++ b/src/ngspice_ghdl.py @@ -33,6 +33,7 @@ class Mainwindow(QtGui.QWidget): print fileopen.read() fileopen.close() self.file_list = [] #to keep the supporting files + self.errorFlag = False #to keep the check of "make install" errors self.initUI() def initUI(self): @@ -115,7 +116,7 @@ class Mainwindow(QtGui.QWidget): self.file_list.remove(file) if nonvhdl_count > 0: - QtGui.QMessageBox.about(self,'Message','''<b>Important Message.</b><br/><br/>Supporting files should be <b>.vhdl</b> file ''') + QtGui.QMessageBox.critical(self,'Critical','''<b>Important Message.</b><br/><br/>Supporting files should be <b>.vhdl</b> file ''') def createModelDirectory(self): @@ -128,8 +129,8 @@ class Mainwindow(QtGui.QWidget): # Looking if model directory is present or not if os.path.isdir(self.modelname): print "Model Already present" - ret = QtGui.QMessageBox.critical(self, "Critical",'''<b>The Model already exist.Do you want to overwrite it?</b><br/> - <b>If yes press ok else cancel it and change the name of you vhdl file</b>''', QtGui.QMessageBox.Ok, QtGui.QMessageBox.Cancel) + ret = QtGui.QMessageBox.warning(self, "Warning",'''<b>This model already exist. Do you want to overwrite it?</b><br/> + If yes press ok, else cancel it and change the name of your vhdl file.''', QtGui.QMessageBox.Ok, QtGui.QMessageBox.Cancel) if ret == QtGui.QMessageBox.Ok: print "Overwriting existing model "+self.modelname cmd="rm -rf "+self.modelname @@ -208,10 +209,14 @@ class Mainwindow(QtGui.QWidget): #os.remove("Vhpi_Package.vhdl") - #slot to redirect stdout to window console + #slot to redirect stdout and stderr to window console @QtCore.pyqtSlot() - def readStdOutput(self): + def readAllStandard(self): self.termedit.append(QtCore.QString(self.process.readAllStandardOutput())) + stderror = QtCore.QString(self.process.readAllStandardError()) + if stderror.contains("ERROR", QtCore.Qt.CaseInsensitive): + self.errorFlag = True + self.termedit.append(stderror) def runMake(self): @@ -224,8 +229,6 @@ class Mainwindow(QtGui.QWidget): path = os.getcwd() self.process = QtCore.QProcess(self) self.process.start(cmd) - self.process.setProcessChannelMode(QtCore.QProcess.MergedChannels) - QtCore.QObject.connect(self.process, QtCore.SIGNAL("readyReadStandardOutput()"), self, QtCore.SLOT("readStdOutput()")) print "make command process pid ---------- >",self.process.pid() except: @@ -247,8 +250,7 @@ class Mainwindow(QtGui.QWidget): self.process = QtCore.QProcess(self) self.process.start(cmd) self.process.finished.connect(self.createSchematicLib) - self.process.setProcessChannelMode(QtCore.QProcess.MergedChannels) - QtCore.QObject.connect(self.process, QtCore.SIGNAL("readyReadStandardOutput()"), self, QtCore.SLOT("readStdOutput()")) + QtCore.QObject.connect(self.process, QtCore.SIGNAL("readyReadStandardOutput()"), self, QtCore.SLOT("readAllStandard()")) os.chdir(self.cur_dir) except: @@ -258,9 +260,14 @@ class Mainwindow(QtGui.QWidget): def createSchematicLib(self): if Appconfig.esimFlag == 1: - print 'Creating library files.................................' - schematicLib = AutoSchematic(self.modelname) - schematicLib.createKicadLibrary() + if not self.errorFlag: + print 'Creating library files.................................' + schematicLib = AutoSchematic(self.modelname) + schematicLib.createKicadLibrary() + else: + QtGui.QMessageBox.critical(self,'Error','''Cannot create Schematic Library of your model. Resolve the <b>errors</b> shown on console of NGHDL window. ''') + else: + QtGui.QMessageBox.information(self,'Message','''<b>Important Message</b><br/><br/>To create Schematic Library of your model, use NGHDL through <b>eSim</b> ''') def uploadModle(self): @@ -276,15 +283,16 @@ class Mainwindow(QtGui.QWidget): print "Current Working Directory :"+self.cur_dir self.checkSupportFiles() if self.file_extension == ".vhdl": + self.errorFlag = False self.createModelDirectory() self.addingModelInModpath() self.createModelFiles() self.runMake() self.runMakeInstall() else: - QtGui.QMessageBox.about(self,'Message','''<b>Important Message.</b><br/><br/>This accepts only <b>.vhdl</b> file ''') + QtGui.QMessageBox.information(self,'Message','''<b>Important Message.</b><br/><br/>This accepts only <b>.vhdl</b> file ''') except Exception as e: - QtGui.QMessageBox.about(self, 'Message','''<b>Error</b><br/><br/> ''' + str(e)) + QtGui.QMessageBox.critical(self, 'Error', str(e)) class FileRemover(QtGui.QWidget): |