Skip to content

Commit 1a63b5a

Browse files
Create README.md for SpiceSharpParser project
Add initial README with project details and usage examples.
1 parent d4969e8 commit 1a63b5a

1 file changed

Lines changed: 127 additions & 0 deletions

File tree

README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# SpiceSharpParser
2+
3+
[![NuGet](https://img.shields.io/nuget/v/SpiceSharp-Parser.svg)](https://www.nuget.org/packages/SpiceSharp-Parser)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5+
6+
A .NET library that parses SPICE netlists and simulates them using [SpiceSharp](https://github.com/SpiceSharp/SpiceSharp). It supports a wide subset of PSpice and LTspice syntax including DC, AC, transient, noise, and operating-point analyses.
7+
8+
**Targets:** .NET Standard 2.0 / .NET 8.0
9+
10+
## Installation
11+
12+
```
13+
dotnet add package SpiceSharp-Parser
14+
```
15+
16+
Or via the NuGet Package Manager:
17+
18+
```
19+
Install-Package SpiceSharp-Parser
20+
```
21+
22+
## Quick Example
23+
24+
```csharp
25+
using System;
26+
using System.Linq;
27+
using SpiceSharpParser;
28+
29+
var netlist = string.Join(Environment.NewLine,
30+
"Low-pass RC filter",
31+
"V1 IN 0 AC 1",
32+
"R1 IN OUT 1k",
33+
"C1 OUT 0 1u",
34+
".AC DEC 10 1 1MEG",
35+
".SAVE V(OUT)",
36+
".END");
37+
38+
// Parse
39+
var parser = new SpiceNetlistParser();
40+
var parseResult = parser.ParseNetlist(netlist);
41+
42+
// Translate to SpiceSharp objects
43+
var reader = new SpiceSharpReader();
44+
var spiceModel = reader.Read(parseResult.FinalModel);
45+
46+
// Run simulation
47+
var sim = spiceModel.Simulations.Single();
48+
var export = spiceModel.Exports.Find(e => e.Name == "V(OUT)");
49+
sim.EventExportData += (sender, args) => Console.WriteLine(export.Extract());
50+
sim.Execute(spiceModel.Circuit);
51+
```
52+
53+
## Workflow
54+
55+
Using SpiceSharpParser involves three steps:
56+
57+
1. **Parse** — convert a SPICE netlist string into a parse-tree model with `SpiceNetlistParser.ParseNetlist()`.
58+
2. **Read** — translate the parse-tree into SpiceSharp simulation objects with `SpiceSharpReader.Read()`.
59+
3. **Simulate** — run the SpiceSharp simulations and collect results via exports and events.
60+
61+
### SpiceSharpModel
62+
63+
`SpiceSharpReader.Read()` returns a `SpiceSharpModel` containing:
64+
65+
| Property | Description |
66+
|----------|-------------|
67+
| `Circuit` | The SpiceSharp `Circuit` with all components |
68+
| `Simulations` | List of simulation objects (DC, AC, Transient, etc.) |
69+
| `Exports` | Signal exports created by `.SAVE`, `.PRINT`, `.PLOT` |
70+
| `XyPlots` | Plot data from `.PLOT` statements |
71+
| `Prints` | Tabular data from `.PRINT` statements |
72+
| `Measurements` | Results from `.MEAS` / `.MEASURE` statements |
73+
| `Title` | Netlist title (first line) |
74+
75+
## Supported Features
76+
77+
### Analysis
78+
79+
`.AC`, `.DC`, `.TRAN`, `.OP`, `.NOISE`
80+
81+
### Output
82+
83+
`.SAVE`, `.PRINT`, `.PLOT`, `.MEAS` / `.MEASURE` (TRIG/TARG, WHEN, FIND, MAX, MIN, AVG, RMS, PP, INTEG, DERIV, PARAM)
84+
85+
### Parameters & Functions
86+
87+
`.PARAM`, `.FUNC`, `.LET`, `.SPARAM`
88+
89+
### Circuit Structure
90+
91+
`.SUBCKT` / `.ENDS`, `X` (subcircuit instances), `.INCLUDE`, `.LIB`, `.GLOBAL`, `.APPENDMODEL`
92+
93+
### Simulation Control
94+
95+
`.STEP`, `.MC` (Monte Carlo), `.TEMP`, `.OPTIONS`, `.IC`, `.NODESET`, `.ST`, `.IF`, `.DISTRIBUTION`
96+
97+
### Devices
98+
99+
| Category | Devices |
100+
|----------|---------|
101+
| Passive | R (resistor), C (capacitor), L (inductor), K (mutual inductance), T (transmission line) |
102+
| Semiconductor | D (diode), Q (BJT), M (MOSFET), J (JFET) |
103+
| Sources | V (voltage), I (current) — DC, AC, PULSE, SIN, PWL, SFFM, AM |
104+
| Controlled sources | E (VCVS), F (CCCS), G (VCCS), H (CCVS) |
105+
| Behavioral | B (arbitrary behavioral source with V= or I= expressions) |
106+
| Switches | S (voltage-controlled), W (current-controlled) |
107+
108+
### Behavioral Modeling
109+
110+
`VALUE={expr}`, `TABLE={expr}`, `POLY(n)`, and a full set of built-in math functions.
111+
112+
## Documentation
113+
114+
See the [documentation articles](src/docs/articles/) for detailed guides on each statement and device type.
115+
116+
## Building from Source
117+
118+
```bash
119+
git clone https://github.com/SpiceSharp/SpiceSharpParser.git
120+
cd SpiceSharpParser/src
121+
dotnet build
122+
dotnet test
123+
```
124+
125+
## License
126+
127+
This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)