MCPcopy Index your code
hub / github.com/dan-fritchman/Spice21

github.com/dan-fritchman/Spice21 @v0.1.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.5 ↗ · + Follow
475 symbols 1,819 edges 48 files 137 documented · 29%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Spice21

SPICE for the 21st century


test


Circuit Simulation Circa 2020

Spice21 is a circuit simulation library akin to the original Berkeley Simulation Program with Integrated Circuit Emphasis, designed around a set of principles for 21st century users:

Spice is a library, not a program.

Circuit simulation almost always is (or should be) embedded in a larger program - whether iterating over circuit conditions or performing design exploration. Spice21 is designed for such embedding. Circuits are data in the program - not schematics entombed in an 80s-grade GUI or intractable netlist-languages.

You may ask: which programming language do I need for this embedding? How about whatever language you like.

Spice21 is implemented in Rust and uses Google's Protocol Buffers for most input and output data. A set of thin wrappers provide bindings to just about any language that supports Protobuf.

Don't Do Stupid (Old) Shit

Spice was born a generation ago, and had a lifetime to accumulate mistakes. Throw them out. Spice21 includes no:

Stupid file formats. Spice21 has no custom netlist, output, or any other dreamt-up file-formats that will require anyone to parse anything, ever. Circuits are defined in the Protobuf schema language. All output lives in open, popular data formats.

Outdated device models and analyses. Transistor models will come in two flavors: the simplest, and the newest and most relevant. To date no open-source SPICE supports BSIM-CMG, the industry-standard model for now-industry-standard FinFETs. Remedying this is a near-term concern.

Intractable options nobody ever uses. Careers-worth of circuit design and simulation experience have taught us how to set these things. We're throwing out all the lessons un-learned along the way.

No Shortcuts

Spice21 doesn't take any shortcuts to simulating transistor-level circuits. There are no table-based "FastSpice" tactics, circuit simplifications, or attempts to categorize or tailor to particular circuit families. This is a fully general-purpose circuit solver; throw it whatever pile of transistors you like.

Open Souce

Spice21 is distributed under a permissive open-source license for all.

Installation

Rust

Add spice21 to the Cargo.toml of any Rust project.

[dependencies]
spice21 = "0.1.5"

Python

pip install spice21py

Pip will detect whether your combination of OS and Python interpreter have pre-compiler wheel-distributions of Spice21. If not, it'll run a source-build which will require installing the Rust compiler. (This will generally take < 1 minute.)

JavaScript

npm install spice21js

Or

yarn add spice21js

Status

Spice21 is in early-days development. Versions 0.1.x support transient, operating-point, and AC analysis of circuits including level-one MOS, passives, diodes, and independent sources.

Thanks

Spice21 is a descendant of a long line of circuit simulators, many borne at the University of California, Berkeley. Several component models are adapted from their original Berkeley SPICE implementations.

Extension points exported contracts — how you extend this code

Component (Interface)
(no doc) [10 implementers]
spice21/src/comps/mod.rs
ToBuffer (Interface)
Node-Buffer Conversion Trait Courtesy the Neon team. Converts binary array/vector-ish Rust-things (`Vec `, `&[u8]`) [1 …
spice21js/native/src/lib.rs
SpProto (Interface)
# SpProto Custom Message Trait Largely an extension of `prost::Message`, derived for each Spice21 `Message` type.
spice21int/src/lib.rs
CallableProto (Interface)
# Callable Protobuf Trait Defines an RPC-like single-argument, single-return type trait-interface used by many of the S [3 …
spice21/src/proto.rs
JsCall (Interface)
(no doc) [3 implementers]
spice21js/native/src/lib.rs
Abs (Interface)
Absolute Value Trait for numeric types [2 implementers]
spice21/src/spnum.rs
SpNum (Interface)
This long list of traits describes our required behavior for numeric types. [1 implementers]
spice21/src/spnum.rs
CacheEntry (Interface)
(no doc) [2 implementers]
spice21/src/defs.rs

Core symbols most depended-on inside this repo

assert
called by 152
spice21/src/assert.rs
push
called by 145
spice21/src/writer.rs
exp
called by 95
spice21/src/comps/cmath.rs
make_matrix_elem
called by 92
spice21/src/comps/mod.rs
sqrt
called by 79
spice21/src/comps/cmath.rs
len
called by 73
spice21/src/analysis.rs
get
called by 68
spice21/src/defs.rs
log
called by 56
spice21/src/comps/cmath.rs

Shape

Method 202
Function 171
Class 77
Enum 15
Interface 10

Languages

Rust95%
Python4%
TypeScript1%

Modules by API surface

spice21/src/sparse21/mod.rs84 symbols
spice21/src/tests.rs60 symbols
spice21/src/analysis.rs42 symbols
spice21/src/comps/mos.rs34 symbols
spice21/src/circuit.rs29 symbols
spice21/src/comps/mod.rs26 symbols
spice21/src/assert.rs24 symbols
spice21/src/comps/diode.rs19 symbols
spice21py/spice21py/tests/test_spice21.py13 symbols
spice21/src/comps/bsim4/bsim4solver.rs13 symbols
spice21/src/elab.rs12 symbols
spice21/src/defs.rs12 symbols

For agents

$ claude mcp add Spice21 \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page