Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Ngspice reference catalog

Effective documentation for the Ngspice dialect (spiceLsp.dialect = "ngspice"): shared entries plus dialect overlays.

Source of truth: JSON under reference/. Hover in the editor uses the same corpus.

Index

NameKindSummarySource
.acdirectiveSmall-signal AC frequency analysisshared
.dcdirectiveDC sweep analysisshared
.enddirectiveEnd of netlistshared
.endsdirectiveEnd a subcircuit definitionshared
.icdirectiveSet initial node voltagesshared
.includedirectiveInclude another netlist fileshared
.modeldirectiveDefine a device modelshared
.opdirectiveDC operating-point analysisshared
.paramdirectiveDefine a named parametershared
.printdirectivePrint analysis results as a tableshared
.subcktdirectiveBegin a subcircuit definitionshared
.tempdirectiveSet circuit temperature(s)shared
.trandirectiveTransient analysis (Ngspice)dialect
CelementCapacitorshared
RelementResistorshared
XelementSubcircuit instanceshared

Directives

.ac

shared.directive.ac — Small-signal AC frequency analysis

.ac {LIN|DEC|OCT} np fstart fstop
ParameterDescriptionUnits
`LINDECOCT`
npNumber of points (LIN) or points per decade/octave (DEC/OCT).
fstartStart frequency.Hz
fstopStop frequency.Hz

Examples

  • .ac DEC 10 1k 1G
  • .ac LIN 100 1 1Meg

.dc

shared.directive.dc — DC sweep analysis

.dc srcname start stop step
ParameterDescriptionUnits
srcnameIndependent source, parameter, or TEMP to sweep.
startSweep start value.
stopSweep stop value.
stepIncrement between points.

Examples

  • .dc V1 0 5 0.1
  • .dc TEMP 0 100 25

.end

shared.directive.end — End of netlist

.end [comment]
ParameterDescriptionUnits
commentOptional trailing comment.

Examples

  • .end
  • .end my_circuit

.ends

shared.directive.ends — End a subcircuit definition

.ends [name]
ParameterDescriptionUnits
nameOptional subcircuit name; should match .subckt.

Examples

  • .ends
  • .ends buffer

See also: shared.directive.subckt

.ic

shared.directive.ic — Set initial node voltages

.ic V(node)=value [V(node2)=value2 ...]
ParameterDescriptionUnits
V(node)Node voltage to initialize.V

Examples

  • .ic V(out)=0
  • .ic V(in)=1.8 V(out)=0

.include

shared.directive.include — Include another netlist file

.include 'filename'
ParameterDescriptionUnits
filenamePath to the file to include (quotes recommended).

Examples

  • .include 'models.inc'
  • .inc 'corners/tt.sp'

See also: shared.directive.model

.model

shared.directive.model — Define a device model

.model mname type (param=value ...)
ParameterDescriptionUnits
mnameModel name referenced by instances.
typeModel type (e.g. NMOS, PMOS, D, NPN).

Examples

  • .model nmos NMOS (VTO=0.7)

.op

shared.directive.op — DC operating-point analysis

.op

Examples

  • .op

Computes node voltages and bias points. Many simulators also print an operating point before .tran / .ac unless UIC is used.

.param

shared.directive.param — Define a named parameter

.param name=value [name2=value2 ...]
ParameterDescriptionUnits
nameParameter identifier.
valueNumeric value or expression.

Examples

  • .param rload=1k
  • .param pi=3.14159

.print

shared.directive.print — Print analysis results as a table

.print {DC|TRAN|AC} ov1 [ov2 ...]
ParameterDescriptionUnits
`DCTRANAC`
ovOutput variable, e.g. V(node), I(Vsrc), VM(node).

Examples

  • .print TRAN V(out) I(Vdd)
  • .print DC V(2) V(3)

.subckt

shared.directive.subckt — Begin a subcircuit definition

.subckt name n1 [n2 ...] [params: p=val ...]
ParameterDescriptionUnits
nameSubcircuit name.
n1...External port nodes in order.

Examples

  • .subckt buffer in out
  • .subckt inv in out

See also: shared.directive.ends

.temp

shared.directive.temp — Set circuit temperature(s)

.temp t1 [t2 ...]
ParameterDescriptionUnits
t1Temperature in Celsius (additional values run multi-temp analysis).°C

Examples

  • .temp 25
  • .temp 0 25 85

.tran

ngspice.directive.tran — Transient analysis (Ngspice)

Dialect overlay (replaces shared entry with the same name).

.tran tstep tstop [tstart [tmax]] [UIC]
ParameterDescriptionUnits
tstepSuggested printing increment.s
tstopFinal time.s
tstartOptional start of printing.s
tmaxOptional maximum timestep.s
UICUse initial conditions.

Examples

  • .tran 1n 100n
  • .tran 1u 1m 0 10u UIC

Ngspice also accepts ; and $ comments in addition to *.

Elements

C

shared.element.C — Capacitor

Cname n1 n2 value [params...]
ParameterDescriptionUnits
n1Positive node.
n2Negative node.
valueCapacitance.F

Examples

  • C1 out 0 1p

R

shared.element.R — Resistor

Rname n1 n2 value [params...]
ParameterDescriptionUnits
n1Positive node.
n2Negative node.
valueResistance.ohm

Examples

  • R1 in out 1k
  • Rload out 0 50

X

shared.element.X — Subcircuit instance

Xname n1 [n2 ...] subckt_name [params...]
ParameterDescriptionUnits
n1...Nodes connected to subcircuit ports.
subckt_nameName of a .subckt definition.

Examples

  • X1 a b buffer