diff options
-rwxr-xr-x | src/kicadtoNgspice/Convert.py | 44 | ||||
-rwxr-xr-x | src/kicadtoNgspice/DeviceModel.py | 36 |
2 files changed, 38 insertions, 42 deletions
diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py index c1209cd3..566182e0 100755 --- a/src/kicadtoNgspice/Convert.py +++ b/src/kicadtoNgspice/Convert.py @@ -525,47 +525,40 @@ class Convert: # print("Library Path :", libpath) # Copying library from devicemodelLibrary to Project Path # Special case for MOSFET - print(eachline[0:5]) + tempStr = libname.split(':') + libname = tempStr[0] + libAbsPath = os.path.join(libpath, libname) + if eachline[0] == 'm': # For mosfet library name come along with MOSFET # dimension information - tempStr = libname.split(':') - libname = tempStr[0] dimension = tempStr[1] # Replace last word with library name # words[-1] = libname.split('.')[0] - words[-1] = self.getRefrenceName(libname, libpath) + words[-1] = self.getReferenceName(libname, libpath) # Appending Dimension of MOSFET words.append(dimension) deviceLine[index] = words includeLine.append(".include " + libname) - # src = completeLibPath.split(':')[0] # <----- Not - # working in Windows - - (src_path, src_lib) = os.path.split(completeLibPath) - src_lib = src_lib.split(':')[0] - src = os.path.join(src_path, src_lib) - dst = projpath - shutil.copy2(src, dst) + shutil.copy2(libAbsPath, projpath) elif eachline[0:6] == 'scmode': (filepath, filemname) = os.path.split(self.clarg1) self.Fileopen = os.path.join(filepath, ".spiceinit") - print("======================================================") - print("Writing to the .spiceinit file to make ngspice SKY130 compatible") + print("==============================================") + print("Writing to the .spiceinit file to " + + "make ngspice SKY130 compatible") self.writefile = open(self.Fileopen, "w") self.writefile.write(''' set ngbehavior=hsa ; set compatibility for reading PDK libs -set ng_nomodcheck ; don't check the model parameters +set ng_nomodcheck ; don't check the model parameters set num_threads=8 ; CPU hardware threads available option noinit ; don't print operating point data optran 0 0 0 100p 2n 0 ; don't use dc operating point, but transient op) ''') - print("======================================================") + print("==============================================") - tempStr = completeLibPath.split(':') - print(tempStr) libs = ''' sky130_fd_pr__model__diode_pd2nw_11v0.model.spice sky130_fd_pr__model__diode_pw2nd_11v0.model.spice @@ -575,31 +568,28 @@ sky130_fd_pr__model__pnp.model.spice sky130_fd_pr__model__r+c.model.spice ''' includeLine.append( - ".lib \"" + tempStr[0] + "\" " + tempStr[1]) + ".lib \"" + libAbsPath + "\" " + tempStr[1]) for i in libs.split(): includeLine.append( - ".include \"" + tempStr[0].replace( + ".include \"" + libAbsPath.replace( "sky130.lib.spice", i) + "\"") deviceLine[index] = "*scmode" # words.append(completeLibPath) # deviceLine[index] = words elif eachline[0:2] == 'sc' and eachline[0:6] != 'scmode': - temp_str = words[0].replace('sc', 'xsc') - words[0] = temp_str + words[0] = words[0].replace('sc', 'xsc') words.append(completeLibPath) deviceLine[index] = words else: # Replace last word with library name # words[-1] = libname.split('.')[0] - words[-1] = self.getRefrenceName(libname, libpath) + words[-1] = self.getReferenceName(libname, libpath) deviceLine[index] = words includeLine.append(".include " + libname) - src = completeLibPath - dst = projpath - shutil.copy2(src, dst) + shutil.copy2(completeLibPath, projpath) # Adding device line to schematicInfo for index, value in deviceLine.items(): @@ -673,7 +663,7 @@ sky130_fd_pr__model__r+c.model.spice return schematicInfo - def getRefrenceName(self, libname, libpath): + def getReferenceName(self, libname, libpath): libname = libname.replace('.lib', '.xml') library = os.path.join(libpath, libname) diff --git a/src/kicadtoNgspice/DeviceModel.py b/src/kicadtoNgspice/DeviceModel.py index 630ec41f..0967333c 100755 --- a/src/kicadtoNgspice/DeviceModel.py +++ b/src/kicadtoNgspice/DeviceModel.py @@ -77,7 +77,6 @@ class DeviceModel(QtWidgets.QWidget): self.count = self.count+1 self.row = self.row + 1 self.devicemodel_dict_beg["scmode1"] = self.count - i = self.count beg = self.count self.deviceDetail[self.count] = "scmode1" sky130box.setTitle("Add parameters of SKY130 library ") @@ -88,9 +87,7 @@ class DeviceModel(QtWidgets.QWidget): self.row = self.row + 1 sky130grid.addWidget(self.parameterLabel[self.count], self.row, 0) self.entry_var[self.count] = QtWidgets.QLineEdit() - init_path = '../../' - if os.name == 'nt': - init_path = '' + self.entry_var[self.count].setReadOnly(True) for child in self.root: if child.tag == "scmode1": @@ -100,9 +97,16 @@ class DeviceModel(QtWidgets.QWidget): .setText(child[0].text) path_name = child[0].text else: - path_name = os.path.abspath( - init_path + "library/deviceModelLibrary/\ -sky130_fd_pr/models/sky130.lib.spice") + if os.name == 'nt': + path_name = os.path.abspath( + "library/" + + "sky130_fd_pr/models/sky130.lib.spice" + ) + else: + path_name = os.path.abspath( + "/usr/share/local/" + + "sky130_fd_pr/models/sky130.lib.spice" + ) self.entry_var[self.count].setText(path_name) # self.trackLibraryWithoutButton(self.count, path_name) @@ -186,7 +190,6 @@ sky130_fd_pr/models/sky130.lib.spice") self.deviceDetail[self.count] = words[0] sky130box = QtWidgets.QGroupBox() sky130grid = QtWidgets.QGridLayout() - i = self.count beg = self.count sky130box.setTitle( "Add parameters for " + @@ -533,14 +536,18 @@ sky130_fd_pr/models/sky130.lib.spice") self.show() def trackDefaultLib(self): - init_path = '../../' - if os.name == 'nt': - init_path = '' sending_btn = self.sender() self.widgetObjCount = int(sending_btn.objectName()) - path_name = os.path.abspath( - init_path + "library/deviceModelLibrary/sky130_fd_pr\ -/models/sky130.lib.spice") + if os.name == 'nt': + path_name = os.path.abspath( + "library/" + + "sky130_fd_pr/models/sky130.lib.spice" + ) + else: + path_name = os.path.abspath( + "/usr/share/local/" + + "sky130_fd_pr/models/sky130.lib.spice" + ) self.entry_var[self.widgetObjCount].setText(path_name) self.trackLibraryWithoutButton(self.widgetObjCount, path_name) @@ -802,4 +809,3 @@ Converter developed at FOSSEE, IIT Bombay\n") self.msg.showMessage(self.content) self.msg.exec_() return - |