Say you want to build a circuit that does some kind of signal processing. You draw your schematic in a paper, make your hand calculations, select the components, build the circuit, turn it on, and it does not do what you were expecting... or even worse, it damages one or more components in the process. Finding the flaw in the circuit and even replacing the lost components may be a pain.
From the selection of the components forward, you could have chosen another path. You could have simulated your circuit in a circuit simulation software. This has several advantages:
That being said, circuit simulators are ever more accurate and are an indispensable tool for electronic engineers. They reduce development time and cost.
While the focus of this topic is on the analog circuit simulation, others exist that deserve their reference.
This type is what is usually referred as circuit simulation. A circuit, by its nature analog, is simulated, while registering and displaying the voltages at the nodes and currents flowing through the components.
Digital circuits are usually written in a RTL (Register-Transfer Level) language, such as Verilog or VHDL. These languages describe the circuit through links (e.g. node A is connected to node B by some combinatorial logic) or through events (e.g. when clock rises). Either way, the simulation of this type of language only looks for changes in the digital signals, and it is therefore event-driven.
The purpose of mixed-mode simulators is to combine the two previous types of simulation. They integrate digital with analog signals, but keep the digital blocks event-driven (faster simulation) and the analog blocks as usual.
The not so well known piecewise linear type of simulation consists in changing between analog models at certain conditions. In power electronics, where nowadays switching circuits are dominant, the switching alters the topology of the circuit. The advantage is that, given the flexibility to change the analog model, it can be made linear (hence piecewise linear), which improves speed and stability.
Circuit simulators are complex pieces of code that rely heavily on optimization techniques. They start with models of the components, which mimic their behavior with a certain level of accuracy. The drawn schematic provides not only the components to be used but also how they connect to each other.
Both of these combined allow the generation of a netlist, a piece of text that describes each component used in the circuit and to where they connect.
v1 1 0 dc 5
r1 1 2 10k
c1 2 0 10u
The above example is the SPICE netlist for the schematic in the right. SPICE (Simulation Program with Integrated Circuit Emphasis) is the most used circuit simulation engine and it is open-source. It receives a netlist that describes the circuit, and performs several types of simulations. The simulation commands can also be incorporated in the netlist.
Back to the netlist, the first column is the name of the component, attributed sequentially or user defined. The next columns are the nodes it is connected to (two for voltage sources, resistances and capacitors, but can be more; 0 always refers to the reference or ground). Names started with "r" are resistances, with "c" are capacitors and with "v" are independent voltage sources. Other letters mean other standard components. The remaining columns are component-specific information: "dc 5" means 5V DC, while for resistances and capacitors the only necessary information is their value. As you can see, with these 3 parts:
How each component behaves is provided by models. Each component has a model, with its own parameters. For instance, the resistance model needs the resistance value, while a capacitance model has the initial condition (ic) optional value (the voltage at the capacitance when the simulation starts). This could be added to the netlist as such:
c1 2 0 10u ic=0
Finally, commands that describe what type of analysis to run and its specific options are appended to the netlist. For example
is a DC analysis and requires no parameters.
.AC lin NP SF EF
requests an AC analysis and requires the starting (SF) and ending (EF) frequencies and the number of frequencies to be analyzed in between (NP), among others. The types of analysis are covered in a later section.
The netlist only describes the components that make up the circuit and their connections. It is also necessary a description of how each component works. Models define the relation between voltages and currents at the terminals of a device. For example, the model of a resistance has a linear relation between the voltage at its terminals and the current flowing through it. The model of a capacitance relates the change in the voltage at its terminals with the current flowing through it. A MOSFET or bipolar transistor, besides having more than two terminals, has a much more complex relation between the voltages and currents at its terminals. To have an idea, advanced models of integrated MOS transistors have hundreds of parameters. Even more complex models may be built by grouping simpler models.
A circuit simulator runs different types of simulations. Each gives different information about the circuit.
Analog circuits are usually built to process signals. They are operated at a steady condition (the DC operation point, bias point or quiescent point) and the AC signals fluctuate around that operating point. The most basic analysis is to keep only the DC signals and calculate where the circuit stabilizes. This analysis provides the DC voltages at every nodes and the DC currents of all terminals. Here is how it is done in Multisim.
Apart from some basic components, such as resistances, capacitances or inductors, most of the components are not linear. They can, however, be linearized around some point. The DC operating point analysis gives the point where the circuit will operate, hence, where it can be linearized. This will affect the sensitivity of each component to their parameters (in the plot above, the sensitivity $\partial y/ \partial x$ is dependent on the operating point because the relation is nonlinear). Having a linear circuit, with the small-signal models of each component, all AC signals applied to the circuit can be superimposed to measure the resulting effect on each node. Furthermore, given the frequency dependent behavior of capacitances and inductances, the result also changes with the frequency of the AC signals. Since the circuit is now linear, if sinusoidal signals are applied to the circuit, only sinusoids with the same frequency must exist in any node.
Therefore, the AC analysis performs these measurements and takes the amplitude and phase of a sinusoid at a certain node for a range of frequencies. The simulation then plots the amplitude and phase for that range, resulting in a bode plot.
The transient analysis simulates the response of the circuit to a transient input, in the time domain. This analysis comes naturally, as it is the one that most resembles what you see when you turn on the circuit, apply signals and read a voltage in the oscilloscope. This is the simulation that takes the longest, as the circuit needs to be traced during a certain period of time, and the nonlinear equations need to be calculated.
Every component generates noise, even a simple resistance. Noises have known spectrums and are uncorrelated. They can be seen as unpredictable, unwanted small signals. Similarly to the AC analysis, the circuit can be linearized around its operating point and the sources of noise can be superimposed. The noise analysis measures the noise at a given node. Since the spectrums are known, the measure can be given in the form of a bode plot, its PSD (Power spectral density) at a given frequency, or its power in a band of frequencies.
Fabricated components have deviations from sample to sample. The reason is that, due to the fabrication process, every parameter of a component can be in a range of values (with its corresponding mean), instead of a single value. Nominal circuit simulation (all of the above) uses the average value of the parameters for simulation.
Specially in the semiconductor industry, it is equally important to simulate the circuit for the complete range of parameter values, because the yield (the percentage of circuits that pass the specification) is highly dependent on it. Here is an example: an opamp needs to have a voltage gain greater than 100000. The nominal simulation measures a gain of 120000. However, a Monte Carlo simulation will measure the gain for many samples extracted from the range of parameters. As a result, only 60% of the trials actually have a gain greater than 100000. If this circuit was to be fabricated, nearly half of the production would go to the trash. As you can see, design a circuit to guarantee a high yield is very important when thinking about production.
Monte Carlo is not a different analysis per se, but uses other analysis instead. Parameters usually follow a Normal distribution (although others can be used), with a given mean and standard deviation. Each trial from the Monte Carlo simulation takes a value out of the distribution and runs the simulations explained above with that parameter value.
The result from the simulation is a histogram for each measurement. For our opamp example, the histogram of the gain would have a mean of 120000. 40% of the samples (the left side) would be below 100000.