4. Simulation using NGSPICE
4.1. NGSPICE installation
Ngspice is an open source simulator hosted at this page. The tool is well documented and the user manual can be found here. In order to install ngspice the recommended method is the following:
git clone https://git.code.sf.net/p/ngspice/ngspice ngspice-ngspice
cd ngspice-ngspice
./autogen.sh
./configure --enable-osdi
make
sudo make install
cd ..
rm -rf ngspice-ngspice
4.2. NGSPICE basic testcases
A basic spice level netlist, which simulates operating point of a npn13G2 HBT transistor, is shown below:
**.subckt dc_hbt_13g2
Vce net3 GND 1.2
I0 GND net1 1u
Vc net3 net2 0
.save i(vc)
XQ1 net2 net1 GND GND npn13G2l Nx=1 le=1.0e-6
.lib cornerHBT.lib hbt_typ
.param temp=27
.control
save all
op
print I(Vc)
.endc
.GLOBAL GND
.end
The netlist can be saved as dc_hbt_13g2.spice and simulated calling the following command:
ngspice -b dc_hbt_13g2.spice
The user should get the following output:
Note: Compatibility modes selected: hs a
Circuit:
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Using SPARSE 1.3 as Direct Linear Solver
No. of Data Rows : 1
i(vc) = 6.492800e-04
Note: Simulation executed from .control section
.lib cornerMOSlv.lib mos_tt
Vgs net1 GND 0.4
Vds net3 GND 1.0
Vd net3 net2 0
.param temp=27
XM1 net2 net1 GND GND sg13_lv_nmos w=1.0u l=0.13u ng=1 m=1
.control
save all
op
let Id = @n.xm1.nsg13_lv_nmos[ids]
print Id
.endc
.GLOBAL GND
.end
The netlist can be saved as mostest.spice and simulated calling the following command:
ngspice -b mostest.spice
The following output should be observed
Note: Compatibility modes selected: hs a
Warning: m=xx on .subckt line will override multiplier m hierarchy!
Circuit: mostest
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Using SPARSE 1.3 as Direct Linear Solver
No. of Data Rows : 1
id = 1.145621e-06
Note: Simulation executed from .control section