Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Cadence PSF file utilities

Project description
Author:Ken Kundert


psf_utils is a library that allows you to read data from a Spectre PSF ASCII file. Spectre is a commercial circuit simulator produced by Cadence Design Systems. PSF files contain signals generated by Spectre. This package also contains two programs that are useful in their own right, but also act as demonstrators as to how to use the library. They are list-psf and plot-psf. The first lists the available signals in a file, and the other displays them.

Accessing the Results

You can use the PSF class to read ASCII Parameter Storage Format files. When instantiating the class you pass in the path to the file and then the resulting PSF object contains a dictionary that containing the signals. For example, the following lists is a:

from psf_utils import PSF
from inform import Error, display

kinds = {
    'float double': 'real',
    'float complex': 'complex',

    psf = PSF('adc.raw/tran.tran')

    for signal in psf.all_signals():
        kind = signal.type.kind
        kind = kinds.get(kind, kind)
        display(f'{<15}  {signal.units:<12}  {kind}')
except Error as e:

This example plots the output signal:

from psf_utils import PSF
from inform import Error, display
import matplotlib.pyplot as plt

    psf = PSF('adc.raw/tran.tran')
    sweep = psf.get_sweep()
    out = psf.get_signal('out')

    figure = plt.figure()
    axes = figure.add_subplot(1,1,1)
    axes.plot(sweep.abscissa, out.ordinate, linewidth=2,
    axes.set_title('ADC Output')
    axes.set_xlabel(f'{} ({PSF.units_to_unicode(sweep.units)})')
    axes.set_ylabel(f'{} ({PSF.units_to_unicode(out.units)})')
except Error as e:

abscissa and ordinate are NumPy arrays. As such, you can perform computation with them:

out = out_p.ordinate - out_n.ordinate

from numpy import sin
sine = sin(sweep.abscissa)

Reading large ASCII data files is slow, so PSF reads the PSF file once, then pickles the data and writes it to disk. On subsequent runs the pickled data is used if the pickle file is newer that the corresponding PSF file.

Utility Programs

Two utility programs are installed along with the psf_utils library: list-psf and plot-psf. The first lists the signals available from a PSF file, and the second displays them. They both employ caching to speed up access to the data. They also cache the name of the PSF file so that it need not be given every time. plot-psf also caches its arguments, so if you run it again with no arguments it will simply repeat what it did last time. For example, here is a typical session:

# display signals in noise PSF file
> list-psf -f resistor.raw/pnoise.pnoise
Using resistor.raw/pnoise.pnoise.
    R1:flicker  R1:total    R2:fn       out
    R1:thermal  R2:rn       R2:total

# display them again, this time in long form
> list-psf -l
Using resistor.raw/pnoise.pnoise.
    R1:flicker  A²/Hz  real  (12042 points)
    R1:thermal  A²/Hz  real  (12042 points)
    R1:total    A²/Hz  real  (12042 points)
    R2:fn       A²/Hz  real  (12042 points)
    R2:rn       A²/Hz  real  (12042 points)
    R2:total    A²/Hz  real  (12042 points)
    out         A/√Hz  real  (12042 points)

# display only those that match R1:* (assumes nonomatch variable is set in shell)
> list-psf -l R1:*
Using resistor.raw/pnoise.pnoise.
    R1:flicker  A²/Hz  real  (12042 points)
    R1:thermal  A²/Hz  real  (12042 points)
    R1:total    A²/Hz  real  (12042 points)

# display a graph containing signals that start with R1:
> plot-psf R1:*

# display the thermal noise of R1, and then the total noise minus the flicker noise
> plot-psf R1:thermal R1:total-R1:flicker

# display a graph containing only out
> plot-psf out

> plot-psf            # display out again, exactly as in previous run

> plot-psf -M out     # display out again, this time include point markers

> plot-psf -P out     # display out again, this time only show point markers

> plot-psf -s out.svg out     # send graph of out to svg file

# display signals in transient PSF file
> list-psf -f diffamp.raw/tran.tran
Using diffamp.raw/pnoise.pnoise.
    in_n    in_p    out_n   out_p   Vdd

# display differential output and differential input
> plot-psf out_p-out_n in_p-in_n

Converting to PSF ASCII

psf_utils only supports PSF ASCII files. As an alternative, libpsf is a Python package that can read both ASCII and binary PSF files. Or, you can use the Cadence psf program to convert various types of simulation results files into PSF ASCII format. To use it, simply specify the input and output files:

> psf -i adc.raw/tran.tran -o adc.raw/tran.psfascii
> list-psf -f adc.raw/tran.psfascii

In this example there is nothing special about the ‘psfascii’ suffix, it is simply mnemonic. Rather, the output is in ASCII format because the -b (binary) option is not specified.

psf_utils does not support SST files, which are generated by AMS Designer, Cadence’s mixed-signal simulator. You can recognize SST files in that they come in pairs, and the two files have .dsn and .trn suffixes. In this case, Cadence’s PSF utility cannot help you either. However, you can use the simvisdbutil to convert the data to a CSV file, which would allow you to access the data, though not with psf_utils. For example, the following converts all waveforms contained in ldo.trn into CSV data:

simvisdbutil ldo.trn -csv -timeunits s -output ldo.csv


Flicker Noise is a simulation script that shows how to write simple Python scripts that run Spectre and use psf_utils to extract and display the desired results.


Latest development release:
Version: 1.0.0
Released: 2020-11-03
1.0 (2020-11-03):
  • Production release
0.7 (2020-09-23):
  • Add ability to show individual points
  • Improve the cursor values display
  • Increase precision of both cursor values and axis labels
0.6 (2020-04-16):
  • modest refinements
0.5 (2020-01-08):
  • beta release
0.4 (2019-09-26):
  • Allow glob patterns to be passed to both list-psf and plot-psf.
0.3 (2019-09-25):
  • Fix import errors in plot-psf command.
0.2 (2019-09-25):
  • Fix dependencies.
0.1 (2019-09-25):
  • Initial version

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for psf-utils, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size psf_utils-1.0.0-py3-none-any.whl (13.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size psf_utils-1.0.0.tar.gz (15.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page