psf_utils
psf_utils copied to clipboard
Parser Error When There is No Traced Signal
After running sampled pnoise simulation in spectre, one of the generated psf file records jitter event time as in the attachment.
Traceback info:
Traceback (most recent call last):
File "/home/xxx/miniforge3/lib/python3.10/site-packages/psf_utils/psf.py", line 104, in __init__
sections = parser.parse(filename, content)
File "/home/xxx/miniforge3/lib/python3.10/site-packages/psf_utils/parse.py", line 539, in parse
result = self.parser.parse(content, tracking=False, lexer=self.lexer)
File "/home/xxx/miniforge3/lib/python3.10/site-packages/ply/yacc.py", line 331, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "/home/xxx/miniforge3/lib/python3.10/site-packages/ply/yacc.py", line 1199, in parseopt_notrack
tok = call_errorfunc(self.errorfunc, errtoken, self)
File "/home/xxx/miniforge3/lib/python3.10/site-packages/ply/yacc.py", line 193, in call_errorfunc
r = errorfunc(token)
File "/home/xxx/miniforge3/lib/python3.10/site-packages/psf_utils/parse.py", line 524, in p_error
raise ParseError("syntax error at '%s'." % (p.value), loc)
psf_utils.parse.ParseError: run/psf/pnoiseMpm0.sample.pnoise(134): syntax error at 'VALUE'.
VALUE
^
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/xxx/src/spectre/noise_tb_sim/read_psf.py", line 111, in <module>
psf_pnoise_sample = PSF("run/psf/pnoiseMpm0.sample.pnoise")
File "/home/xxx/miniforge3/lib/python3.10/site-packages/psf_utils/psf.py", line 106, in __init__
raise Error(str(e))
inform.inform.Error: run/psf/pnoiseMpm0.sample.pnoise(134): syntax error at 'VALUE'.
VALUE
^
psf_utils is in version 1.8.0.
Just found a quick fix by adding the following function to parse.py:
def p_traces_empty(p):
"traces : "
p[0] = []
If possible, I will create a merge request. @KenKundert
I added you code to fixed this. The fix is on github.
It seems that after updating to latest spectre, it does not generate a Trace section with only a keyword TRACE. Instead, the whole section does not show. So I added the following function in parse.py:
def p_contents_without_trace(p):
"contents : header_section type_section sweep_section value_section end"
p[0] = (p[1], p[2], p[3], None, p[4])
And in line 180 of psf.py, I temporarily fixed the assertion like this (because this case is not DC simulation):
# assert len(value.values) == 1
if len(value.values) != 1:
break
The example input file: pnoiseMpm0.sample.pnoise.gz