spicefault

spicefault documentation banner

Reproducible SPICE-based fault injection and reliability assessment of electronic circuits.

spicefault is a Python framework for studying how a circuit behaves when something in it fails, under realistic component tolerances and operating conditions. You describe a circuit, the faults it can have and how its good units vary; the framework simulates the campaign with ngspice, keeps a record of every sample, and computes what the results say: which faults are detected, which are confused with each other, and how tolerance erodes both.

It is not another Python interface to SPICE. It works one level above:

   circuit  +  normal variation  +  faults  +  operating conditions
                              |
                         experiment            one seed, one definition
                              |
                    SPICE simulations          every one with a status
                              |
        dataset: samples, waveforms, provenance
                              |
   detectability, diagnostic coverage, robustness, ambiguity

Install

pip install spicefault

and ngspice, which does the simulations:

brew install ngspice          # macOS
sudo apt install ngspice      # Debian, Ubuntu

A first experiment

A resistive divider with 1 % resistors, two faults and two operating conditions:

from spicefault import Circuit, Experiment, OperatingCondition, SimulationConfig
from spicefault.faults import OpenCircuit, ParametricFault
from spicefault.variation import ToleranceVariation

circuit = Circuit("""divider
V1 in 0 dc 1
R1 in out 10k
R2 out 0 10k
.end
""", name="divider")

experiment = Experiment(
    circuit,
    config=SimulationConfig(analyses=("op",), outputs=("v(out)",)),
    faults=[OpenCircuit("R2"), ParametricFault("R1", deviation=0.2)],
    variations=[ToleranceVariation("R1", 0.01), ToleranceVariation("R2", 0.01)],
    conditions=[
        OperatingCondition(),
        OperatingCondition("low supply", settings={("V1", "dc"): 0.5}),
    ],
    samples=100,
    seed=42,
)
result = experiment.run(workers=4)

print(result.status_counts())      # {'SUCCESS': 600}
table = result.to_frame()          # sample definitions, status and realised values
vout = [s.result.plot("op")["v(out)"][0] for s in result]

Go on with Getting started, or run the examples.

What it gives you

  • Faults as objects. Open, short, leakage, parametric and composite faults, each a recorded change of the netlist with a physical interpretation. Faults
  • An auditable fault list. A fault universe generated from rules, with a coverage matrix and a reason for every fault left out.
  • A healthy population. Tolerance, normal, log-normal and joint distributions, kept apart from the faults. Normal variation
  • Reproducible campaigns. The same samples on any number of workers; resumable; every failed simulation kept with its status. Experiments
  • Datasets that stand on their own. Integrity checks, the provenance of each sample, and the netlist that was simulated for it. Datasets
  • Reliability metrics with intervals. Detection probability, diagnostic coverage, minimum detectable deviation, robustness against tolerance, ambiguity groups. Reliability analysis

Limits

One simulator, ngspice. One fault per sample. Faults act on the top level of the netlist: a component inside a subcircuit is reached through the parameters of its instance. Simulated evidence does not replace testing hardware.

Citing

If you use spicefault in your work, please cite it: see CITATION.cff in the repository.