KenKundert / psf_utils

Read Spectre PSF files
49 stars 14 forks source link

unknown keyword 'S' #16

Closed dan-zilla closed 1 year ago

dan-zilla commented 2 years ago

PSF file is attached. 20220829-psf_debug.zip

Below is the error I am getting

ipykernel_launcher.py error:
    /nfs/regress_04_snc/analog/danvilla/simulation/tn55cms_adc_sar12b_ip_sim/adc_sar12b_cdac_4b_sim/maestro/results/maestro/Interactive.102/1/tran_dnl/psf/tran.psf.ascii(181): unknown keyword 'S'.
        S 312 471 0 3.2e-07 0 0
        ^
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

The traceback is below:

Traceback (most recent call last):
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/psf_utils/psf.py", line 86, in __init__
    sections = parser.parse(filename, content)
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/psf_utils/parse.py", line 488, in parse
    result = self.parser.parse(content, tracking=False, lexer=self.lexer)
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/ply-3.4-py3.9.egg/ply/yacc.py", line 265, in parse
    return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/ply-3.4-py3.9.egg/ply/yacc.py", line 921, in parseopt_notrack
    lookahead = get_token()     # Get the next token
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/ply-3.4-py3.9.egg/ply/lex.py", line 348, in token
    newtok = func(tok)
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/psf_utils/parse.py", line 156, in t_ID
    raise ParseError(f"unknown keyword '{t.value}'.", loc)
psf_utils.parse.ParseError: /nfs/regress_04_snc/analog/danvilla/simulation/tn55cms_adc_sar12b_ip_sim/adc_sar12b_cdac_4b_sim/maestro/results/maestro/Interactive.102/1/tran_dnl/psf/tran.psf.ascii(181): unknown keyword 'S'.
    S 312 471 0 3.2e-07 0 0
    ^

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/ipykernel_1453498/581391547.py", line 12, in <module>
    psf = PSF('/nfs/regress_04_snc/analog/danvilla/simulation/tn55cms_adc_sar12b_ip_sim/adc_sar12b_cdac_4b_sim/maestro/results/maestro/Interactive.102/1/tran_dnl/psf/tran.psf.ascii')
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/psf_utils/psf.py", line 88, in __init__
    raise Error(str(e))
inform.inform.Error: /nfs/regress_04_snc/analog/danvilla/simulation/tn55cms_adc_sar12b_ip_sim/adc_sar12b_cdac_4b_sim/maestro/results/maestro/Interactive.102/1/tran_dnl/psf/tran.psf.ascii(181): unknown keyword 'S'.
    S 312 471 0 3.2e-07 0 0
    ^

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3441, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "/tmp/ipykernel_1453498/581391547.py", line 15, in <module>
    e.terminate()
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/inform-1.26.0-py3.9.egg/inform/inform.py", line 3101, in terminate
    fatal(*self.args, **kwargs)
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/inform-1.26.0-py3.9.egg/inform/inform.py", line 1944, in __call__
    INFORMER._report(args, kwargs, self)
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/inform-1.26.0-py3.9.egg/inform/inform.py", line 2485, in _report
    self.terminate(status=action.terminate)
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/inform-1.26.0-py3.9.egg/inform/inform.py", line 2619, in terminate
    raise SystemExit(status)
SystemExit: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py", line 1101, in get_records
    return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py", line 248, in wrapped
    return f(*args, **kwargs)
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py", line 281, in _fixed_getinnerframes
    records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/inspect.py", line 1541, in getinnerframes
    frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
AttributeError: 'tuple' object has no attribute 'tb_frame'

---------------------------------------------------------------------------
ParseError                                Traceback (most recent call last)
~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/psf_utils/psf.py in __init__(self, filename, sep, use_cache, update_cache)
     85             content = psf_filepath.read_text()
---> 86             sections = parser.parse(filename, content)
     87         except ParseError as e:

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/psf_utils/parse.py in parse(self, filename, content)
    487 
--> 488         result = self.parser.parse(content, tracking=False, lexer=self.lexer)
    489         return result

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/ply-3.4-py3.9.egg/ply/yacc.py in parse(self, input, lexer, debug, tracking, tokenfunc)
    264         else:
