From 2da39e40d6047b23ee8a2fc6885fb241a7517632 Mon Sep 17 00:00:00 2001 From: takez Date: Mon, 7 Apr 2025 05:21:30 +0900 Subject: [PATCH 1/2] update qspice.py --- src/PyQSPICE/qspice.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PyQSPICE/qspice.py b/src/PyQSPICE/qspice.py index 4219d07..88aaf07 100644 --- a/src/PyQSPICE/qspice.py +++ b/src/PyQSPICE/qspice.py @@ -188,6 +188,7 @@ def LoadQRAW(self, probe, label = "", Nline = -999): line = qux.stdout.readline() if line == '\n': continue if line.startswith("Values:"): break + if line.startswith("Trouble parsing"):break if line.startswith("No. Points:"): self.sim['Nstep'] = int(int(re.match(r'^No. Points:\s*(\d+).*', line).group(1)) / (Nline + 1)) if line.startswith("Plotname:"): From 33c165f2364646610a9cabc2e984673a9c4a7394 Mon Sep 17 00:00:00 2001 From: takez Date: Tue, 15 Apr 2025 06:00:13 +0900 Subject: [PATCH 2/2] update function --- src/PyQSPICE/qspice.py | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/PyQSPICE/qspice.py b/src/PyQSPICE/qspice.py index 88aaf07..1f4fdbb 100644 --- a/src/PyQSPICE/qspice.py +++ b/src/PyQSPICE/qspice.py @@ -26,7 +26,7 @@ class clsQSPICE: usrp = gpath['home'] + "/QSPICE/" sysp = r"c:/Program Files/QSPICE/" - for exe in ['QUX', 'QSPICE64', 'QSPICE80']: + for exe in ['QUX', 'QSPICE64', 'QSPICE80','QPOST']: if os.path.isfile(sysp + exe + '.exe'): gpath[exe] = sysp + exe + '.exe' # User path has priority if os.path.isfile(usrp + exe + '.exe'): gpath[exe] = usrp + exe + '.exe' @@ -54,7 +54,8 @@ def __init__(self, fname): self.path['user'] = fname self.path['base'] = fname.removesuffix('.qsch').removesuffix('.qraw').removesuffix('.cir') - clsQSPICE.tstime(self, ['qsch', 'qraw', 'cir', 'utf8']) +# clsQSPICE.tstime(self, ['qsch', 'qraw', 'cir', 'utf8']) + clsQSPICE.tstime(self, ['qsch', 'qraw', 'cir', 'utf8','log','logutf8']) # How many data points to read from QRAW simulation result files # Too small, too zigzag; too big, too slow ☹ @@ -148,7 +149,34 @@ def cir4label(self, label = 'simulation_label'): self.sim['label=' + label] = {'label': label, 'Nline': self.sim['Nline'], 'Nbit': self.sim['Nbit']} self.sim['labels'] += [label] - + def cir2log(self): + print(self.gpath['QPOST'], self.path['cir'], "-o log.txt",self.path['log']) + + if self.ts['cir']: + with open(self.path['log'], "w") as ofile: + subprocess.run([self.gpath['QPOST'], self.path['cir'], "-o",self.path['log']], stdout=ofile) + clsQSPICE.tstime(self, ['log']) + with codecs.open(self.path['log'], 'r', 'latin_1') as ifile: + lines = ifile.read() + with codecs.open(self.path['logutf8'], 'w', 'utf_8') as ofile: + ofile.write(lines) + clsQSPICE.tstime(self, ['logutf8']) + def LoadMEAS(self): + measdata={} + with open(self.path['logutf8'], 'r') as file: + for line in file: + if line.startswith(".meas"): + word=line.split() + + if(word[1]=='tran'): + param=word[2] + else: + param=word[1] + else: + word=line.split() + value=word[0] + measdata[param]=value + return measdata # Run a simulation from the netlist CIR file def cir2qraw(self, label = ""): if self.sim['label'] != 'default': label = self.sim['label']