Basic inverter simulation in Xschem
Ming Sun / November 04, 2022
11 min read • ––– views
In this blog post, let us create a simple inverter in Xschem. And then we are going to use Skywater130 PDK and Ngspice to simulate it.
Step 1 - Create the test bench
- First, import 1.8V NMOS symbol
nfet_01v8.sym
into the schematic by going tosky130_fd_pr
folder as shown below. The bindkey for import isShift-i
.
Next, follow the same above procedure and import 1.8V PMOS symbol
pfet_01v8.sym
. Leave the default attribute (channel width and length) for both NMOS and PMOS.Import
vdd.sym
,gnd.sym
,vsource.sym
,title.sym
into the schematic fromxschem_library/devices
folder as shown in Fig. 2.
Use bindkey
w
to connect and draw wires.Import
corner.sym
fromsky130_fd_pr
folder.Import
code_shown.sym
fromxschem_library/devices
folder with the following content.
name=SPICE only_toplevel=false value="
.dc Vin 0 1.8 0.01
.save all
"
The above command will sweep the input voltage source Vin
from 0V to 1.8V with 10mV per step.
The finished schematic is as shown in Fig. 3.
Step 2 - run simulation
In Xschem
top right corner, click Netlist
button. If there is no window pop up, click bindkey Shift-A
to enable the netlist pop up window.
From the netlist as shown in Fig. 4, we can observe the following:
- The devices have been netlisted correctly
- The Skywater130 PDK has been included in the netlist
- The DC sweep command has been added correctly
Next, click the Simulate
button. At Ngspice
popup window, type plot Vin Vout
and enter. The Vin and Vout waveforms are as shown in Fig. 5.
Step 3 - change simulation DC voltage sweep resolution
Let us change the Vin sweep step size from 10mV to 1mV and see if the simulation results change or not.
name=SPICE only_toplevel=false value="
.dc Vin 0 1.8 0.001
.save all
"
Step 4 - modify NMOS parameters
Currently, PMOS M11 dimension is W=1µm and L=0.15µm, while NMOS M1 dimension is also W=1µm and L=0.15µm.
From Fig. 6, we can tell that the inverter threshold is about 850mV. Let us change NMOS M1 channel width from 1µm to 10µm. Also, let us change the multiplier m
from 1 to 10 as well. As a result, the NMOS M1 becomes much stronger than before. Theoretically, the inverter's threshold should decrease because the NMOS is much easier to pull Vout to ground with the same voltage as before.
Fig. 7 clearly shows that the inverter's threshold has been moved to about 600mV, which matches with our prediction.
Step 5 - transient simulation
Click File
=> Save as
=> Rename the schametic to be SIM_inv_tran
. Then modify the schematic as shown in Fig. 8.
The simulation result is shown in Fig. 9.
Next, let us try a much sharper edge rate for the Vin so that we can clearly see the coupling from input to the output. To do so, let us modify as follows:
name=SPICE only_toplevel=false value="
.tran 10p 20n
.save all
"
name=Vin
value="pulse(0 1.8 1ns 0.1ns 0.1ns 5ns 10ns)"
Fig. 10 shows the updated transient simulation result, where we can clearly see the coupling from input to the output.