--> 265             return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
    266 

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/ply-3.4-py3.9.egg/ply/yacc.py in parseopt_notrack(self, input, lexer, debug, tracking, tokenfunc)
    920                 if not lookaheadstack:
--> 921                     lookahead = get_token()     # Get the next token
    922                 else:

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/ply-3.4-py3.9.egg/ply/lex.py in token(self)
    347 
--> 348                 newtok = func(tok)
    349 

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/psf_utils/parse.py in t_ID(t)
    155         t.lexer.skip(1)
--> 156         raise ParseError(f"unknown keyword '{t.value}'.", loc)
    157     return t

ParseError: /nfs/regress_04_snc/analog/danvilla/simulation/tn55cms_adc_sar12b_ip_sim/adc_sar12b_cdac_4b_sim/maestro/results/maestro/Interactive.102/1/tran_dnl/psf/tran.psf.ascii(181): unknown keyword 'S'.
    S 312 471 0 3.2e-07 0 0
    ^

During handling of the above exception, another exception occurred:

Error                                     Traceback (most recent call last)
/tmp/ipykernel_1453498/581391547.py in <module>
     11 try:
---> 12     psf = PSF('/nfs/regress_04_snc/analog/danvilla/simulation/tn55cms_adc_sar12b_ip_sim/adc_sar12b_cdac_4b_sim/maestro/results/maestro/Interactive.102/1/tran_dnl/psf/tran.psf.ascii')
     13 

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/psf_utils/psf.py in __init__(self, filename, sep, use_cache, update_cache)
     87         except ParseError as e:
---> 88             raise Error(str(e))
     89         except OSError as e:

Error: /nfs/regress_04_snc/analog/danvilla/simulation/tn55cms_adc_sar12b_ip_sim/adc_sar12b_cdac_4b_sim/maestro/results/maestro/Interactive.102/1/tran_dnl/psf/tran.psf.ascii(181): unknown keyword 'S'.
    S 312 471 0 3.2e-07 0 0
    ^

During handling of the above exception, another exception occurred:

SystemExit                                Traceback (most recent call last)
    [... skipping hidden 1 frame]

/tmp/ipykernel_1453498/581391547.py in <module>
     14 except Error as e:
---> 15     e.terminate()

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/inform-1.26.0-py3.9.egg/inform/inform.py in terminate(self, **new_kwargs)
   3100             kwargs = self.kwargs
-> 3101         fatal(*self.args, **kwargs)
   3102 

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/inform-1.26.0-py3.9.egg/inform/inform.py in __call__(self, *args, **kwargs)
   1943     def __call__(self, *args, **kwargs):
-> 1944         INFORMER._report(args, kwargs, self)
   1945 

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/inform-1.26.0-py3.9.egg/inform/inform.py in _report(self, args, kwargs, action)
   2484         if action.terminate is not False:
-> 2485             self.terminate(status=action.terminate)
   2486         self.previous_action = action

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/inform-1.26.0-py3.9.egg/inform/inform.py in terminate(self, status, exit)
   2618         if exit:
-> 2619             raise SystemExit(status)
   2620         else:

SystemExit: 1

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
    [... skipping hidden 1 frame]

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/interactiveshell.py in showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)
   2052                     stb = ['An exception has occurred, use %tb to see '
   2053                            'the full traceback.\n']
