diff options
Diffstat (limited to 'src/kicadtoNgspice/Processing.py')
-rw-r--r-- | src/kicadtoNgspice/Processing.py | 116 |
1 files changed, 97 insertions, 19 deletions
diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index 63847761..ebbd3429 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -5,23 +5,35 @@ from xml.etree import ElementTree as ET class PrcocessNetlist: """ - This class include all the function required for pre-proccessing of netlist - before converting to Ngspice Netlist. + - This class include all the function required for pre-proccessing of + netlist before converting to Ngspice Netlist. """ modelxmlDIR = '../modelParamXML' def __init__(self): pass + """ + - Read the circuit file and return splitted lines + """ def readNetlist(self, filename): f = open(filename) data = f.read() f.close() + print("=============================================================") + print("readNetList called, from Processing") + print("=============================================================") + print("NETLIST", data.splitlines()) + print("=============================================================") return data.splitlines() + """ + - Read Parameter information and store it into dictionary + - kicadNetlis is the .cir file content + """ def readParamInfo(self, kicadNetlis): - """Read Parameter information and store it into dictionary""" param = {} + print("=========================KICADNETLIST========================") for eachline in kicadNetlis: print(eachline) eachline = eachline.strip() @@ -32,10 +44,18 @@ class PrcocessNetlist: for i in range(1, len(words), 1): paramList = words[i].split('=') param[paramList[0]] = paramList[1] + print("=============================================================") + print("readParamInfo called, from Processing") + print("=============================================================") + print("PARAM", param) + print("=============================================================") return param + """ + - Preprocess netlist (replace parameters) + - Separate infoline (first line) from the rest of netlist + """ def preprocessNetlist(self, kicadNetlis, param): - """Preprocess netlist (replace parameters)""" netlist = [] for eachline in kicadNetlis: # Remove leading and trailing blanks spaces from line @@ -66,9 +86,22 @@ class PrcocessNetlist: # Copy information line infoline = netlist[0] netlist.remove(netlist[0]) + print("=============================================================") + print("preprocessNetList called, from Processing") + print("=============================================================") + print("NETLIST", netlist) + print("INFOLINE", infoline) + print("=============================================================") return netlist, infoline def separateNetlistInfo(self, netlist): + """ + - Remove the options such as .end, .param, starting wtih "." + from the netlist file + - This is stored as option info, whereas rest is stored as + schematicInfo + - Rest from the `* Sheet Name:` line stored as schematicInfo + """ optionInfo = [] schematicInfo = [] for eachline in netlist: @@ -78,14 +111,25 @@ class PrcocessNetlist: optionInfo.append(eachline) else: schematicInfo.append(eachline) + print("=============================================================") + print("separateNetlistInfo called, from Processing") + print("=============================================================") + print("OPTIONINFO", optionInfo) + print("SCHEMATICINFO", schematicInfo) + print("=============================================================") return optionInfo, schematicInfo + """ + - Insert Special source parameter + - As per the parameters passed create source list, start with v or i + - Then check for type whether ac, dc, sine, etc... + - Handle starting with h and f as well + """ def insertSpecialSourceParam(self, schematicInfo, sourcelist): - # Inser Special source parameter schematicInfo1 = [] - + print("=============================================================") print("Reading schematic info for source details") - + print("=============================================================") for compline in schematicInfo: words = compline.split() compName = words[0] @@ -171,10 +215,27 @@ class PrcocessNetlist: schematicInfo = schematicInfo + schematicInfo1 print("Source List : ", sourcelist) # print schematicInfo + print("=============================================================") + print("insertSpecialSourceParam called, from Processing") + print("=============================================================") + print("SCHEMATICINFO", schematicInfo) + print("SOURCELIST", sourcelist) + print("=============================================================") return schematicInfo, sourcelist def convertICintoBasicBlocks( self, schematicInfo, outputOption, modelList, plotText): + """ + - Parses the schematicInfo and returns + - - SchematicInfo + - - Output Option + - - Model List + - - Unkown Model List + - - Multiple Model List + - - Plot text + - Parsing info is provided below + """ + print("=============================================================") print("Reading Schematic info for Model") # Insert details of Ngspice model unknownModelList = [] @@ -228,6 +289,8 @@ class PrcocessNetlist: unknownModelList.append(compType) elif count == 1: try: + print("==========================================\ + ===========================") print( "Start Parsing Previous Values XML\ for ngspice model :", modelPath) @@ -265,7 +328,7 @@ class PrcocessNetlist: if 'default' in item.attrib: paramDict[item.tag + ":" + item.attrib['default']] \ - = temp_list + = temp_list else: paramDict[item.tag] = item.text @@ -273,7 +336,7 @@ class PrcocessNetlist: if 'default' in item.attrib: paramDict[item.tag + ":" + item.attrib['default']]\ - = item.text + = item.text else: paramDict[item.tag] = item.text @@ -288,6 +351,8 @@ class PrcocessNetlist: modelLine += compName else: + print("=====================================\ + ================================") print("Split Details :", splitDetail) modelLine = "a" + str(k) + " " vectorDetail = splitDetail.split(':') @@ -302,7 +367,7 @@ class PrcocessNetlist: for i in range(0, int( item.split("-")[0])): modelLine += words[pos] +\ - " " + " " pos += 1 modelLine += ") " else: @@ -310,7 +375,7 @@ class PrcocessNetlist: for i in range(0, int( item.split("-")[0])): modelLine += words[pos] + \ - " " + " " pos += 1 modelLine += "] " elif item.split("-")[1] == 'NV': @@ -376,8 +441,8 @@ class PrcocessNetlist: words = compline.split() # Adding zero voltage source to netlist schematicInfo.append( - "v_" + words[0] + " " - + words[1] + " " + words[2] + " " + "0") + "v_" + words[0] + " " + + words[1] + " " + words[2] + " " + "0") plotText.append("plot i(v_" + words[0] + ")") elif compType == 'plot_log': words = compline.split() @@ -393,9 +458,11 @@ class PrcocessNetlist: schematicInfo.insert(index, "* " + compline) # For Primary Couple - modelLine = "a" + str(k) - + " (" + words[1] + " " + words[2] + ") (interNode_" + str( - interMediateNodeCount) + " " + words[3] + ") " + modelLine = ( + "a" + str(k) + " (" + words[1] + " " + + words[2] + ") (interNode_" + + str(interMediateNodeCount) + " " + words[3] + ") " + ) modelLine += compName + "_primary" schematicInfo.append(modelLine) k = k + 1 @@ -436,16 +503,27 @@ class PrcocessNetlist: else: schematicInfo.insert(index, "* " + compline) - + print("=====================================================") print( "UnknownModelList Used in the Schematic", unknownModelList) + print("=====================================================") print( "Multiple Model XML file with same name ", multipleModelList) + print("=====================================================") print("Model List Details : ", modelList) - + print("=============================================================") + print("convertICIntoBasicBlocks called, from Processing") + print("=============================================================") + print("SCHEMATICINFO", schematicInfo) + print("OUTPUTOPTION", outputOption) + print("MODELLIST", modelList) + print("UNKOWNMODELLIST", unknownModelList) + print("MULTIPLEMODELLIST", multipleModelList) + print("PLOTTEST", plotText) + print("=============================================================") return ( schematicInfo, outputOption, modelList, unknownModelList, multipleModelList, plotText - ) + ) |