Analog & Mixed-Signal Design — Installation
What You're Setting Up
Overview's op-amp gain equations are closed-form and hand-calculable. This section sets up a Python-based op-amp gain calculator, plus ngspice — the standard free, open-source, actively maintained SPICE circuit simulator, for actually simulating real op-amp circuits rather than only computing their ideal gain by formula.
Install Python
No extra packages needed for the gain calculator.
Verify Your Setup — Recompute Overview's Op-Amp Gain Examples
This reproduces Overview's worked inverting and non-inverting gain calculations.
A Second Check — the Try It Circuit
Reproducing Overview's Try It exercise (Rf = 20 kΩ, Rin = 2 kΩ, Vin = 0.3 V):
Install ngspice for Real Circuit Simulation
ngspice is a free, open-source, actively maintained SPICE circuit simulator — build the actual inverting-amplifier circuit from Overview (op-amp plus two resistors) and simulate its real behavior, rather than only computing the ideal gain formula.
(needs verification — recheck against current source: exact current ngspice version changes with each release — confirm at ngspice.sourceforge.io before assuming a specific version number.)
A Simple ngspice Netlist — the Inverting Amplifier
(needs verification — recheck against current source: exact ngspice netlist syntax for behavioral/dependent sources can vary by version — confirm the current E source syntax against ngspice's own manual if this exact netlist doesn't run as shown.)
Verify Everything Works
Common Setup Issues
Python gain calculator gives a positive result for the inverting configuration
Check the formula's negative sign — inverting_gain must include the explicit - in -(Rf / Rin) * Vin; omitting it produces a magnitude-correct but sign-wrong result, which defeats the entire point of distinguishing inverting from non-inverting configurations.
ngspice simulation result doesn't closely match the ideal formula's -5.0 V
Check the op-amp's modeled open-loop gain (the 100000 in the Eopamp dependent-source line above) — a real op-amp has finite (though very high) open-loop gain, and the ideal formula assumes infinite gain; a very low modeled gain value will produce a real, visible deviation from the ideal formula's prediction, which is itself a genuine and useful observation about where the ideal-op-amp assumption breaks down, not necessarily a simulation error.
ngspice command not found after installing
Confirm the install actually completed (dpkg -l | grep ngspice on Debian/Ubuntu) — a failed package install due to a network issue during apt update is a more common cause than a PATH problem specifically for ngspice.
What's Set Up
Next Steps
Go to the Fundamentals section to continue with ADC/DAC quantization error, computed with real numbers.