-> 2054                     stb.extend(self.InteractiveTB.get_exception_only(etype,
   2055                                                                      value))
   2056                 else:

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in get_exception_only(self, etype, value)
    752         value : exception value
    753         """
--> 754         return ListTB.structured_traceback(self, etype, value)
    755 
    756     def show_exception_only(self, etype, evalue):

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, context)
    627             chained_exceptions_tb_offset = 0
    628             out_list = (
--> 629                 self.structured_traceback(
    630                     etype, evalue, (etb, chained_exc_ids),
    631                     chained_exceptions_tb_offset, context)

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
   1365         else:
   1366             self.tb = tb
-> 1367         return FormattedTB.structured_traceback(
   1368             self, etype, value, tb, tb_offset, number_of_lines_of_context)
   1369 

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
   1265         if mode in self.verbose_modes:
   1266             # Verbose modes need a full traceback
-> 1267             return VerboseTB.structured_traceback(
   1268                 self, etype, value, tb, tb_offset, number_of_lines_of_context
   1269             )

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)
   1122         """Return a nice text document describing the traceback."""
   1123 
-> 1124         formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
   1125                                                                tb_offset)
   1126 

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)
   1080 
   1081 
-> 1082         last_unique, recursion_repeat = find_recursion(orig_etype, evalue, records)
   1083 
   1084         frames = self.format_records(records, last_unique, recursion_repeat)

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in find_recursion(etype, value, records)
    380     # first frame (from in to out) that looks different.
    381     if not is_recursion_error(etype, value, records):
--> 382         return len(records), 0
    383 
    384     # Select filename, lineno, func_name to track frames with

TypeError: object of type 'NoneType' has no len()
KenKundert commented 2 years ago

psf-utils is not recognizing the following line:

"I_14.XI_DUMMIES_19__XR0.r1:subckt_trise__" "-real" PROP(                        
    S 312 471 0 3.2e-07 0 0                                                                        
    "units" "-real"                                                                  
)  

I have no idea what the meaning of S followed by 6 numbers. Do you?

dan-zilla commented 2 years ago

I am not sure either. For additional context: this is the result of a simulation of a parasitic extracted layout. XI_DUMMIES_19 is a metal resistor in the schematic. Maybe the layout coordinates and/or geometry shape parameters that define the metal resistor? I am attaching the netlist here for reference. input.scs.txt

dan-zilla commented 2 years ago

Another piece of info that may be relevant: this spectre simulation contains a verilogA component. It's called instance I_13 in the netlist. Not sure if that makes a difference in the format of the resulting PSF file.

KenKundert commented 2 years ago

Any chance you can share the definition of rmxw?

dan-zilla commented 2 years ago

Pasting the excerpt here from the model deck. I've removed process-specific values:

//***********************************     Metal x with W/S=0.XX/0.XXX     ***********************************
subckt rmxw ( n1 n2 ) 
parameters l=length w=width  factor=factor_res mf=1
parameters rsh=r_rmxw 
parameters dw=0 
parameters pvc1=0    pvc2=0    ptc1=X.XXe-03    ptc2=-X.XXe-07
parameters tfac=1.0+ptc1*(pt-25.0)+ptc2*(pt-25.0)*(pt-25.0) 
parameters pt=temp 

parameters j_max=XXXX 
parameters r1_ov=rsh/mf*l*factor/(w*factor-dw)*(1+pvc1*(0/l/factor)+pvc2*(0/l/factor)*(0/l/factor))*tfac 

r1 ( n1 n2 ) resistor r=rsh/mf*l*factor/(w*factor-dw)*(1+pvc1*(abs(v(n2,n1))/l/factor)+pvc2*(v(n2,n1)/l/factor)*(v(n2,n1)/l/factor))*tfac
c_soa ( n1 n2 ) capacitor c=1e-60  m=mf  bv_max=j_max*w*factor*r1_ov*mf

ends rmxw
KenKundert commented 2 years ago

Seems like the built-in resistor is creating that line, and I have no idea what that line means. Not sure what do do about this. Since I don't know what the line means I cannot come up with a theory of to how to parse it.

dan-zilla commented 2 years ago

I am not sure about that. Does the PROP() attribute mean anything in PSF format? All of the declarations in the PSF file contain that tuple of values. Even traces that are not for resistors. One clue is that the 4th value after the S is the stop time of the transient simulation (320 ns). The 5th and 6th values seem to match the units specified (Ohms, V, A, etc.). Is there a PSF format specification for these kind of things?

KenKundert commented 2 years ago

Well, not the resistor per see. What I should have said is that the values seem unrelated to the fact that the netlist was extracted or that there was a Verilog-A model.

You make a good point about PROP. I'm sure it means something to someone, but it currently means nothing to psf_utils, it is simply discarded. Extending the psf_utils parser to handle the unknown and seemingly rather arbitrary syntax for the contents of PROP() would be difficult and fragile. Perhaps the right approach is to simply preprocess the file and remove the PROPs all together. Let me try it.

KenKundert commented 2 years ago

Well I worked past the issue with PROP only to find that the file is defective. It is a file with names but no values. How did you create it?

dan-zilla commented 2 years ago

Strange. I used the psf utility to convert it from psfbin to psfascii. Let me try that again and see if there is a difference