Skip to content

Commit f7b7074

Browse files
Docs update
1 parent 56f9cf5 commit f7b7074

6 files changed

Lines changed: 136 additions & 9 deletions

File tree

‎roadmap/ltspice-compatibility-matrix.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: LTspice Compatibility Matrix
3-
status: P3 Baseline + .FOUR Support Refresh + Custom Passives + Ideal Diodes + Golden Evidence + Include/Lib Path Evidence
3+
status: P3 Baseline + .FOUR Support Refresh + Custom Passives + Ideal Diodes + Golden Evidence + Include/Lib Path Evidence + Waveform Docs Refresh
44
scope: SpiceSharpParser + SpiceSharp
55
last_reviewed: 2026-07-04
66
---
@@ -58,7 +58,7 @@ Compatibility classes:
5858
| `PULSE(... Ncycles)` | Accepted in LTspice mode | Produces finite-cycle pulse waveform | TRAN supported | Analytic transient fixture | Invalid period or cycle count produces targeted `PULSE` diagnostic | Current parser/runtime | The eighth LTspice argument limits the waveform to `Ncycles` periods, then returns to the initial value. |
5959
| `SINE(... Ncycles)` | Accepted | Rejected in LTspice mode | Not runnable | None | Targeted LTspice `SINE` cycle-count diagnostic | Current parser/runtime | Finite-cycle waveform behavior is deferred. |
6060
| Independent source `tbl=(expr,x1,y1,...)` | Accepted in LTspice mode | Lowered to behavioral `table(...)` source | OP supported | Analytic fixture | Invalid form names `tbl` | Current parser/runtime | Parser shim uses the existing source/table expression path. |
61-
| Source `wavefile=<path> chan=<n> [amplitude=<value>]` | Accepted | Produces wave-file waveform | Existing wave-file behavior | Smoke/diagnostic fixture | Missing `chan` and missing file produce targeted validation | Current parser/runtime | Channel defaults are not inferred. |
61+
| Source `wavefile=<path> chan=<n> [amplitude=<value>]` | Accepted | Produces wave-file waveform | Existing wave-file behavior | Smoke/diagnostic fixture | Missing `wavefile`, missing `chan`, missing file, and invalid `chan` produce targeted validation | Current parser/runtime | Channel defaults are not inferred. |
6262
| Source `Rser`, `Cpar`, `load`, `R=<value>` | Accepted | Rejected in LTspice mode | Not runnable | None | Targeted LTspice source-option error names option | Current parser/runtime | Topology-changing source options are not synthesized. |
6363
| R/C model `tc=a[,b]` | Accepted | Lowered to `tc1` / `tc2` | Existing R/C model behavior | Read fixture | None expected in LTspice mode | Current parser/runtime | Parser shim only; coefficients beyond two are rejected. |
6464
| LTspice metadata/rating parameters `mfg`, `manufacturer`, `pn`, `part`, `desc`, `description`, `V`, `Irms`, `Ipk` | Accepted | Warning no-op in LTspice mode | No runtime effect | Diagnostic fixture | Default: existing parameter error. LTspice: warning names parameter. | Current parser/runtime | BOM/layout metadata is not used by SpiceSharpParser. |

‎roadmap/ltspice-netlist-compatibility-plan.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Implemented P2 behavior:
213213
- Added six-argument `EXP(v1 v2 td1 tau1 td2 tau2)` source waveform support with argument-count and positive-tau diagnostics.
214214
- Added LTspice-mode finite-cycle `PULSE(... Ncycles)` support and targeted diagnostics for unsupported finite-cycle `SINE` arguments.
215215
- Added LTspice-mode `tbl=(expr,x1,y1,...)` independent-source lowering to the existing behavioral `table(...)` path.
216-
- Improved `wavefile=<path> chan=<n> [amplitude=<value>]` validation so missing `chan` and missing files produce targeted diagnostics.
216+
- Improved `wavefile=<path> chan=<n> [amplitude=<value>]` validation so missing `wavefile`, missing `chan`, missing files, and invalid `chan` values produce targeted diagnostics.
217217
- Added LTspice-mode targeted diagnostics for topology-changing source options `Rser`, `Cpar`, `load`, and `R=<value>`.
218218

219219
Remaining follow-up:

‎src/SpiceSharpParser.IntegrationTests/LTspiceCompatibility/LTspiceCompatibilityP2Tests.cs‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using System.Linq;
34
using System.Text;
45
using SpiceSharpParser.Common;
@@ -82,6 +83,52 @@ public void When_LtspiceSourceOptionChangesTopology_Expect_TargetedError(string
8283
AssertErrorContains(model.ValidationResult, optionName);
8384
}
8485

