Simulation with XSPICE code models

Currently ngspice contains 68 code models, ranging from simple elements like analog gain cells or digital inverters up to complex ones like a digital state machine , SRAMs, 3D table models or interfaces to digital Verilog building blocks compiled with Verilator.

I have created a symbol library for KiCad 8, containing digital and hybrid symbols. It is accompanied by the associated simulation model library. Enhancement by analog symbols and models will follow.

XSPICE-symbols-models.7z (4.0 KB)

Both symbols and models are made to be integrated into the KiCad symbol library. Therefore the installation even now requires to copy both files (Simulation_XSPICE.kicad_sym and Simulation_XSPICE.sp) into the location where the standard symbol library resides (e.g. C:\Program Files\KiCad\8.0\share\kicad\symbols on MS Windows). Then they have to be added to the available libraries by Eeschema → Preferences → Manage Symbol libraries → + → Select the library path and add a nickname (Simulation_XSPICE for example).

Yes, it may happen that these files are deleted when updating KiCad. Then just copy them and attch them again into this directory. However,. after updating and installing KiCad 8.0.7 (MS Windows), the Simulation_XSPICE files are still present.

Below you will find some projects using the new symbols and models, tested with KiCad 8.06 on MS Windows 10.

Simulation_XSPICE.7z (27.1 KB)

Some examples are:
A 4-bit counter with JKFFs


A divide by 4 with 2 DFFs

A voltage controlled oscillator and a voltage controlled pulse width modulator (both are hybrid models, analog in, digital out).

with result

Plotting is sometimes done using a ngspice script writing a VCD file and then starting GTKWAVE to plot it. The Eeschema plotter currently does not support plotting digital data (except for you will change them to analog by adding a resistor to the specific node).

6 Likes