C11 · Lesson 24 · Circuit simulation with SPICE
What a simulator computes, and when to trust it
Every circuit in this course's sims is solved the way SPICE solves circuits: nodal equations, Newton's method for the nonlinear parts, and adaptive time steps for the transient. A simulator checks a design before anything is built, but it answers exactly the question it's asked, with exactly the models it's given. An AC sweep is a linearization that will happily show a 100 V output from a 5 V amplifier; a transient run with too coarse a time step misses a glitch; a model with the wrong saturation current puts a transistor in the wrong region. Knowing what each analysis computes is how you tell a real result from an artifact.
- An RC low-pass, analyzed two ways at once: the scope runs a transient analysis of a 1 kHz sine, and the Bode plot runs an AC analysis from 10 Hz to 1 MHz.
- Move R or C: the AC sweep's corner moves, and the transient output's size and lag change to match the AC answer at 1 kHz.
- The AC analysis is small-signal: it would give the same shape for a 1 mV or a 1000 V input. Only the transient analysis respects nonlinearity and limits.
Predict
An AC analysis is run on an amplifier powered from ±5 V with a gain of 100 and a 1 V input. What output does it report?
100 V. AC analysis linearizes every device at the DC operating point and solves a linear circuit, so the output is just gain times input, however large. Treat AC results as gains and phases, and check large signals with a transient run.
Name it
Kinds of analysis
| Analysis | Computes | Use for |
|---|---|---|
| operating point (.op) | DC node voltages and currents, nonlinear devices solved | bias checks; always run first |
| DC sweep (.dc) | the operating point as a source or parameter varies | transfer curves |
| AC (.ac) | small-signal gain and phase, linearized at the operating point | frequency response, stability |
| transient (.tran) | the full nonlinear response over time | waveforms, clipping, switching, startup |
| noise, Monte Carlo, worst case | noise spectra; spread over part tolerances | performance and yield |
How it solves
Nonlinear circuits are solved by Newton's method: linearize every device at a guess, solve, repeat. Near the answer the error roughly squares each iteration, so convergence is fast once close. When it fails ("no convergence"), simulators fall back on gmin stepping (adding small conductances) and source stepping (ramping the supplies). Transient analysis advances in steps sized by an error estimate; to resolve a signal at f with N points per cycle, steps must be about or smaller.
Trusting results
- Check the operating point before anything else: a transistor in the wrong region invalidates every other analysis.
- A model is only as good as its parameters: manufacturer models, measured if possible.
- Results that look too good (perfect matching, infinite bandwidth) usually mean a part was left ideal.
- Monte Carlo runs the circuit many times with parts drawn from their tolerance distributions; the fraction that meets the spec estimates the yield. With Gaussian spreads, a spec at ±kσ passes a fraction : 95.4% at 2σ, 99.73% at 3σ.
Worked example
Newton's method starts with an error of 0.1 V, and the error squares each iteration. How many iterations to reach 10⁻⁸ V?
Show the solution
- Square the error each iteration. That's three iterations.
- Compare with halving. That's quadratic convergence; a method that only halved the error would need 24.
Answer three iterations.
Worked example
A Monte Carlo run shows an output with a Gaussian spread; the spec is the mean ± 3σ. What yield should production expect?
Show the solution
- Yield within ±3σ. or 2.7 failures per thousand.
- A tighter spec. Tightening the spec to ±2σ would fail 4.6%.
Answer a yield of 99.73%, or 2.7 failures per thousand.
Worked example
A circuit's output varies with a Gaussian spread. What yield should production expect if the specification is the mean ± 2σ, and ± 3σ?
Show the solution
- Fraction within ±kσ.
- At 2σ and 3σ.
- In parts per million. Out of specification that's 45,500 and 2,700.
- Why aim higher. A 3σ design still fails a few thousand units per million, which is why high-volume products aim for 4σ to 6σ.
Answer 95.45% for ±2σ and 99.73% for ±3σ.
Check
A transient run must show a 50 kHz signal with 20 points per cycle. What is the largest time step?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
Check
Monte Carlo shows a Gaussian output. What percentage of units fall within ±1.5σ of the mean?
Check
Newton's method starts with error 0.1, and the error squares each iteration. How many iterations until it is at or below 1 × 10⁻¹²?
Check
An AC analysis of an RC low-pass (R = 4.7 kΩ, C = 10 nF) reports what gain at 1000 Hz, in dB?
Check
An AC sweep uses 20 points per decade over 3 decades, including both ends. How many frequencies does it compute?
Check
A simulated amplifier shows a perfectly flat gain to 10 GHz. What's the most likely explanation?
Check
Newton's method starts with error 0.1 V, and each iteration squares the error (in volts).
(a)
How many iterations bring the error below 1 × 10⁻⁶ V?
(b)
What is the error after one iteration?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
Check
A design's output is Gaussian, and the specification is the mean ± 2σ.
(a)
What yield should production expect?
(b)
How many parts per million fail?
Explain why
Why should a simulation's DC operating point be checked before trusting its AC analysis?
AC analysis linearizes every nonlinear device at the operating point: a transistor's transconductance, output resistance and capacitances all depend on its bias current and voltages. If the operating point is wrong, say a transistor saturated, cut off, or biased at the wrong current because of a bad resistor value or model, the small-signal parameters are wrong too, and every gain and corner frequency computed from them is meaningless, even though the plot looks perfectly reasonable. Checking the bias first confirms that the circuit being linearized is the one intended.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.