86+
[Theory]
87+
[InlineData("V1 out 0 WAVE chan=1", "wavefile")]
88+
[InlineData("V1 out 0 wavefile=\"missing.wav\"", "chan")]
89+
[InlineData("V1 out 0 wavefile=\"missing.wav\" chan=1", "does not exist")]
90+
public void When_LtspiceWaveFileSourceIsInvalid_Expect_TargetedError(string sourceLine, string expectedMessage)
91+
{
92+
var model = GetSpiceSharpModelWithCompatibility(
93+
CompatibilityOptions.LTspice,
94+
"LTspice P2 - invalid wavefile",
95+
sourceLine,
96+
"R1 out 0 1k",
97+
".tran 1n 6n",
98+
".save V(out)",
99+
".end");
100+
101+
Assert.True(model.ValidationResult.HasError);
102+
AssertErrorContains(model.ValidationResult, "wavefile");
103+
AssertErrorContains(model.ValidationResult, expectedMessage);
104+
}
105+
106+
[Fact]
107+
public void When_LtspiceWaveFileChannelIsInvalid_Expect_TargetedError()
108+
{
109+
var waveFilePath = Path.GetTempFileName();
110+
111+
try
112+
{
113+
var model = GetSpiceSharpModelWithCompatibility(
114+
CompatibilityOptions.LTspice,
115+
"LTspice P2 - invalid wavefile channel",
116+
$"V1 out 0 wavefile=\"{waveFilePath}\" chan=bad",
117+
"R1 out 0 1k",
118+
".tran 1n 6n",
119+
".save V(out)",
120+
".end");
121+
122+
Assert.True(model.ValidationResult.HasError);
123+
AssertErrorContains(model.ValidationResult, "wavefile");
124+
AssertErrorContains(model.ValidationResult, "chan");
125+
}
126+
finally
127+
{
128+
File.Delete(waveFilePath);
129+
}
130+
}
131+
85132
[Theory]
86133
[InlineData("V1 out 0 SINE(0 1 1k 0 0 0 3)", "SINE")]
87134
public void When_LtspiceWaveformHasCycleCount_Expect_TargetedError(string sourceLine, string waveformName)

