Skip to main content

Overview

KiCad includes integrated SPICE simulation capabilities through ngspice, allowing you to simulate analog and mixed-signal circuits directly from your schematic. The simulation system supports AC, DC, transient, and noise analysis.

Architecture

The simulation system consists of several key components:

NGSPICE Interface

Defined in /eeschema/sim/ngspice.h:

Simulation Library Manager

Defined in /eeschema/sim/sim_lib_mgr.h:

SPICE Model Types

KiCad supports various SPICE model types:

Built-in Primitive Models

  • R: Resistor
  • C: Capacitor
  • L: Inductor
  • V: Voltage source (DC, AC, transient)
  • I: Current source
  • D: Diode
  • Q: BJT transistor
  • M: MOSFET
  • J: JFET
  • X: Subcircuit

Assigning Models to Symbols

In the schematic, symbols are assigned simulation models through fields:
Or reference external SPICE models:

Running Simulations

DC Operating Point

Analyze DC voltages and currents:

DC Sweep

Sweep a voltage or current source:

AC Analysis

Frequency domain analysis:
Parameters:
  • dec: Decade sweep (10 points per decade)
  • 1: Start frequency (1 Hz)
  • 100k: End frequency (100 kHz)

Transient Analysis

Time-domain simulation:
Parameters:
  • 1u: Time step (1 microsecond)
  • 100u: Total time (100 microseconds)

Noise Analysis

SPICE Netlist Export

KiCad generates SPICE netlists from schematics using /eeschema/netlist_exporters/netlist_exporter_spice.h:

Netlist Structure

Probe Points and Measurements

Voltage Probes

Current Probes

Insert voltage source with 0V to measure current:

Power Calculations

Python Scripting Integration

While KiCad’s simulation is primarily GUI-based, you can export and run netlists programmatically:

Advanced SPICE Features

Behavioral Sources

Subcircuits

Parameter Sweeps

Temperature Analysis

Model Libraries

Loading External Models

IBIS Models

For signal integrity analysis, KiCad supports IBIS models through /eeschema/sim/kibis/:

Performance Optimization

Convergence Issues

Memory Management

Simulation Results Analysis

Fourier Analysis

Distortion Analysis

Pole-Zero Analysis

Common Simulation Patterns

RC Low-Pass Filter

BJT Amplifier

Troubleshooting

Common Errors

“Singular matrix”
  • Add small resistor to floating nodes
  • Check for loops of voltage sources or capacitors
“Timestep too small”
  • Reduce RELTOL
  • Add small resistance to capacitors
  • Check for unrealistic component values
“No convergence”
  • Set better initial conditions
  • Use .nodeset to hint at solutions
  • Reduce circuit complexity

Best Practices

  1. Start simple: Verify basic operation before adding complexity
  2. Use realistic values: Avoid extreme component values
  3. Set appropriate tolerances: Balance speed vs. accuracy
  4. Include parasitics: Add ESR, ESL for real-world behavior
  5. Validate with measurements: Compare simulation to hardware
  6. Document models: Comment model sources and parameters

See Also