SpiceSharpParser parses SPICE netlists and translates them into ordinary SpiceSharp circuits and simulations. It supports broad SPICE, PSpice, and LTspice syntax for .NET Standard 2.0 and .NET 8.0.
For the complete feature and API reference, see the detailed project guide.
- Parse
.AC,.DC,.TRAN,.OP, and.NOISEanalyses. - Translate netlists into normal SpiceSharp circuits and simulation objects.
- Load recursive
.INCLUDE/.LIBdependencies with source-located diagnostics. - Use
.SAVE,.PRINT,.PLOT,.MEAS, and.FOURresults from the netlist. - Load reusable
.SUBCKTlibraries into programmatically assembled circuits. - Opt into LTspice A-devices, ideal diodes, nonlinear passives, digital logic, analog functional models, and a functional 555 with the companion package.
Install the core parser:
dotnet add package SpiceSharp-ParserInstall the optional models only when they are needed:
dotnet add package SpiceSharpParser.CustomComponents| Requirement | Package |
|---|---|
| Parse and simulate ordinary SPICE netlists | SpiceSharp-Parser |
Load user-authored .SUBCKT libraries |
SpiceSharp-Parser |
| Parse supported LTspice A-devices and ideal/nonlinear devices | SpiceSharpParser.CustomComponents |
| Use packaged digital, analog, and functional 555 models | SpiceSharpParser.CustomComponents |
See the CustomComponents README for setup, model explanations, examples, and compatibility limits.
The original API exposes parsing, translation, and simulation as separate steps:
using System;
using System.Linq;
using SpiceSharpParser;
using SpiceSharpParser.Common;
var netlist = string.Join(Environment.NewLine,
"Low-pass RC filter",
"V1 IN 0 AC 1",
"R1 IN OUT 1k",
"C1 OUT 0 1u",
".AC DEC 10 1 1MEG",
".SAVE V(OUT)",
".END");
// Parse the SPICE text.
var parser = new SpiceNetlistParser();
var parsed = parser.ParseNetlist(netlist);
// Translate it into SpiceSharp objects.
var reader = new SpiceSharpReader();
var model = reader.Read(parsed.FinalModel);
// Run the analysis and read the requested export.
var simulation = model.Simulations.Single();
var output = model.Exports.Find(export => export.Name == "V(OUT)");
simulation.EventExportData += (_, _) => Console.WriteLine(output.Extract());
simulation.Execute(model.Circuit);| Goal | API |
|---|---|
| Direct control over an in-memory netlist | SpiceNetlistParser, then SpiceSharpReader |
| Compile user or vendor files with stable diagnostics | SpiceCompiler.CompileFile(...) |
Load selected .SUBCKT definitions into a circuit |
SpiceSubcircuitLibrary.LoadFile(...) or LoadText(...) |
| Enable optional netlist components in the original API | reader.Settings.UseCustomComponents() before Read() |
Enable optional components with SpiceCompiler |
SpiceCompileOptions.ConfigureReader |
SpiceCompiler adds recursive dependency loading, recovery, compatibility
classification, structural linting, and JSON/SARIF diagnostic output. See the
detailed project guide and
diagnostic reference.
SpiceSharpParser.CustomComponents supports these native eight-terminal
A-device families:
| Digital | Analog and mixed-signal |
|---|---|
SRFLOP, DFLOP, PHASEDET, COUNTER |
SAMPLEHOLD, OTA, VARISTOR, MODULATOR/MODULATE |
Terminal 8 is common. A terminal is unused only when it repeats that common
node; if common is not ground, a literal 0 remains an active global-ground
connection. Unused outputs are detached, and an unused MODULATOR amplitude
input selects the native amplitude of 1.
Complete netlists, .SAVE/.PLOT waveforms, .MEAS checks, and guides are in
the runnable A-device example pack.
The former long README reference is split across these focused documents:
| Topic | Document |
|---|---|
| Full project reference | Detailed Project Guide |
| Practical, measured designs | Circuit Cookbook |
| Documentation by statement and device | Documentation Index |
| Parser introduction | Introduction |
| Compiler diagnostics | Diagnostic Reference |
| LTspice compatibility status | Compatibility Matrix |
| Programmatic subcircuit libraries | Subcircuit Library Guide |
| LTspice A-devices | A-device Guide |
| Digital logic and functional 555 | Digital Subcircuits |
| Analog special functions | Analog Subcircuits |
| LTspice-style ideal diode | Ideal Diode |
| Nonlinear capacitors and inductors | Nonlinear Passives |
| Measurements and output | .MEAS, .PRINT, .PLOT |
git clone https://github.com/SpiceSharp/SpiceSharpParser.git
cd SpiceSharpParser
dotnet restore src/SpiceSharp-Parser.sln
dotnet build src/SpiceSharp-Parser.sln
dotnet test src/SpiceSharpParser.Tests/SpiceSharpParser.Tests.csproj
dotnet test src/SpiceSharpParser.IntegrationTests/SpiceSharpParser.IntegrationTests.csprojSpiceSharpParser is licensed under the MIT License.