‎src/docs/articles/current-source.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ I<name> <node+> <node-> [DC <dc_value>] [AC <mag> [<phase>]] [<waveform>] [M=<m>
1313
| `node+`, `node-` | Current flows from node+ through the source to node- |
1414
| `DC <value>` | DC current value |
1515
| `AC <mag> [phase]` | AC magnitude and phase |
16-
| `waveform` | Time-domain waveform (PULSE, SIN, PWL, SFFM, AM) |
16+
| `waveform` | Time-domain waveform (`PULSE`, `SIN` / `SINE`, `EXP`, `PWL`, `SFFM`, `AM`, wave-file input) |
1717
| `M=m` | Multiplier (equivalent to m parallel sources) |
1818

1919
## Examples
@@ -41,11 +41,15 @@ Current sources support the same waveform types as voltage sources:
4141

4242
- `PULSE` — Rectangular pulse train
4343
- `SIN` / `SINE` — Sinusoidal
44+
- `EXP` — Exponential rise/fall
4445
- `PWL` — Piecewise linear
4546
- `SFFM` — Single-frequency FM
4647
- `AM` — Amplitude modulation
48+
- `wavefile=<path> chan=<n> [amplitude=<scale>]` / `WAVE` — Wave-file input
4749

48-
See the [V — Voltage Source](voltage-source.md) article for waveform syntax details.
50+
See the [V — Voltage Source](voltage-source.md) article for waveform syntax,
51+
LTspice finite-cycle `PULSE`, unsupported finite-cycle `SINE`, wave-file
52+
diagnostics, and LTspice source-option notes.
4953

5054
## Behavioral Current Source
5155

‎src/docs/articles/tran.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ Transient analysis is typically paired with time-domain sources:
6262
```spice
6363
V1 IN 0 PULSE(0 5 0 10n 10n 500u 1m)
6464
V2 SIG 0 SIN(0 1 1k)
65+
V3 EDGE 0 EXP(0 5 1u 100n 10u 200n)
6566
```
6667

67-
See the individual waveform documentation for `PULSE`, `SIN`, `PWL`, `SFFM`, and `AM`.
68+
See the [voltage-source waveform documentation](voltage-source.md#waveform-types)
69+
for `PULSE`, `SIN` / `SINE`, `EXP`, `PWL`, `SFFM`, `AM`, wave-file input,
70+
and LTspice compatibility notes.
6871

6972
## MNA View
7073

‎src/docs/articles/voltage-source.md‎

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,37 +31,73 @@ V1 IN 0 AC 1
3131

3232
## Waveform Types
3333

34+
Waveforms can be written in function form, for example `PULSE(...)`, or as a
35+
waveform name followed by parameters, for example `PULSE 0 5 0 1n 1n 5u 10u`.
36+
The same waveform syntax is available on independent current sources.
37+
3438
### PULSE — Rectangular Pulse Train
3539

3640
```
3741
PULSE(<v1> <v2> <delay> <rise> <fall> <pulse_width> <period>)
42+
PULSE(<v1> <v2> <delay> <rise> <fall> <pulse_width> <period> <Ncycles>)
3843
```
3944

4045
```spice
4146
V1 IN 0 PULSE(0 5 0 10n 10n 500u 1m)
47+
V2 GATE 0 PULSE(0 1 2n 1n 1n 3n 10n 2)
4248
```
4349

44-
### SIN — Sinusoidal
50+
The seven-argument form is the normal repeating pulse train. The eight-argument
51+
LTspice finite-cycle form is available only when `CompatibilityOptions.LTspice`
52+
is enabled. In that mode, `<Ncycles>` limits the source to that many periods and
53+
then returns it to `<v1>`. The period and cycle count must be positive.
54+
55+
### SIN / SINE — Sinusoidal
4556

4657
```
4758
SIN(<offset> <amplitude> <frequency> [<delay> [<damping> [<phase>]]])
59+
SINE(<offset> <amplitude> <frequency> [<delay> [<damping> [<phase>]]])
4860
```
4961

5062
```spice
5163
V1 IN 0 SIN(0 1 1k)
5264
V2 SIG 0 SIN(2.5 2.5 60 0 0 0)
5365
```
5466

67+
LTspice finite-cycle `SINE` arguments are recognized in LTspice compatibility
68+
mode, but they are not mapped yet and produce a targeted validation error.
69+
70+
### EXP — Exponential Rise/Fall
71+
72+
```
73+
EXP(<v1> <v2> <td1> <tau1> <td2> <tau2>)
74+
```
75+
76+
```spice
77+
V1 IN 0 EXP(0 5 1u 100n 10u 200n)
78+
```
79+
80+
`EXP` starts at `<v1>`, rises toward `<v2>` after `<td1>` with time constant
81+
`<tau1>`, and falls back toward `<v1>` after `<td2>` with time constant
82+
`<tau2>`. Both time constants must be positive.
83+
5584
### PWL — Piecewise Linear
5685

5786
```
58-
PWL(<t1> <v1> <t2> <v2> ... [repeat])
87+
PWL(<t1> <v1> <t2> <v2> ...)
88+
PWL file = "<path>"
5989
```
6090

6191
```spice
6292
V1 IN 0 PWL(0 0 1m 5 2m 5 3m 0)
93+
V2 IN 0 PWL file = "Resources\pwl_reference.txt"
6394
```
6495

96+
Inline PWL data uses time/value pairs. File-backed PWL data reads a local text
97+
file with a header row followed by two numeric columns; spaces, commas,
98+
semicolons, and tabs are recognized from the first line. Broader LTspice PWL
99+
file and repeat variants are not claimed yet.
100+
65101
### SFFM — Single-Frequency FM
66102

67103
```
@@ -74,7 +110,44 @@ V1 IN 0 SFFM(0 1 1k 5 100)
74110

75111
### AM — Amplitude Modulation
76112

77-
Available for amplitude-modulated waveforms.
113+
```
114+
AM(<amplitude> <offset> <modulation_freq> <carrier_freq> [<delay> [<carrier_phase> [<signal_phase>]]])
115+
```
116+
117+
```spice
118+
V1 IN 0 AM(1 0 100 10k 0 0 0)
119+
```
120+
121+
### Wave-File Input
122+
123+
```
124+
wavefile=<path> chan=<n> [amplitude=<scale>]
125+
WAVE wavefile=<path> chan=<n> [amplitude=<scale>]
126+
```
127+
128+
```spice
129+
V1 IN 0 wavefile="input.wav" chan=0 amplitude=0.5
130+
V2 IN 0 WAVE wavefile="input.wav" chan=1
131+
```
132+
133+
Wave-file input converts the selected audio channel to a PWL waveform. The
134+
channel must be explicit; LTspice channel defaults are not inferred. Missing
135+
`wavefile=`, missing `chan=`, missing files, and invalid channel expressions
136+
produce targeted validation diagnostics.
137+
138+
## LTspice Source Compatibility
139+
140+
With `CompatibilityOptions.LTspice`, independent sources also support
141+
`tbl=(expr,x1,y1,...)`, which is lowered to the existing behavioral
142+
`table(...)` expression path:
143+
144+
```spice
145+
V1 OUT 0 tbl=(V(IN), 0,0, 1,5)
146+
```
147+
148+
Topology-changing LTspice source options such as `Rser`, `Cpar`, `load`, and
149+
`R=<value>` are recognized as unsupported and reported with targeted errors.
150+
They are not silently ignored or synthesized into extra components.
78151

79152
## Behavioral Voltage Source
80153

0 commit comments

Comments
 (0)