eCircuit  Center

SPICE Topics


About SPICE | SPICE Basics | Running SPICE | CIRCUIT COLLECTION | SPICE Commands | SPICE Demos and Downloads
About Us | Contact Us | Home  | Search
 

 

 

 

SPICE ALGORITHM OVERVIEW

Regardless if you have a great or small interest in understanding how SPICE works, its a good idea to get a basic grasp of it. Why? For the same reason it helps to have basic understanding of how your car works - when things go wrong. The same holds true with SPICE. Sooner or later, your simulation grinds to halt and you'll need to peer under the hood and start tinkering to get it going again. There's another reason to see the big picture. Not only to satisfy your curiosity, but to get an appreciation of this marvelous tool.

 

BLOCK DIAGRAM

Here's a simplified block diagram of the main SPICE program flow. Most of SPICE's amazing capabilities (and problems) happen right here!

Here's three key points about the algorithm:

1 At the heart of the SPICE is Nodal Analysis (blocks 3 and 4) accomplished by formulating the Nodal Matrix and solving the nodal equations for the circuit voltages.

2 The inner loop (2 - 6) finds the solution for Non-Linear circuits. Non-Linear devices are replaced by equivalent linear models. It may take many iterations before the calculations converge to a solution.

3 The outer loop (7 - 9), together with the inner loop, performs a Transient Analysis creating equivalent linear models for energy-storage components for capacitors, inductors, etc. and selecting the best time points.

Top↑
 

ALGORITHM IN ACTION

In a nutshell, SPICE can do the following:

»  DC Analysis
»  Transient Analysis (Time Response)
»  AC Analysis (Frequency Response)

Based on these main muscles, SPICE also serves up some extended analysis like sensitivity, Fourier, noise, etc. But, lets take a look at some of the main analysis and see which parts of the algorithm are called into action to perform them.

Top↑
 

DC ANALYSIS

DC Analysis is performed either to calculate a DC Operating Point or a DC Sweep. An operating point is required for the initial solution to a Transient Analysis or as a bias point for an AC Analysis. The DC Sweep does exactly as the name implies - performs the DC Analysis multiple times as you sweep a selected component parameter across a defined range. All energy-storage components like capacitors, inductors and semiconductor charge mechanisms are ignored for this analysis!

One of the simpler tasks for SPICE is performing DC Analysis on Linear circuits. Only two of the blocks are really needed: Load the Nodal Matrix (3) and solve the Nodal Equations (4) using Gaussian Elimination. (See Nodal Analysis.) One important point - Nodal Analysis works for a system of linear equations.

For Non-Linear circuits SPICE needs to create equivalent linear models for the non-linear devices! But, it can only guess at the operating point for which the models are created. The loop (blocks 1-6) iteratively finds the exact solution as follows: guess an operating point, create equivalent linear models and solve the Nodal Matrix for the circuit voltages. Then, choose a new operating point based on the new voltages and start all over again. How does SPICE know when to stop? When the changes in circuit voltages and currents have fallen below some limit, from one iteration to the next, the solution is said to have converged! (See Non-Linear Analysis.) This is known as the Raphson-Newton solution of non-linear circuits.

Top↑

 

TRANSIENT ANALYSIS

To perform a Transient Analysis for Linear Circuits, SPICE completes the outer loop only, ignoring blocks 2 and 5. After the initial operating point is found, the energy-storage components (capacitors, inductors, semiconductor junctions) are transformed into linear companion models, well suited for the Nodal Equation solver. (See Transient Analysis.). For Non-Linear Circuits, SPICE completes the Non-Linear loop (2-6) at each time point of the Transient Analysis.

SPICE dynamically adjusts the time step, h(n). Why? For two reasons - to improve accuracy and reduce long simulation times. The time step will be reduced when circuit voltages and currents are changing rapidly. Under these conditions, accuracy generally improves with a smaller time step. On the other hand, if nothing much is happening dynamically in a circuit, increase the time step to avoid a painfully long simulation.

Top↑
 

AC ANALYSIS

The AC Analysis happens in two parts.

Part 1  SPICE performs the Non-Linear Circuit loop (1-6) to find the DC Operating Point (See DC Analysis above.) This loop ignores all capacitors, inductors and other energy storage components.

Part 2  This part performs blocks 3 and 4 - but with slightly modified versions. SPICE loads the Nodal Matrix with the Real and Imaginary Parts of impedances for the resistors, capacitors and inductors. For components like semiconductors, SPICE replaces non-linear behaviors by their linearized small signal equivalents. Finally, power supplies are set to zero, the signal source is set to unity, and blocks 3 and 4 are repeated for all requested frequencies. Nodal Analysis calculates the result in terms of Magnitude and Phase for each node voltage.

Top↑
 

SPICE CONTROL

Although most SPICE simulations runs smoothly, sometimes the program sputters to a halt. What would cause it to stop? Just a pick a block in the diagram and you've got a potential problem. That's one of the reasons why there are so many Options available for running a SPICE simulation. For example, options adjust parameters such as:

  • the maximum iterations allowed in the Non-Linear loop

  • the criterion for when a solution has converged

  • how to select the initial operating point

  • how the time steps are chosen in a Transient Analysis

  • which method is used to create linear companion models

The good news is that users are given reasonable control over the simulation. Sometimes the  simple tweeking of an option can get your simulation going again. The bad news is the number of options and correctly adjusting them. In later topics covering options, SPICE troubles, and convergence (or non-convergence), we'll refer back to the block diagram above.

Top↑
 

NEED MORE INFO?

Here are some great sources of information about the SPICE engine.

SPICE2: A Program to Simulate Semiconductor Circuits, Lawrence W. Nagel, Memo UCB/ERL M520, 1975, University of California, Berkeley, CA.

The Spice Book, Andrei Vladimirescu, John Wiley & Sons, Inc., 1994,
ISBN 0-471-60926-9.

Inside SPICE, Ron Keilkowski, McGraw Hill, 1994, ISBN 0-07-913712-1.

For more info on these and other books go to the Bookshop.

 

Top↑

◄BACK TO SPICE TOPICS INDEX
 

 

About SPICE | SPICE Basics | Running SPICE | CIRCUIT COLLECTION | SPICE Commands
SPICE Demos and Downloads | About Us | Contact Us | Home | Search

© 2003 eCircuit Center