Basic inverter simulation in Xschem

Ming Sun

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.

Cell name: SIM_inv, SIM_inv_tran
PDK: Skywater130
Schematic capture: Xschem
Simulator: Ngspice

Step 1 - Create the test bench

  • First, import 1.8V NMOS symbol nfet_01v8.sym into the schematic by going to sky130_fd_pr folder as shown below. The bindkey for import is Shift-i.
Import 1.8V NMOS symbol into schematic
Fig. 1Import 1.8V NMOS symbol into schematic[1]
  • 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 from xschem_library/devices folder as shown in Fig. 2.

Import VDD symbol in to schematic
Fig. 2Import VDD symbol in to schematic[1]
  • Use bindkey w to connect and draw wires.

  • Import corner.sym from sky130_fd_pr folder.

  • Import code_shown.sym from xschem_library/devices folder with the following content.

code_shown.sym
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.

SIM_inv schematic
Fig. 3SIM_inv schematic[1]

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
SIM_inv netlist
Fig. 4SIM_inv netlist[1]

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.

Simulation result - DC sweep of Vin
Fig. 5Simulation result - DC sweep of Vin[1]

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.

code_shown.sym
name=SPICE only_toplevel=false value="
.dc Vin 0 1.8 0.001
.save all
"
Simulation result - 1mV DC sweep per step
Fig. 6Simulation result - 1mV DC sweep per step[1]

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.

Simulation result - M1 = 10*1µm
Fig. 7Simulation result - M1 = 10*1µm[1]

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.

Transient simulation test bench
Fig. 8Transient simulation test bench[1]

The simulation result is shown in Fig. 9.

Transient simulation result
Fig. 9Transient simulation result[1]

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:

code_shown.sym
name=SPICE only_toplevel=false value="
.tran 10p 20n
.save all
"
Vin
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.

Transient simulation result
Fig. 10Transient simulation result[1]

References and materials

[1] bminch's Youtube video

[2] SIM_inv.sch download

[3] SIM_inv_tran.sch download


HomeWikis
SnippetsAbout
Google ScholarLinkedIn