Skip to content
Stable.cir@modelscript/spice 10 diagnostic rules
Parser WASM GLR
Diagnostics 10 rules
DAE Arena Lowering
Simulation Native Solvers
Projections Modelica, ECAD
Live ExampleSallenKeyActiveFilter.cir

SPICE Second-Order Low-Pass Filter & Clamping Stage

Analog circuit netlist combining an AC sinusoidal source, two-stage RC filter network, PN junction clamping diode, and transient directive.

Playground
Source (10 lines)
1* Second-Order RC Low-Pass Filter with Clamping Diode
2V1 in 0 SIN(0 5.0 1k)
3R1 in n1 1.5k
4C1 n1 0 47n
5R2 n1 out 2.2k
6C2 out 0 22n
7D1 out 0 DMOD
8.model DMOD D(Is=2.52n Rs=0.568 N=1.752)
9.tran 5u 2m
10.end
SPICE Analog Circuit Schematic
Second-Order RC Low-Pass Filter with Clamping Diode — SPICE Circuit Schematic VSRC V1 ⊝ V ⊕ RES R1 ─╱╲╱╲─ 1.50kΩ CAP C1 ─││─ 47.0nF RES R2 ─╱╲╱╲─ 2.20kΩ CAP C2 ─││─ 22.0nF DIODE D1 ─▷|─
Drag to pan · Click % to reset

SPICE Electronics & Analog Circuit Simulation ​

ModelScript features high-performance native support for SPICE (.cir, .sp, .net, .lib) netlists and analog circuit analysis. Engineers can validate electrical schematics, detect topological faults (floating nodes, voltage source loops), execute pure in-WASM circuit simulations, and export to Modelica or ECAD netlist graphs.


Capabilities & Supported Formats ​

FormatExtensionDescription
SPICE Netlist.cir, .sp, .netCircuit description specifying passive components (R, L, C), active semiconductors (diode, BJT, MOSFET), independent/dependent sources, subcircuits, and simulation directives.
SPICE Model Library.lib, .modDevice physics parameters for transistors, diodes, op-amps, and macro-models.

Key Architectural Features ​

  • Engineering Unit Netlist Parser:
    • Robust lexer parsing metric prefixes (f, p, n, u, m, k, meg, g, t), curly brace math expressions {R1 * 2}, line continuations (+), and subcircuit definitions (.SUBCKT / .ENDS).
    • Lossless round-trip serializer (serializeSpice()).
  • Native Numerical Solvers:
    • DC Operating Point (.OP): Assembles Modified Nodal Analysis (MNA) matrix Gv=i with Newton-Raphson iteration for non-linear PN junctions.
    • Transient Simulation (.TRAN): Numerical companion-circuit integration supporting Trapezoidal rule with damping for reactive elements (L,C).
    • AC Small-Signal Frequency Sweep (.AC): Complex admittance matrix Y(jω) solving decade/octave/linear frequency sweeps and bode response.
  • Circuit Linter Rules (M7101–M7109):
    • Identifies single-connection floating nodes, parallel ideal voltage sources, cutsets of ideal current sources, non-positive passives, and subcircuit pin mismatches.
  • Bilateral Modelica & ECAD Projections:
    • Translates SPICE netlists to standard Modelica.Electrical.Analog components.
    • Projects to generic NetlistGraph data structures for PCB layout, schematic capture, and Design Rule Checking (DRC).

Command Line Interface (msx spice) ​

bash
msx spice <action> [files...] [options]
ActionDescriptionKey Options
simulateRuns DC operating point, transient, or AC analysis (AC sweep from the .AC card).--analysis op|tran|ac, --tstep, --tstop, --format table|json|csv, --out
lintRuns pre-flight structural and electrical rule checks.--format
inspectDumps topology, component breakdown, nodes, models, subcircuits, and directives.--format, --out
to-modelicaTranslates the netlist to Modelica 3.x electrical components and connections.--out
to-ecadProjects the netlist to an ECAD netlist graph for PCB routing and DRC.--out
to-daeLowers the netlist directly into the linear-memory DAE arena.--format, --out
diagramRenders the circuit schematic to SVG or a JSON graph.--format, --out
syncSynchronizes tuned parameters and topology from Modelica back into the netlist.--from-modelica, --strategy, --out

Examples ​

bash
# Calculate DC bias voltages on all circuit nodes
msx spice simulate LowPassFilter.cir --analysis op

# Simulate transient step response and export trajectory
msx spice simulate PowerSupply.cir --analysis tran --tstep 1e-6 --tstop 0.01 --out transient.csv

# Run the AC frequency response defined by the netlist's .AC directive
msx spice simulate AudioAmplifier.sp --analysis ac --format csv --out bode.csv

# Lint netlist for floating electrical nodes and ground connectivity
msx spice lint SensorFrontEnd.net

Electrical Linters & Diagnostic Rules ​

10 rules9 error1 warning Run with msx lint

CodeRuleSeverityMessage
M7101spice-floating-nodeerrorFloating node '<nodeName>' has no DC reference path to ground.
M7102spice-voltage-looperrorVoltage source '<vName>' forms a closed loop of ideal voltage sources without series resistance.
M7103spice-current-cutseterrorNode '<nodeName>' is connected strictly to ideal current sources (current cutset).
M7104spice-unresolved-subcircuiterrorSubcircuit '<subName>' is referenced by '<compName>' but not defined.
M7105spice-invalid-passive-valueerrorPassive component '<compName>' has invalid non-positive value <val>.
M7106spice-timestep-violationerrorTransient analysis directive specifies invalid timestep '<tstep>' or stop time '<tstop>'.
M7107spice-duplicate-deviceerrorDuplicate component name '<compName>' detected in circuit scope.
M7108spice-missing-modelerrorActive device '<compName>' references undefined model '<modelName>'.
M7109spice-pin-count-mismatcherrorSubcircuit instance '<compName>' connects <nodeCount> pins but definition '<subName>' expects <portCount> ports.
M7110spice-malformed-directivewarningMalformed or unsupported directive '<dirName>'.

Generated from languages/spice/src/lints/rules.ts. All languages →

Open-Core under the GNU AGPL v3 License; Enterprise Edition (ee/) under the ModelScript Enterprise License. • Trademark Policy