diff options
Diffstat (limited to 'src/kicadtoNgspice')
-rw-r--r-- | src/kicadtoNgspice/Convert.py | 13 | ||||
-rw-r--r-- | src/kicadtoNgspice/KicadtoNgspice.py | 47 | ||||
-rw-r--r-- | src/kicadtoNgspice/KicadtoNgspice.pyc | bin | 3987 -> 4289 bytes | |||
-rw-r--r-- | src/kicadtoNgspice/Processing.py | 98 | ||||
-rw-r--r-- | src/kicadtoNgspice/Source.py | 7 | ||||
-rw-r--r-- | src/kicadtoNgspice/TrackWidget.py | 5 |
6 files changed, 148 insertions, 22 deletions
diff --git a/src/kicadtoNgspice/Convert.py b/src/kicadtoNgspice/Convert.py index 3d45f94a..26010d9e 100644 --- a/src/kicadtoNgspice/Convert.py +++ b/src/kicadtoNgspice/Convert.py @@ -8,13 +8,12 @@ class Convert: self.entry_var = source_entry_var self.sourcelistvalue = [] - self.analysisInserter() - + def addSourceParameter(self): print "Adding Source parameter" - print "SourceListTrack : ",self.sourcelisttrack - print "Schematic Info ",self.schematicInfo - print "Entry Var",self.entry_var + #print "SourceListTrack : ",self.sourcelisttrack + #print "Schematic Info ",self.schematicInfo + #print "Entry Var",self.entry_var self.start = 0 self.end = 0 @@ -107,5 +106,5 @@ class Convert: return self.schematicInfo - def analysisInserter(self): - print "Adding Analysis"
\ No newline at end of file + def addModelParameter(self,schematicInfo): + print "Schematic info after adding source detail",schematicInfo
\ No newline at end of file diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index ecf951cd..55e6c360 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -16,7 +16,6 @@ # REVISION: --- #=============================================================================== import sys -import os from PyQt4 import QtGui,QtCore from Processing import PrcocessNetlist import Analysis @@ -32,8 +31,10 @@ class MainWindow(QtGui.QWidget): QtGui.QWidget.__init__(self) #Create object of track widget self.obj_track = TrackWidget.TrackWidget() - + print "Init Kicad to Ngspice" + #print "Current Project",sys.argv[1] + #Creating GUI for kicadtoNgspice window self.grid = QtGui.QGridLayout(self) @@ -92,7 +93,9 @@ class MainWindow(QtGui.QWidget): #Adding Source Value to Schematic Info schematicInfo = self.obj_convert.addSourceParameter() - + #print "Schematic After adding source parameter",schematicInfo + schematicInfo = self.obj_convert.addModelParameter(schematicInfo) + @@ -102,8 +105,8 @@ def main(args): print "Kicad to Ngspice netlist converter " print "==================================" global kicadFile,kicadNetlist,schematicInfo - kicadFile = "/home/fahim/eSim-Workspace/BJT_amplifier/BJT_amplifier.cir" - #kicadFile = sys.argv[1] + #kicadFile = "/home/fahim/eSim-Workspace/BJT_amplifier/BJT_amplifier.cir" + kicadFile = sys.argv[1] #Object of Processing obj_proc = PrcocessNetlist() @@ -127,32 +130,54 @@ def main(args): print "SCHEMATICINFO",schematicInfo #Getting model and subckt list - modelList=[] + devicemodelList=[] subcktList=[] - modelList,subcktList = obj_proc.getModelSubcktList(schematicInfo,modelList,subcktList) + devicemodelList,subcktList = obj_proc.getModelSubcktList(schematicInfo,devicemodelList,subcktList) - print "MODEL LIST ",modelList + print "MODEL LIST ",devicemodelList print "SUBCKT ",subcktList #List for storing source and its value global sourcelist, sourcelisttrack sourcelist=[] sourcelisttrack=[] - schematicInfo,sourcelist=obj_proc.insertSpecialSourceParam(schematicInfo,sourcelist) + schematicInfo,sourcelist = obj_proc.insertSpecialSourceParam(schematicInfo,sourcelist) print "SOURCELIST",sourcelist print "SCHEMATICINFO",schematicInfo - - + #List storing model detail + global modelList,outputOption + modelList = [] + outputOption = [] + schematicInfo,outputOption,modelList,unknownModelList,multipleModelList = obj_proc.convertICintoBasicBlocks(schematicInfo,outputOption,modelList) + print "Unknown Model List",unknownModelList + print "Multple Model List",multipleModelList + + + + #Checking for unknown Model List and Multiple Model List + if unknownModelList: + print "ErrorMessage : These Models are not available.Please check it",unknownModelList + sys.exit(2) + else: + if multipleModelList: + print "ErrorMessage: There are multiple model for same name. Please check it",multipleModelList + sys.exit(2) + else: + pass + app = QtGui.QApplication(args) #app.setApplicationName("KicadToNgspice") #app.setQuitOnLastWindowClosed(True) kingWindow = MainWindow() kingWindow.show() sys.exit(app.exec_()) + + + if __name__ == '__main__': main(sys.argv) diff --git a/src/kicadtoNgspice/KicadtoNgspice.pyc b/src/kicadtoNgspice/KicadtoNgspice.pyc Binary files differindex ece6486f..5a3f1e57 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.pyc +++ b/src/kicadtoNgspice/KicadtoNgspice.pyc diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index 4dee9446..3a2bcb37 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -1,8 +1,14 @@ +import sys +import os +from xml.etree import ElementTree as ET + + class PrcocessNetlist: + modelxmlDIR = '../modelParamXML' def __init__(self): pass - + def readNetlist(self,filename): f = open(filename) data=f.read() @@ -92,13 +98,18 @@ class PrcocessNetlist: modelName=words[4] index=schematicInfo.index(eachline) schematicInfo.remove(eachline) + ''' width=raw_input(' Enter width of mosfet '+words[0]+'(default=100u):') length=raw_input(' Enter length of mosfet '+words[0]+'(default=100u):') multiplicative_factor=raw_input(' Enter multiplicative factor of mosfet '+words[0]+'(default=1):') + if width=="": width="100u" if multiplicative_factor=="": multiplicative_factor="100u" if length=="": length="100u" schematicInfo.insert(index,words[0]+" "+words[1]+" "+words[2]+" "+words[3]+" "+words[3]+" "+words[4]+" "+'M='+multiplicative_factor+" "+'L='+length+" "+'W='+width) + ''' + + schematicInfo.insert(index,words[0]+" "+words[1]+" "+words[2]+" "+words[3]+" "+words[3]+" "+words[4]) if modelName in modelList: continue modelList.append(modelName) @@ -191,4 +202,89 @@ class PrcocessNetlist: return schematicInfo,sourcelist + def convertICintoBasicBlocks(self,schematicInfo,outputOption,modelList): + #Insert details of Ngspice model + unknownModelList = [] + multipleModelList = [] + k = 1 + for compline in schematicInfo: + words = compline.split() + compName = words[0] + # Find the IC from schematic + if compName[0]=='u': + # Find the component from the circuit + index=schematicInfo.index(compline) + compType=words[len(words)-1]; + schematicInfo.remove(compline) + print "Compline",compline + print "CompType",compType + print "Words",words + print "compName",compName + #Looking if model file is present + xmlfile = compType+".xml" #XML Model File + count = 0 #Check if model of same name is present + modelPath = [] + all_dir = [x[0] for x in os.walk(PrcocessNetlist.modelxmlDIR)] + for each_dir in all_dir: + all_file = os.listdir(each_dir) + if xmlfile in all_file: + count += 1 + modelPath.append(os.path.join(each_dir,xmlfile)) + + if count > 1: + multipleModelList.append(modelPath) + elif count == 0: + unknownModelList.append(compType) + elif count == 1: + try: + tree = ET.parse(modelPath[0]) + #root = parsemodel.getroot() + for child in tree.iter(): + print "Child Item",child + #print "Tag",child.tag + #print "Tag Value",child.text + + except: + print "Unable to parse the model, Please check your your xml file" + sys.exit(2) + + #print "Count",count + #print "UnknownModelList",unknownModelList + #print "MultipleModelList",multipleModelList + ''' + if compType=="gain": + schematicInfo.append("a"+str(k)+" "+words[1]+" "+words[2]+" "+compName) + k=k+1 + #Insert comment at remove line + schematicInfo.insert(index,"* "+compline) + print "-----------------------------------------------------------\n" + print "Adding Gain" + Comment='* Gain '+compType + Title='Add parameters for Gain '+compName + in_offset=' Enter offset for input (default=0.0): ' + gain=' Enter gain (default=1.0): ' + out_offset=' Enter offset for output (default=0.0): ' + print "-----------------------------------------------------------" + modelList.append([index,compline,compType,compName,Comment,Title,in_offset,gain,out_offset]) + elif compType=="summer": + schematicInfo.append("a"+str(k)+" ["+words[1]+" "+words[2]+"] "+words[3]+" "+compName) + k=k+1 + #Insert comment at remove line + schematicInfo.insert(index,"* "+compline) + print "-----------------------------------------------------------\n" + print "Adding summer" + Comment='* Summer '+compType + Title='Add parameters for Summer '+compName + in1_offset=' Enter offset for input 1 (default=0.0): ' + in2_offset=' Enter offset for input 2 (default=0.0): ' + in1_gain=' Enter gain for input 1 (default=1.0): ' + in2_gain=' Enter gain for input 2 (default=1.0): ' + out_gain=' Enter gain for output (default=1.0): ' + out_offset=' Enter offset for output (default=0.0): ' + print "-----------------------------------------------------------" + modelList.append([index,compline,compType,compName,Comment,Title,in1_offset,in2_offset,in1_gain,in2_gain,out_gain,out_offset]) + ''' + return schematicInfo,outputOption,modelList,unknownModelList,multipleModelList + +
\ No newline at end of file diff --git a/src/kicadtoNgspice/Source.py b/src/kicadtoNgspice/Source.py index 657a980c..ee460cb0 100644 --- a/src/kicadtoNgspice/Source.py +++ b/src/kicadtoNgspice/Source.py @@ -16,6 +16,7 @@ class Source(QtGui.QWidget): self.end = 0 self.row = 0 self.entry_var = {} + #self.font = QtGui.QFont("Times",20,QtGui.QFont.Bold,True) #Creating Source Widget self.createSourceWidget(sourcelist,sourcelisttrack) @@ -41,6 +42,7 @@ class Source(QtGui.QWidget): label=QtGui.QLabel(line[4]) self.grid.addWidget(label,self.row,0) self.entry_var[self.count]=QtGui.QLineEdit() + self.entry_var[self.count].setMaximumWidth(150) self.grid.addWidget(self.entry_var[self.count],self.row,1) #Value Need to check previuouse value self.entry_var[self.count].setText("") @@ -57,6 +59,7 @@ class Source(QtGui.QWidget): label=QtGui.QLabel(line[4]) self.grid.addWidget(label,self.row,0) self.entry_var[self.count]=QtGui.QLineEdit() + self.entry_var[self.count].setMaximumWidth(150) self.grid.addWidget(self.entry_var[self.count],self.row,1) self.entry_var[self.count].setText("") self.row=self.row+1 @@ -74,6 +77,7 @@ class Source(QtGui.QWidget): label=QtGui.QLabel(line[it]) self.grid.addWidget(label,self.row,0) self.entry_var[self.count]=QtGui.QLineEdit() + self.entry_var[self.count].setMaximumWidth(150) self.grid.addWidget(self.entry_var[self.count],self.row,1) self.entry_var[self.count].setText("") self.row=self.row+1 @@ -90,6 +94,7 @@ class Source(QtGui.QWidget): label=QtGui.QLabel(line[it]) self.grid.addWidget(label,self.row,0) self.entry_var[self.count]=QtGui.QLineEdit() + self.entry_var[self.count].setMaximumWidth(150) self.grid.addWidget(self.entry_var[self.count],self.row,1) self.entry_var[self.count].setText("") self.row=self.row+1 @@ -105,6 +110,7 @@ class Source(QtGui.QWidget): label=QtGui.QLabel(line[4]) self.grid.addWidget(label,self.row,0) self.entry_var[self.count]=QtGui.QLineEdit() + self.entry_var[self.count].setMaximumWidth(150) self.grid.addWidget(self.entry_var[self.count],self.row,1) self.entry_var[self.count].setText(""); self.row=self.row+1 @@ -121,6 +127,7 @@ class Source(QtGui.QWidget): label=QtGui.QLabel(line[it]) self.grid.addWidget(label,self.row,0) self.entry_var[self.count]=QtGui.QLineEdit() + self.entry_var[self.count].setMaximumWidth(150) self.grid.addWidget(self.entry_var[self.count],self.row,1) self.entry_var[self.count].setText("") self.row=self.row+1 diff --git a/src/kicadtoNgspice/TrackWidget.py b/src/kicadtoNgspice/TrackWidget.py index 0b11d938..1c600d79 100644 --- a/src/kicadtoNgspice/TrackWidget.py +++ b/src/kicadtoNgspice/TrackWidget.py @@ -1,9 +1,8 @@ class TrackWidget: """ This Class track the widget of Kicad to NgSpice converter - module in the form of list + module. """ sourcelisttrack = {"ITEMS":"None"} source_entry_var = {"ITEMS":"None"} - analysis_entry_var = {"ITEMS":"NONE"} - analysis_type = {"ITEMS":"NONE"}
\ No newline at end of file +
\ No newline at end of file |