Create symbol and hierarchical schematic in Xschem

Ming Sun

Ming Sun / November 05, 2022

5 min read––– views

In this blog post, let us create a simple nand2 logic gate in Xschem. And then we are going to use Skywater130 PDK and Ngspice to simulate it.

Cell name: SIM_nand2
PDK: Skywater130
Schematic capture: Xschem
Simulator: Ngspice

Step 1 - Create the nand2 schematic

If you are not familiar with Xschem, please follows Ref. [1~2] to learn how to import devices and run simulations in Xschem.

Create the nand2 schematic as shown in Fig. 1.

nand2 schematic
Fig. 1nand2 schematic

The symbols used in the schematic are listed below.

pfet_01v8.symsky130A/ PMOS
nfet_01v8.symsky130A/ NMOS
title.symxschem/xschem_library/devicestitle block
ipin.symxschem/xschem_library/devicesinput port
opin.symxschem/xschem_library/devicesoutput port

Step 2 - Create the nand2 symbol

At nand2 schematic, press bindkey a to create symbol as shown in Fig. 2.

nand2 symbol
Fig. 2nand2 symbol

For the shape, such as line, arc, circle, you can use the following bindkey to create[3].

ldraw line
shift-cdraw arc
control-shift-cdraw circle

Another way to draw the symbol is that we can open the nand2_1.sym symbol under this path /usr/share/pdk/sky130A/

Step 3 - Create the test bench

Next, we can create the SIM_nand2.sch test bench to simulate the nand2 standard cell we just created. The test bench is as shown in Fig. 3.

SIM_nand2 schematic
Fig. 3SIM_nand2 schematic

The transient simulation result is as shown in Fig. 4.

SIM_nand2 schematic
Simulation results
Fig. 4 Simulation results

From Fig. 4, we can tell that nand2 output logic 0 only when both Vin1 and Vin2 are at logic 1, which matches with the nand2 function.

References and materials

[1] Basic RLC simulation in Xschem

[2] Basic inverter simulation in Xschem

[3] Xschem hotkeys cheatsheet

[4] SIM_nand2 schematic pdf - download

Google ScholarLinkedIn