def parseCCCS_F(stringCCCS=''): CCCSList = stringCCCS.split() if len(CCCSList) > 6: print("Error! More parameters than expected!") elif len(CCCSList) < 6: print("Error! Less parameters than expected!") else: cccsTemp = cccs() cccsTemp.name = CCCSList[0] cccsTemp.portPos = CCCSList[1] cccsTemp.portNeg = CCCSList[2] cccsTemp.ctlNodePos = CCCSList[3] cccsTemp.ctlNodeNeg = CCCSList[4] cccsTemp.currentGain = CCCSList[5] addNode(cccsTemp.portPos) addNode(cccsTemp.portNeg) parameters.listF.append(cccsTemp) #FkValue = string2num(cccsTemp.currentGain) #print('\t',cccsTemp.portPos,'\t',cccsTemp.portNeg,'\t',cccsTemp.ctlNodePos,'\t',cccsTemp.ctlNodeNeg,'\t','i') #print(cccsTemp.portPos,'\t',0,'\t',0,'\t',0,'\t',0,'\t',FkValue) #print(cccsTemp.portNeg,'\t',0,'\t',0,'\t',0,'\t',0,'\t',-1*FkValue) #print(cccsTemp.ctlNodePos,'\t',0,'\t',0,'\t',0,'\t',0,'\t',1) #print(cccsTemp.ctlNodeNeg,'\t',0,'\t',0,'\t',0,'\t',0,'\t',-1) #print('br\t',0,'\t',0,'\t',1,'\t',-1,'\t',0)
def parseVCCS_G(stringVCCS=''): VCCSList = stringVCCS.split() if len(VCCSList) > 6: print("Error! More parameters than expected!") elif len(VCCSList) < 6: print("Error! Less parameters than expected!") else: vccsTemp = vccs() vccsTemp.name = VCCSList[0] vccsTemp.portPos = VCCSList[1] vccsTemp.portNeg = VCCSList[2] vccsTemp.ctlNodePos = VCCSList[3] vccsTemp.ctlNodeNeg = VCCSList[4] vccsTemp.transconValue = VCCSList[5] addNode(vccsTemp.portPos) addNode(vccsTemp.portNeg) parameters.listG.append(vccsTemp) #value = string2num(vccsTemp.transconValue) #print('\t',vccsTemp.ctlNodePos,'\t',vccsTemp.ctlNodeNeg) #print(vccsTemp.portPos,'\t',value,'\t',value*(-1)) #print(vccsTemp.portNeg,'\t',value*(-1),'\t',value) #print('')
def parseDiode(stringDiode = ''): DiodeList = stringDiode.split() if len(DiodeList) > 6: print("****Error! More parameters than EXPECTED!") elif len(DiodeList) < 6: print("****Error! Less parameters than EXPECTED!") else: DiodeTemp = Diode() DiodeTemp.name = DiodeList[0] DiodeTemp.port1 = DiodeList[1] DiodeTemp.port2 = DiodeList[2] DiodeTemp.Model = DiodeList[3] ITemp = 4 while ITemp < len(DiodeList): if '=' in DiodeList[ITemp]: DiodeValTemp = DiodeList[ITemp].split('=') if DiodeValTemp[0] == 'is': DiodeTemp.Isat = DiodeValTemp[1] elif DiodeValTemp[0] == 'alpha': DiodeTemp.Alpha = DiodeValTemp[1] else : print("****Error! Unknow parameter NAME",DiodeValTemp[0]) ITemp = ITemp + 1 else: print("****Error! Unknow parameter NAME",DiodeList[ITemp]) exit() parameters.listD.append(DiodeTemp) addNode(DiodeTemp.port1) addNode(DiodeTemp.port2) return DiodeTemp
def parseIs(IsString=''): IsParaList = IsString.split(' ') if len(IsParaList) > 4: print('----ERROR: More parameters than expected!') return '----False' elif len(IsParaList) < 4: print('----ERROR: Less parameters than expected!') return '----False' else: IsTemp = DCCurrent() IsTemp.name = IsParaList[0] IsTemp.portPos = IsParaList[1] IsTemp.portNeg = IsParaList[2] IsTemp.value = IsParaList[3] value = string2num(IsTemp.value) addNode(IsTemp.portPos) addNode(IsTemp.portNeg) parameters.listDCI.append(IsTemp) print('\t RHS') print(IsTemp.portPos, '\t', -1 * value) print(IsTemp.portNeg, '\t', value) print('') return IsTemp return ''
def parseR(resString =''): #parse Resistor resParaList = resString.split(' ') if len(resParaList) > 4: print('----ERROR: More parameters than expected!') return '----False' elif len(resParaList) < 4: print('----ERROR: Lese parameters than expected!') return '----False' else: resistorTemp = Resistor() resistorTemp.name = resParaList[0] resistorTemp.port1 = resParaList[1] resistorTemp.port2 = resParaList[2] resistorTemp.value = resParaList[3] #value = string2num(resistorTemp.value) addNode(resistorTemp.port1) addNode(resistorTemp.port2) parameters.listR.append(resistorTemp) #print('\t',resistorTemp.port1,'\t',resistorTemp.port2,'\t') #print(resistorTemp.port1,' ',1/value,' \t',-1/value) #print(resistorTemp.port2,' ',-1/value,' \t',1/value) #print('') return resistorTemp return ''
def parseVCVS_E(stringVCVS=''): VCVSList = stringVCVS.split() if len(VCVSList) > 6: print("Error! More parameters than expected!") elif len(VCVSList) < 6: print("Error! Less parameters than expected!") else: vcvsTemp = vcvs() vcvsTemp.name = VCVSList[0] vcvsTemp.portPos = VCVSList[1] vcvsTemp.portNeg = VCVSList[2] vcvsTemp.ctlNodePos = VCVSList[3] vcvsTemp.ctlNodeNeg = VCVSList[4] vcvsTemp.voltageGain = VCVSList[5] addNode(vcvsTemp.portPos) addNode(vcvsTemp.portNeg) parameters.listE.append(vcvsTemp)
def parseC(capString=''): capParaList = capString.split(' ') if len(capParaList) > 4: print('ERROR: More parameters than expected!') exit() #return '----False' elif len(capParaList) < 4: print('ERROR: Less parameters than expected!') exit() #return '----False' else: capacitorTemp = Capacitor() capacitorTemp.name = capParaList[0] capacitorTemp.port1 = capParaList[1] capacitorTemp.port2 = capParaList[2] capacitorTemp.value = capParaList[3] addNode(capacitorTemp.port1) addNode(capacitorTemp.port2) parameters.listC.append(capacitorTemp)
def parseInductor(IndString = ''): IndParaList = IndString.split(' ') if len(IndParaList) > 4: print('----ERROR: More parameters than expected!') return '----False' elif len(IndParaList) < 4: print('----ERROR: Less parameters than expected!') return '----False' else : InductorTemp = Inductor() InductorTemp.name = IndParaList[0] InductorTemp.port1 = IndParaList[1] InductorTemp.port2 = IndParaList[2] InductorTemp.value = IndParaList[3] addNode(InductorTemp.port1) addNode(InductorTemp.port2) parameters.listL.append(InductorTemp) value = string2num(InductorTemp.value) #print("--AC stamp") #print('\t|',InductorTemp.port1,'\t|',InductorTemp.port2, '\t| I', '\t\t| RHS') #print(InductorTemp.port1,'\t|',0,'\t|',0,'\t|',1,'\t\t|',0) #print(InductorTemp.port2,'\t|',0,'\t|',0,'\t|',-1,'\t\t|',0) #print('branch','\t|',1,'\t|',-1,'\t|',-1*value,'s','\t|',0) #rint '' #print('\t',InductorTemp.port1,'\t',InductorTemp.port2,'\t') #print(InductorTemp.port1,' ',1/value,' \t',-1/value) #print(InductorTemp.port2,' ',-1/value,' \t',1/value) #print('') return InductorTemp return ''
def parseMosfet(mosString = ''): mosParaList = mosString.split(' ') if len(mosParaList) > 8: print('ERROR: More parameters than expected!') exit() elif len(mosParaList) < 8: print('ERROR: Less parameters than expected!') exit() else: MosfetTemp = Mosfet() MosfetTemp.name = mosParaList[0] MosfetTemp.portD = mosParaList[1] MosfetTemp.portG = mosParaList[2] MosfetTemp.portS = mosParaList[3] MosfetTemp.portB = mosParaList[4] MosfetTemp.valueL = mosParaList[6].split('=')[1] MosfetTemp.valueW = mosParaList[7].split('=')[1] addNode(MosfetTemp.portB) addNode(MosfetTemp.portD) addNode(MosfetTemp.portG) addNode(MosfetTemp.portS) if mosParaList[5] == 'nmos': MosfetTemp.MosType = 'nmos' print('Info: --Type: nmos') elif mosParaList[5] == 'pmos': MosfetTemp.MosType = 'pmos' print('Info: --Type: pmos') else : print('Error: Error mosfet TYPE!',mosParaList[5]) exit() parameters.listM.append(MosfetTemp)
def parsePower(powString = ''): powParaList = powString.split(' ') if len(powParaList) < 4: print('----ERROR: Less parameters than expected!') return '----False' elif 'sin' in powParaList: SinPowerTemp = SinPower() SinPowerTemp.name = powParaList[0] SinPowerTemp.portPos = powParaList[1] SinPowerTemp.portNeg = powParaList[2] addrTemp = 4 while addrTemp < len(powParaList): if '=' in powParaList[addrTemp]: paraTempList = powParaList[addrTemp].split('=') if paraTempList[0] == 'a': SinPowerTemp.A = paraTempList[1] elif paraTempList[0] == 'w': SinPowerTemp.w = paraTempList[1] elif paraTempList[0] == 'phi': SinPowerTemp.phi = paraTempList[1] elif paraTempList[0] == 'vo': SinPowerTemp.Vo = paraTempList[1] else: print("****Error! Unknow parameter : ",paraTempList[0]) else: if addrTemp == 4 : SinPowerTemp.A = powParaList[addrTemp] elif addrTemp == 5: SinPowerTemp.w = powParaList[addrTemp] elif addrTemp == 6: SinPowerTemp.phi = powParaList[addrTemp] elif addrTemp == 7: SinPowerTemp.Vo = powParaList[addrTemp] else: print(powParaList[addrTemp],"is Unexpected! It will be Ignored!") pass addrTemp = addrTemp + 1 addNode(SinPowerTemp.portPos) addNode(SinPowerTemp.portNeg) parameters.listSinV.append(SinPowerTemp) elif 'pluse' in powParaList: plusePowerTemp = PlusePower() plusePowerTemp.name = powParaList[0] plusePowerTemp.portPos = powParaList[1] plusePowerTemp.portNeg = powParaList[2] addrTemp = 4 while addrTemp < len(powParaList): if '=' in powParaList[addrTemp]: paraTempList = powParaList[addrTemp].split('=') if paraTempList[0] == 'tdelay' | paraTempList[0] == 'td': plusePowerTemp.Tdelay = paraTempList[1] elif paraTempList[0] == 'lowv' | paraTempList[0] == 'lv': plusePowerTemp.LowVoltage = paraTempList[1] elif paraTempList[0] == 'highv' | paraTempList[0] == 'hv': plusePowerTemp.HighVoltage = paraTempList[1] elif paraTempList[0] == 'trise' | paraTempList[0] == 'tr': plusePowerTemp.Trise = paraTempList[1] elif paraTempList[0] == 'tfall' | paraTempList[0] == 'tf': plusePowerTemp.Tfall = paraTempList[1] elif paraTempList[0] == 'twide' | paraTempList[0] == 'tw': plusePowerTemp.Twide = paraTempList[1] elif paraTempList[0] == 'tperiod' | paraTempList[0] == 'tp': plusePowerTemp.Tperiod = paraTempList[1] else: print("****Error! Unknow parameter : ",paraTempList[0]) else: if addrTemp == 4 : plusePowerTemp.LowVoltage = powParaList[addrTemp] elif addrTemp == 5: plusePowerTemp.HighVoltage = powParaList[addrTemp] elif addrTemp == 6: plusePowerTemp.Tdelay = powParaList[addrTemp] elif addrTemp == 7: plusePowerTemp.Trise = powParaList[addrTemp] elif addrTemp == 8: plusePowerTemp.Tfall = powParaList[addrTemp] elif addrTemp == 9: plusePowerTemp.Twide = powParaList[addrTemp] elif addrTemp == 10: plusePowerTemp.Tperiod = powParaList[addrTemp] else: print(powParaList[addrTemp],"is Unexpected! It will be Ignored!") pass addrTemp = addrTemp + 1 addNode(plusePowerTemp.portPos) addNode(plusePowerTemp.portNeg) parameters.listPulseV.append(plusePowerTemp) elif len(powParaList) == 4: dcpowerTemp = DCPower() dcpowerTemp.name = powParaList[0] dcpowerTemp.portPos = powParaList[1] dcpowerTemp.portNeg = powParaList[2] if '=' in powParaList[3]: paraTempList = powParaList[3].split('=') if(paraTempList[0] == 'dc'): dcpowerTemp.value = paraTempList[1] else: dcpowerTemp.value = powParaList[3] addNode(dcpowerTemp.portPos) addNode(dcpowerTemp.portNeg) parameters.listDCV.append(dcpowerTemp) #value = string2num(powerTemp.value) #print('\t',powerTemp.portPos,'\t',powerTemp.portNeg,'\t','i','\t','RHS') #print(powerTemp.portPos,'\t',0,'\t',0,'\t',1,'\t',0) #print(powerTemp.portNeg,'\t',0,'\t',0,'\t',-1,'\t',0) #print('branch\t',1,'\t',-1,'\t',0,'\t',value ) else: print('****ERROR! Wrong expression of Power: ') print(' ', powString) return '----False' return ''